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

Add job to update policies and kubectl image #407

Merged
merged 6 commits into from
Mar 26, 2024

Conversation

viccuad
Copy link
Member

@viccuad viccuad commented Mar 19, 2024

Description

Fix #388

Add job that checks the policies and kubectl image tags every week,
and opens a PR if there's any bump needed.

Test

Tested updatecli part locally with:

  --config updatecli/updatecli.d/update-deps.yaml \
  --values updatecli/values.yaml

Tested make generate-policies-file generate-images-file, everything works for airgap scripts.

Tested in my fork:
https://github.com/viccuad/helm-charts/actions/runs/8393105846/job/22987348660
viccuad#2

Additional Information

Should wait for merge until 1.11 is released.

Tradeoff

Potential improvement

Comment on lines 127 to 103
updateCapabilitiesPolicyTag:
name: Update capabilities-psp tag
kind: yaml
sourceid: capabilitiesPolicyTag
spec:
file: "charts/kubewarden-defaults/values.yaml"
key: "$.recommendedPolicies.capabilitiesPolicy.module.tag"
Copy link
Member

@jvanz jvanz Mar 19, 2024

Choose a reason for hiding this comment

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

Where are the tags updated? Reading script I have the impression that script just checks if the tag from the values files are the latest ones. But I do not understand where are the targets that will update it with the latest version. Furthermore, where the latest tags are fetched? I think we should do something similar of the dockerimage example

Copy link
Member

Choose a reason for hiding this comment

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

To test the script, I've merge this PR into my helm-charts repository main branch and downgrade two policies. Then, I've ran the CI. The CI is green but no PR is open. In the logs we can see that script ran every step but it does not update the tags.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed now with a rebase. One doesn't need conditions, just to set target.foo.scmid.

Tested in my fork:
https://github.com/viccuad/helm-charts/actions/runs/8393105846/job/22987348660
viccuad#2

viccuad added 2 commits March 22, 2024 11:35
This allows for programatically consuming module.tag, for example in
airgap scripts or update scripts.

Signed-off-by: Víctor Cuadrado Juan <[email protected]>
Signed-off-by: Víctor Cuadrado Juan <[email protected]>
@viccuad viccuad force-pushed the feat-update-policies branch from 7dca022 to b2720e3 Compare March 22, 2024 16:06
viccuad added 4 commits March 22, 2024 17:10
Add job that checks the policies and kubectl image tags every week,
and opens a PR if there's any bump needed.

Signed-off-by: Víctor Cuadrado Juan <[email protected]>
Signed-off-by: Víctor Cuadrado Juan <[email protected]>
@viccuad viccuad force-pushed the feat-update-policies branch from b2720e3 to 81d48a4 Compare March 22, 2024 16:11
@viccuad viccuad requested a review from jvanz March 22, 2024 16:19
@viccuad viccuad marked this pull request as ready for review March 22, 2024 16:19
@viccuad viccuad requested a review from a team as a code owner March 22, 2024 16:19
Copy link
Member

@jvanz jvanz left a comment

Choose a reason for hiding this comment

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

I could see the script working now. But I have a question about the script to update the dependencies

Comment on lines +4 to +9
kubectlImageTag:
kind: dockerimage
spec:
image: ghcr.io/kubewarden/kubectl
versionfilter:
kind: semver
Copy link
Member

Choose a reason for hiding this comment

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

The test in my fork I can see the script bumping the version. That's nice! Thanks for that!

But I have some questions, how the versionfilter knows which is the latest version? Does it perform semver comparisons? What are the difference from the kind latest?

I'm wondering if we can hit some coner case like a patch release is published after a major/minor release. In other words, let's image that we have a latest release which is v2.0.0 but we release a patch release v1.9.1 to fix an issue in the v1.9.0 version. Will the script downgrade the policy because v1.9.1 is the most recent version? I was reading the updatecli docs I did not fully understand what's happening here.

Copy link
Member

Choose a reason for hiding this comment

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

I'm aware that scenario never happen before. But I would like to understand that to help the maintainance of the script in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question, tripped me too.
Right now the spec.versionfilter is configured with semver and no pattern. This means it defaults to pattern: *, and will accept any valid semver (including prereleases, which I think it's fine, we review the PR) that are newer than the current semver version (so, not :latest nor downgrades). See here.

@viccuad viccuad merged commit 300e807 into kubewarden:main Mar 26, 2024
2 of 3 checks passed
@viccuad viccuad deleted the feat-update-policies branch March 26, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automation: update version of policies referenced by kubewarden-defaults chart
2 participants