Skip to content

Override the ClusterServiceVersion.metadata.containerImage value when callingack-generate olm with values from build scripts #780

@komish

Description

@komish

Describe the bug

The ack-generate olm generator will lay down a ClusterServiceVersion manifest in {CONTROLLER_SOURCE}/config/manifests/bases/. The metadata.annotations section of this particular YAML manifest contains a bunch of keys that inform the way the OpenShift console renders the service as an operator in its OperatorHub.

One of those keys is containerImage. The value for that is pretty rigid right now:

metadata:
  annotations:
    ...
    containerImage: {{.Annotations.ContainerImage}}:{{.ServiceIDClean}}-v{{.Version}}
    ...

https://github.com/aws-controllers-k8s/code-generator/blob/main/templates/config/manifests/bases/clusterserviceversion.yaml.tpl#L10

Currently, this can be overridden using the olmconfig.yaml, however, you can only really override the registry, repository namespace, and image Name (e.g. my-registry.example.com/repositoryNamespace/imageName). By default the value is as follows:

ContainerImage:     "public.ecr.aws/aws-controllers-k8s/controller",

https://github.com/aws-controllers-k8s/code-generator/blob/main/pkg/generate/olm/olm.go#L110

This works for a majority of cases, but should you at any point change your registry, or should anyone generate the project with intentions of storing them in a different registry, then this causes a discrepancy between rendered release assets (i.e. the OLM bundle at the very least).


Steps to reproduce

From the community repository, run:

# While you can overwrite the image here, I believe it only makes a different in the rendered helm assets.
./scripts/build-controller-release.sh <service> <version>

# If you intend to point your OLM bundle to a different registry, the ClusterServiceVersion base that gets
# put on disk here is already wrong. This will be come clear when you run the following while setting 
SERVICE_CONTROLLER_CONTAINER_REPOSITORY="your-registry.example.com/namespace/imagename"
./scripts/olm-create-bundle.sh <service> <version>

# Confirm that the rendered bundle assets have values that are mismatched:
grep -R [Ii]mage\: ../s3-controller/olm/bundle/manifests/*clusterserviceversion.yaml

Output from some release testing I was working on earlier for the s3-controller:

../s3-controller/olm/bundle/manifests/ack-s3-controller.clusterserviceversion.yaml:    containerImage: public.ecr.aws/aws-controllers-k8s/controller:s3-v7.1.2
../s3-controller/olm/bundle/manifests/ack-s3-controller.clusterserviceversion.yaml:                image: quay.io/komish/s3-controller:7.1.2

Note that this does not impede my ability to test. I still was able to test - but ultimately the representation on the OpenShift Console and in places like OperatorHub will be inconsistent.


Expected outcome

Ideally, I'd like these values to match. Two implementation options that I could think of off the top of my head were:

(1) Add a flag to the ack-generate olm command, or read the environment, such that it dictates how this metadata piece should look. There will need to be clearly defined precedence between the flag/environment, and the value that's read in the olmconfig (if any).

(2) change this value, or otherwise add it to the manifest base after the initial generation (potentially in the build scripts or the bundle creation scripts).

Happy to hear any other ideas! I'm looking for any kind of implementation suggestions that fit best with the project's release tasks.


Environment

  • Kubernetes version: OpenShift! =D
  • Using EKS (yes/no), if so version? N/A
  • AWS service targeted (S3, RDS, etc.): All

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions