Skip to content

Commit

Permalink
Merge pull request #3296 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…2899-to-release-4.13

[release-4.13] HOSTEDCP-1146: cpo: use CPO spec container image if it is a sha256 reference
  • Loading branch information
openshift-merge-bot[bot] committed Dec 14, 2023
2 parents 24cdafd + 1190bce commit 1ef713f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions control-plane-operator/main.go
Expand Up @@ -248,8 +248,18 @@ func NewStartCommand() *cobra.Command {
if err := mgr.GetAPIReader().Get(ctx, crclient.ObjectKeyFromObject(me), me); err != nil {
return "", fmt.Errorf("failed to get operator pod %s: %w", crclient.ObjectKeyFromObject(me), err)
}
// Use the container status to make sure we get the sha256 reference rather than a potentially
// floating tag.

// If CPO container image is a sha256 reference, use it
for _, container := range me.Spec.Containers {
if container.Name == "control-plane-operator" {
if strings.Contains(container.Image, "@sha256:") {
return container.Image, nil
}
}
}

// CPO container image is not a sha256 reference
// Use the container status to make sure we get the sha256 reference
for _, container := range me.Status.ContainerStatuses {
// TODO: could use downward API for this too, overkill?
if container.Name == "control-plane-operator" {
Expand Down

0 comments on commit 1ef713f

Please sign in to comment.