Skip to content

Commit

Permalink
Revert "revert to using unhealthy state as disconnected"
Browse files Browse the repository at this point in the history
This reverts commit 34bc7f4.
  • Loading branch information
maximpertsov committed Sep 24, 2024
1 parent a0fc8d8 commit 08db841
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions resource/graph_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ 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 @@ -294,10 +297,9 @@ func (w *GraphNode) NeedsReconfigure() bool {
w.mu.RLock()
defer w.mu.RUnlock()

// 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))
// 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
}

// hasUnresolvedDependencies returns whether or not this node has any
Expand Down Expand Up @@ -362,11 +364,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.LogAndSetLastError(errDisconnected)
w.mu.Lock()
defer w.mu.Unlock()
w.transitionTo(NodeStateDisconnected)
}

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

0 comments on commit 08db841

Please sign in to comment.