MCPcopy Create free account
hub / github.com/docker/cli / getActiveNodes

Function getActiveNodes

cli/command/service/progress/progress.go:219–232  ·  view source on GitHub ↗

getActiveNodes returns all nodes that are currently not in status [swarm.NodeStateDown]. TODO(thaJeztah): this should really be a filter on [apiClient.NodeList] instead of being filtered on the client side.

(ctx context.Context, apiClient client.NodeAPIClient)

Source from the content-addressed store, hash-verified

217//
218// TODO(thaJeztah): this should really be a filter on [apiClient.NodeList] instead of being filtered on the client side.
219func getActiveNodes(ctx context.Context, apiClient client.NodeAPIClient) (map[string]struct{}, error) {
220 res, err := apiClient.NodeList(ctx, client.NodeListOptions{})
221 if err != nil {
222 return nil, err
223 }
224
225 activeNodes := make(map[string]struct{})
226 for _, n := range res.Items {
227 if n.Status.State != swarm.NodeStateDown {
228 activeNodes[n.ID] = struct{}{}
229 }
230 }
231 return activeNodes, nil
232}
233
234func initializeUpdater(service swarm.Service, progressOut progress.Output) (progressUpdater, error) {
235 if service.Spec.Mode.Replicated != nil && service.Spec.Mode.Replicated.Replicas != nil {

Callers 1

ServiceProgressFunction · 0.85

Calls 1

NodeListMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…