Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator: fix upgradeImages #1865

Merged
merged 2 commits into from
Oct 16, 2024
Merged

operator: fix upgradeImages #1865

merged 2 commits into from
Oct 16, 2024

Conversation

hj-johannes-lee
Copy link
Contributor

@hj-johannes-lee hj-johannes-lee commented Oct 4, 2024

fixes: #1873
Operatorhub bundle can have sha256 image tags that are put through env vars. When operator controller manager gets upgraded, its operands (plugin daemonsets) should be updated to the image in the env vars. But it has not been working properly because of wrong parsing.

Fix it to parse the image names that have sha256 tags correctly so env vars in operator can be used as intended.

@mythi
Copy link
Contributor

mythi commented Oct 4, 2024

For sha256 image tags, it has not been working properly.

Can you write how you expect it to work and how it works now. IIRC we decided SHA pinning is only for the env var approach.

@hj-johannes-lee
Copy link
Contributor Author

hj-johannes-lee commented Oct 4, 2024

If image is intel-qat-plugin@sha256:69858421d6abd38867f61844db2c3fa7275bf6c089efd547e7de98dfc0c90a1a

Before:
name was intel-qat-plugin@sha256
and upgradeImage was not working even though envVar is properly set.

For example, let's say there is 0.30.0 version of deployed operatorhub bundle using olm (as written in the link), and then let's say we deploy a qat plugin (0.30.0 version).
And then we update the bundle with the comamnd:

operator-sdk run bundle-upgrade intel/intel-deviceplugins-operator:0.31.0

Then, the qat-plugin is expected to be upgraded automatically according to the envVar, but it does not because the parsing has been wrong (intel-qat-plugin@sha256)

So,
I expect name to be intel-qat-plugin so that it can be updated when another sha256 is found from envVar.
And it works now like that, and tested with olm.

IIRC we decided SHA pinning is only for the env var approach.

Yeah, this fix is for fixing the misimplementation with env var approach.
Maybe I need to make the commit message more clear.

@mythi
Copy link
Contributor

mythi commented Oct 5, 2024

Thanks for noticing this! TestUpgrade unit test needs updating to get this covered. Also .1 release is needed

@hj-johannes-lee
Copy link
Contributor Author

hj-johannes-lee commented Oct 5, 2024

Yeah, I think we should have had it already... It's my mistake.
I pushed the commit for the testUpgrade fix too.

@hj-johannes-lee hj-johannes-lee force-pushed the PR-2024-010 branch 3 times, most recently from de64c4d to 663ba27 Compare October 8, 2024 19:05
@hj-johannes-lee hj-johannes-lee marked this pull request as draft October 8, 2024 19:05
@hj-johannes-lee hj-johannes-lee marked this pull request as ready for review October 8, 2024 19:13
Copy link
Contributor

@mythi mythi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for full coverage, we'd also need a case where image is same as the corresponding envVar and when the envVar is not in the pinned/sha256 format.

pkg/controllers/reconciler_test.go Outdated Show resolved Hide resolved
@hj-johannes-lee
Copy link
Contributor Author

hj-johannes-lee commented Oct 14, 2024

@mythi

for full coverage, we'd also need a case where image is same as the corresponding envVar and when the envVar is not in the pinned/sha256 format.

Umm, we do not check in reconciler.go whether the envVar value is sha256 format or not.
In our current implementation, we always expect the envvar value for the image would be in sha256 format as the name of the envvar itself is like INTEL_DSA_PLUGIN_SHA

So, do you want to improve the implementation? Or... did I misunderstand what you mean?

@mythi
Copy link
Contributor

mythi commented Oct 14, 2024

So, do you want to improve the implementation?

we can focus on the current functionality and make sure all scenarios are covered

@hj-johannes-lee
Copy link
Contributor Author

hj-johannes-lee commented Oct 14, 2024

@mythi
Thanks for the comment. I think we all cover for the "current implementation."
edit: We need to cover the case of 'same image given in env var'. Let me add it.

Anyway, I opened an issue because we should improve the functionality of UpgradeImage at some point.
#1881

@hj-johannes-lee
Copy link
Contributor Author

Fixed.!

And,, added some comments in the code to make it understandable more easily (actually for myself to understand next time.. I need to always follow the process and understand again...). If you think it's not good, let me konw.!

Operatorhub bundle can have sha256 image tags that are put through
env vars. When operator controller manager gets upgraded, its
operands (plugin daemonsets) should be updated to the image in the
env vars. But it has not been working properly because of wrong
parsing.

Fix it to parse the image names that have sha256 tags correctly so
env vars in operator can be used as intended.

Additionatlly, add comments with an example result to the part
where parsing, trimming, or transforming the name of images happens
in UpgradImages to make the process intuitive.

Signed-off-by: Hyeongju Johannes Lee <[email protected]>
Copy link
Contributor

@mythi mythi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@tkatila tkatila merged commit d2279d1 into intel:main Oct 16, 2024
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix operator to support image with sha256 tags through env vars
3 participants