MCPcopy
hub / github.com/docker/compose / mustRecreate

Method mustRecreate

pkg/compose/reconcile.go:540–560  ·  view source on GitHub ↗

mustRecreate decides whether oc must be recreated to match expected. The expectedHash and parentRecreated inputs are precomputed once per service by reconcileService — see expectedConfigHash and parentNamespaceRecreated for the rationale (issue #13878).

(expected types.ServiceConfig, expectedHash string, parentRecreated bool, oc ObservedContainer, policy string)

Source from the content-addressed store, hash-verified

538// reconcileService — see expectedConfigHash and parentNamespaceRecreated for
539// the rationale (issue #13878).
540func (r *reconciler) mustRecreate(expected types.ServiceConfig, expectedHash string, parentRecreated bool, oc ObservedContainer, policy string) bool {
541 switch policy {
542 case api.RecreateNever:
543 return false
544 case api.RecreateForce:
545 return true
546 }
547 if parentRecreated {
548 return true
549 }
550 if oc.ConfigHash != expectedHash {
551 return true
552 }
553 if oc.ImageDigest != expected.CustomLabels[api.ImageDigestLabel] {
554 return true
555 }
556 if oc.State == container.StateRunning && r.hasNetworkMismatch(expected, oc) {
557 return true
558 }
559 return r.hasVolumeMismatch(expected, oc)
560}
561
562// parentNamespaceRecreated reports whether any namespace- or volume-sharing
563// parent of svc has at least one container scheduled for recreation. The

Callers 2

reconcileServiceMethod · 0.95
sortContainersMethod · 0.95

Calls 2

hasNetworkMismatchMethod · 0.95
hasVolumeMismatchMethod · 0.95

Tested by

no test coverage detected