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

Deprecate providesGVR flag and update validate script #620

Merged
merged 4 commits into from
Sep 9, 2020

Conversation

aiyengar2
Copy link
Contributor

@aiyengar2 aiyengar2 commented Sep 9, 2020

This PR deprecates the provideGVR flag and updates the validate script to unblock CI issues for local charts that use the generateCRDChart flag.

Related to build failures in #594

scripts/validate Outdated
providesGVR="$(cat ${f}/package.yaml | yq r - providesGVR)"
if [[ -n ${providesGVR} && -f ${f}/charts/Chart.yaml ]]; then
if [[ "$(yq r ${f}/charts/Chart.yaml 'annotations[catalog.cattle.io/provides-gvr]')" == "${providesGVR}" ]]; then
yq d -i ${f}/charts/Chart.yaml "annotations[catalog.cattle.io/provides-gvr]"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mrajashree I pulled out your local changes into my fork and tested this out and it seems to be passing validate on your script as expected... with one exception. I had to make a tiny change to your chart in this commit: aiyengar2@e152e52.

The technical reason why this change is required is because yq doesn't support preserving the formatting with in place writing (based on mikefarah/yq#465), so changes like yq d -i or yq w -i sprinkled throughout our codebase essentially reformat your Chart.yaml's formatting to a standard YAML format.

Specifically, this causes an issue in the validate script since it checks to see if your Git is dirty when performing the validate (i.e. you have changes that have not been committed to your patch or directly to your chart). Since you saved your Chart.yaml with a different format than what the output of yq [d/w] -i ${f}/charts/Chart.yaml would have generated, the validate will always fail since it will always assume your git is dirty.

TLDR, if you see an issue with the make validate, just make sure the Chart.yaml's output matches the output provided by yq r ${f}/charts/Chart.yaml, where f=packages/backup-restore-operator or something similar, and run make validate once more.

Copy link
Contributor

@mrajashree mrajashree Sep 9, 2020

Choose a reason for hiding this comment

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

yup I'd noticed that too, tested my commit with this PR and the ci works fine 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@aiyengar2 If yq is going to be changing formatting of files then failing a build this needs to be more obvious, and we need to include formatting as part of the make steps a dev will run locally similar to go-fmt so anyone will be compliant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Easy solution is just to remove these from package.yaml altogether and just manually put in the patch file. The dual way was too confusing. Since its disconnected from the CRD generation and pushed onto parent it doesn't make sense in package.yaml anymore and will greatly simplify scripts.

Copy link
Contributor Author

@aiyengar2 aiyengar2 Sep 9, 2020

Choose a reason for hiding this comment

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

@dramich the new last commit on the PR bf9a622 ensures that yq won't break the build. @mrajashree with the last commit, you should no longer need to make the Chart.yaml change to get your chart to pass CI.

I tried adding formatting as part of the make validate instead, but it seems like there are discrepancies between the style yq r gives on the machine that runs our tests vs. the local dev environment (i.e. make validate with some Chart.yamls that I changed to correctly format on my machine failed on the test machine since it expected a slightly different style, such as no spaces on list entries, breaks between big lines, etc.), so unless we somehow standardize the yq style across both environment, a make validate-fmt-type script will be difficult to create. Imo we should avoid making those types of changes in this PR though since this is blocking CIS / backup-restore-operator CI. We can address this when we switch to using Go scripts after 2.5.

re: @cbron's comments, I agree that providesGVR should be removed from the package.yaml to simplify the scripts, but I think we still need to modify the Chart.yaml for auto-install annotations for CRD charts.

Copy link
Contributor

Choose a reason for hiding this comment

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

We talked about this offline and to simplify things we are just removing all the providesGVR and git update-index stuff. Scripts has to stay small and simple until we rewrite. The downside is that validate might fail for original charts on chart.yaml formatting, we can make a separate make command for that later, but right now its a nice-to-have.

