Skip to content

OCPBUGS-31522: Warn and allow CRD upgrade if validation fails but new CRD specifies a conversion strategy #3209

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

Conversation

everettraven
Copy link
Contributor

@everettraven everettraven commented Apr 23, 2024

Description of the change:

  • Updates the CRD Upgrade validation logic to warn when the validations for a CRD upgrade fails but the new CRD specifies a conversion strategy

Motivation for the change:

  • When the new version of the CRD specifies a conversion strategy it is assumed that this conversion strategy should be used to perform conversion. There is no guarantee existing conversion strategies match this conversion strategy and thus OLM should assume the conversion would result in successful validation and allow the upgrade through with a warning.

Architectural changes:

Testing remarks:

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Bug fixes are accompanied by regression test(s)
  • e2e tests and flake fixes are accompanied evidence of flake testing, e.g. executing the test 100(0) times
  • tech debt/todo is accompanied by issue link(s) in comments in the surrounding code
  • Tests are comprehensible, e.g. Ginkgo DSL is being used appropriately
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive
  • Tests marked as [FLAKE] are truly flaky and have an issue
  • Code is properly formatted

Sorry, something went wrong.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 23, 2024

Verified

This commit was signed with the committer’s verified signature.
driesvints Dries Vints
…ersion strategy

Signed-off-by: everettraven <[email protected]>
@everettraven everettraven force-pushed the bug/crd-upgrade-conversion-warn branch from 4fc01b4 to 43c7bd9 Compare April 29, 2024 18:46
@everettraven everettraven changed the title WIP: Bug/crd upgrade conversion warn OCPBUGS-31522: Warn and allow CRD upgrade if validation fails but new CRD specifies a conversion strategy Apr 30, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 30, 2024
@grokspawn
Copy link
Contributor

/jira refresh

Verified

This commit was signed with the committer’s verified signature.
driesvints Dries Vints
Signed-off-by: everettraven <[email protected]>
Comment on lines 147 to 148
if crd.Spec.Conversion == nil || crd.Spec.Conversion.Strategy == apiextensionsv1.NoneConverter || !errors.As(err, vErr) {
return fmt.Errorf("error validating existing CRs against new CRD's schema for %q: %w", step.Resource.Name, err)
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to explicitly check for Webhook Converter to switch to the warn logic. If another converter type is added in the future, I think that should be an error, not a warning. If it turns out that new converter type is something we can't evaluate we could opt that into the warning logic at that time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be done in 209d783

// is an error related to validation, warn that validation failed but that we are trusting
// that the conversion strategy specified by the author will successfully convert to a format
// that passes validation and allow the upgrade to continue
b.logger.Warnf("trusting conversion strategy detected in new CRD, but failed validation of existing CRs against new CRD's schema for %q: %s",
Copy link
Member

Choose a reason for hiding this comment

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

Two things:

  1. This is likely something that needs some pretty descriptive messaging. Can you try to explain a bit more about why this isn't being treated as an error.
  2. I think we need to use an EventRecorder to emit the warning as a kubernetes event against the InstallPlan object.

Copy link
Member

Choose a reason for hiding this comment

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

(But keep this. Logging to the olm-operator log is helpful too)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be done in 209d783

… installplan

Signed-off-by: everettraven <[email protected]>
Comment on lines 158 to 164
warnTempl := `validation of existing CRs against new CRD's schema failed, but a webhook conversion strategy was specified.
allowing the CRD upgrade to occur as we can't run the webhook, but is assumed that it will successfully convert existing CRs
to a format that would have passed validation.
CRD: %q
Validation Error: %s
`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
warnTempl := `validation of existing CRs against new CRD's schema failed, but a webhook conversion strategy was specified.
allowing the CRD upgrade to occur as we can't run the webhook, but is assumed that it will successfully convert existing CRs
to a format that would have passed validation.
CRD: %q
Validation Error: %s
`
warnTempl := `Validation of existing CRs against the new CRD's schema failed, but a webhook conversion strategy was specified in the new CRD. The new webhook will only start after the bundle is upgraded, so we must assume that it will successfully convert existing CRs to a format that would have passed validation.
CRD: %q
Validation Error: %s
`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 91b7f5f

Signed-off-by: everettraven <[email protected]>
@everettraven everettraven added this pull request to the merge queue May 2, 2024
@everettraven everettraven removed this pull request from the merge queue due to a manual request May 2, 2024
@everettraven everettraven enabled auto-merge May 2, 2024 13:32
@everettraven everettraven added this pull request to the merge queue May 2, 2024
Copy link
Contributor

@dtfranz dtfranz left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 2, 2024
@dtfranz dtfranz added this pull request to the merge queue May 2, 2024
Merged via the queue into operator-framework:master with commit c3e1774 May 2, 2024
14 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.

None yet

4 participants