operator-sdk: Don't override relatedImages in config CSV.

Bug Report

Looks like https://github.com/operator-framework/operator-sdk/issues/5000 has reappeared after related image discovery features were added. This has caused us to change how we specify relatedImages in our operator https://github.com/openshift/oadp-operator/pull/694

Seems to be sideeffect from related image discovery feature. Not sure which was the first PR for that.

Related PRs: https://github.com/operator-framework/operator-sdk/pull/5567

What did you do?

operatorsdk generate bundle.

What did you expect to see?

relatedImages in config CSV preserved

What did you see instead? Under which circumstances?

relatedImages in config CSV removed from generated bundle

Environment

Operator type:

/language go

$ operator-sdk version

operator-sdk version: “v1.20.0”, commit: “deb3531ae20a5805b7ee30b71f13792b80bd49b1”, kubernetes version: “v1.23”, go version: “go1.18.1”, GOOS: “darwin”, GOARCH: “amd64” $ go version (if language is Go)

go version go1.18.1 darwin/amd64 $ kubectl version

Possible Solution

Don’t override but append to existing relatedImages.

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@ryantking - Yeah makes sense to me. I hadn’t considered backcompat issue with the name changing. In all likelihood, there’s nothing that actually depends on that name since I know OLM and mirroring tooling ignore it. But there could be some operator author tooling that uses it.

So I’m plus +1 to that tweak, though I still think it makes sense to issue a warning about the statically defined related images. If we want to be more vague about why you shouldn’t do that, we could just say that specifying static related images is deprecated, that you should start using RELATED_IMAGE_ envs, and we’ll remove persistence of static related images is OSDK v2.

I think we should specifically recommend only the env-based related image detection. If there are csv.spec.relatedImages in the base CSV manifest, I think we should:

  1. Give them the lowest precedence when choosing names or de-duping.
  2. Output a warning along the lines of “we found related images in your base CSV. we preserved them in the generated CSV, but your operator is at risk for supporting disconnected environments”

So I think that logic would look like the following when comparing discovered vs base:

  1. same image, regardless of whether the names differ: use the discovered name/image pair in the output.
  2. same name with a different image: keep discovered name, prefix base name (with static- or base- or something along those lines).
  3. name/image pair not found in discovered set: add base name/image pair to output.

I need @tlwu2013 to check my math on item 2, but it seems like you need a RELATED_IMAGE_* environment variable for each other image you expect to use so that when your bundle is built, the pipeline can correctly inject digest-based image references for every image your operator uses.