@aiyengar2 aiyengar2 changed the title Update all scripts to properly roll back changes Update several scripts to roll back changes from optional flags Sep 9, 2020
@aiyengar2 aiyengar2 changed the title Update several scripts to roll back changes from optional flags Update scripts to roll back changes from optional flags Sep 9, 2020
@aiyengar2 aiyengar2 changed the title Update scripts to roll back changes from optional flags Update scripts to roll back optional flag changes Sep 9, 2020
@aiyengar2 aiyengar2 force-pushed the fix_local_split_crd_validate branch 2 times, most recently from 4b11820 to 9f0383a Compare September 9, 2020 05:04
@aiyengar2 aiyengar2 force-pushed the fix_local_split_crd_validate branch 4 times, most recently from 8e79ff4 to 49eda64 Compare September 9, 2020 06:34
Copy link
Contributor

@mrajashree mrajashree left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@cbron cbron left a comment

Choose a reason for hiding this comment

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

Even if approved don't merge this until after 10am PST.

scripts/clean-crds Show resolved Hide resolved
scripts/validate Outdated
providesGVR="$(cat ${f}/package.yaml | yq r - providesGVR)"
if [[ -n ${providesGVR} && -f ${f}/charts/Chart.yaml ]]; then
if [[ "$(yq r ${f}/charts/Chart.yaml 'annotations[catalog.cattle.io/provides-gvr]')" == "${providesGVR}" ]]; then
yq d -i ${f}/charts/Chart.yaml "annotations[catalog.cattle.io/provides-gvr]"
Copy link
Contributor

Choose a reason for hiding this comment

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

Easy solution is just to remove these from package.yaml altogether and just manually put in the patch file. The dual way was too confusing. Since its disconnected from the CRD generation and pushed onto parent it doesn't make sense in package.yaml anymore and will greatly simplify scripts.

scripts/clean Outdated Show resolved Hide resolved
@aiyengar2 aiyengar2 force-pushed the fix_local_split_crd_validate branch 5 times, most recently from 34f65c7 to cb5e5f1 Compare September 9, 2020 16:55
@aiyengar2 aiyengar2 force-pushed the fix_local_split_crd_validate branch 4 times, most recently from 94cfbe5 to bf9a622 Compare September 9, 2020 17:29
@aiyengar2 aiyengar2 requested review from dramich and cbron September 9, 2020 17:48
@aiyengar2 aiyengar2 force-pushed the fix_local_split_crd_validate branch from bf9a622 to e9d6a4c Compare September 9, 2020 19:05
Before, the logic for reverting a CRD chart was located in `generate-patch` since it was the only script that required these changes. Now that the same logic is required on a `make clean` in order to support reverting just the generateCRDChart changes from local charts, this commit moves that logic out to its own script `clean-crds`.

Based on discussion in rancher#607 (comment).
@aiyengar2 aiyengar2 force-pushed the fix_local_split_crd_validate branch 3 times, most recently from ecf8e46 to df0cbe7 Compare September 9, 2020 19:24
Arvind Iyengar added 3 commits September 9, 2020 12:25
This commit deprecates the providesGVR flag used by charts in favor of charts adding this annotation directly to the patch of their chart (or their Chart.yaml).
By utilizing the `clean-crds` script, both `validate` and `clean` can cleanly deal with issues related to annotations added and files overlaid as part of the CRD chart process.
@aiyengar2
Copy link
Contributor Author

aiyengar2 commented Sep 9, 2020

Chart changes for deprecated providesGVR flag are located in #624

@aiyengar2 aiyengar2 changed the title Update scripts to roll back optional flag changes Deprecate providesGVR changes and update validate script Sep 9, 2020
@aiyengar2 aiyengar2 changed the title Deprecate providesGVR changes and update validate script Deprecate providesGVR flag and update validate script Sep 9, 2020
Copy link
Contributor

@cbron cbron left a comment

Choose a reason for hiding this comment

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

lgtm, merging this will break the provides->requires dependency but then 624 will fix them again, so we will merge in succession.
The formatting issue will be a known issue with original charts, both current chart owners know and we'll have fix in next edition.

@aiyengar2 aiyengar2 merged commit af76c27 into rancher:dev-v2.5 Sep 9, 2020
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.

5 participants