pgraph, resources: Improve Init/Close and Worker status
This should do some rough cleanups around the Init/Close of resources, and tracking of Worker function status.
This commit is contained in:
@@ -316,7 +316,11 @@ func (g *Graph) Worker(v *Vertex) error {
|
||||
// the Watch() function about which graph it is
|
||||
// running on, which isolates things nicely...
|
||||
obj := v.Res
|
||||
obj.SetWorking(true) // gets set to false in Res.Close() method at end...
|
||||
|
||||
// run the init (should match 1-1 with Close function if this succeeds)
|
||||
if err := obj.Init(); err != nil {
|
||||
return errwrap.Wrapf(err, "could not Init() resource")
|
||||
}
|
||||
|
||||
lock := &sync.Mutex{} // lock around processChan closing and sending
|
||||
finished := false // did we close processChan ?
|
||||
@@ -629,7 +633,7 @@ func (g *Graph) Start(first bool) { // start or continue
|
||||
go func(vv *Vertex) {
|
||||
defer g.wg.Done()
|
||||
// TODO: if a sufficient number of workers error,
|
||||
// should something be done? Will these restart
|
||||
// should something be done? Should these restart
|
||||
// after perma-failure if we have a graph change?
|
||||
if err := g.Worker(vv); err != nil { // contains the Watch and CheckApply loops
|
||||
log.Printf("%s[%s]: Exited with failure: %v", vv.Kind(), vv.GetName(), err)
|
||||
|
||||
Reference in New Issue
Block a user