Skip to content

Commit

Permalink
revert to using unhealthy state as disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpertsov committed Sep 24, 2024
1 parent 92b3fd9 commit 34bc7f4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions resource/graph_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ const (

// NodeStateUnhealthy denotes a resource is unhealthy.
NodeStateUnhealthy

// NodeStateDisconnected denotes a resource is disconnected.
NodeStateDisconnected
)

// A GraphNode contains the current state of a resource.
Expand Down Expand Up @@ -297,9 +294,10 @@ func (w *GraphNode) NeedsReconfigure() bool {
w.mu.RLock()
defer w.mu.RUnlock()

// A resource can only become unhealthy during (re)configuration, so we can
// assume that an unhealthy node always need to be reconfigured.
return w.state == NodeStateConfiguring || w.state == NodeStateUnhealthy
// A resource can only become unhealthy during (re)configuration or if it is disconnected, so we
// can assume that an unhealthy node always need to be reconfigured unless it is disconnected.
return w.state == NodeStateConfiguring ||
(w.state == NodeStateUnhealthy && !errors.Is(w.lastErr, errDisconnected))
}

// hasUnresolvedDependencies returns whether or not this node has any
Expand Down Expand Up @@ -364,11 +362,11 @@ func (w *GraphNode) SetNeedsUpdate() {
w.setNeedsReconfigure(w.Config(), false, w.UnresolvedDependencies())
}

var errDisconnected = errors.New("disconnected")

// SetDisconnected is used to mark a remote node as disconnected.
func (w *GraphNode) SetDisconnected() {
w.mu.Lock()
defer w.mu.Unlock()
w.transitionTo(NodeStateDisconnected)
w.LogAndSetLastError(errDisconnected)
}

// setUnresolvedDependencies sets names that are yet to be resolved as
Expand Down

0 comments on commit 34bc7f4

Please sign in to comment.