From: Sage Weil Date: Sat, 3 Apr 2021 13:14:00 +0000 (-0400) Subject: cephadm: normalize unqualified repo digests to docker.io X-Git-Tag: v16.2.2~28^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8d27b8fecbb80f7ed94ac7b70ba894b5af39ade7;p=ceph.git cephadm: normalize unqualified repo digests to docker.io A RepoDigests returned by docker|podman image inspect can either include the docker.io/ prefix or not. For reasons that aren't entirely clear, this may vary between hosts in a cluster. However, ceph/ceph@sha256:abc... is the same thing as docker.io/ceph/ceph@sha256:abc..., and should be treated as such. Otherwise, upgrade can get into a loop where it pulls the image on a new host, finds the other variant of the repodigests, sees no overlap, updates target_digests, and restarts. (It will then find the first variant again on the first host and loop.) Avoid this by normalizing any docker.io digests by always including the docker.io/ prefix. Note that it is technically possible that this assumption is wrong: it may be that the image that already exists on the local host is from a different registry in registries.conf's unqualified-search-registries. However, we don't know which, since this is a search list. In practice, it should be exceeding rare that an image that *we* are installing using a fully-qualified image name will end up having an unqualified repodigest in the local registry. Hopefully! Fixes: https://tracker.ceph.com/issues/50114 Signed-off-by: Sage Weil (cherry picked from commit e07a73830436340e77180782216524f071a5a292) --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index fe870f6e814e..bf3ec7ab66c9 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -53,6 +53,7 @@ DEFAULT_PROMETHEUS_IMAGE = 'docker.io/prom/prometheus:v2.18.1' DEFAULT_NODE_EXPORTER_IMAGE = 'docker.io/prom/node-exporter:v0.18.1' DEFAULT_GRAFANA_IMAGE = 'docker.io/ceph/ceph-grafana:6.7.4' DEFAULT_ALERT_MANAGER_IMAGE = 'docker.io/prom/alertmanager:v0.20.0' +DEFAULT_REGISTRY = 'docker.io' # normalize unqualified digests to this # ------------------------------------------------------------------------------ LATEST_STABLE_RELEASE = 'pacific' @@ -3258,6 +3259,20 @@ def command_inspect_image(ctx): return 0 +def normalize_image_digest(digest): + # normal case: + # ceph/ceph -> docker.io/ceph/ceph + # edge cases that shouldn't ever come up: + # ubuntu -> docker.io/ubuntu (ubuntu alias for library/ubuntu) + # no change: + # quay.ceph.io/ceph/ceph -> ceph + # docker.io/ubuntu -> no change + bits = digest.split('/') + if '.' not in bits[0] or len(bits) < 3: + digest = DEFAULT_REGISTRY + '/' + digest + return digest + + def get_image_info_from_inspect(out, image): # type: (str, str) -> Dict[str, Union[str,List[str]]] image_id, digests = out.split(',', 1) @@ -3267,7 +3282,7 @@ def get_image_info_from_inspect(out, image): 'image_id': normalize_container_id(image_id) } # type: Dict[str, Union[str,List[str]]] if digests: - r['repo_digests'] = digests[1:-1].split(' ') + r['repo_digests'] = list(map(normalize_image_digest, digests[1:-1].split(' '))) return r ##################################