-
Notifications
You must be signed in to change notification settings - Fork 560
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
Changes from 1 commit
43c7bd9
81d1ed4
209d783
91b7f5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,7 +140,21 @@ func (b *builder) NewCRDV1Step(client apiextensionsv1client.ApiextensionsV1Inter | |
currentCRD, _ := client.CustomResourceDefinitions().Get(context.TODO(), crd.GetName(), metav1.GetOptions{}) | ||
crd.SetResourceVersion(currentCRD.GetResourceVersion()) | ||
if err = validateV1CRDCompatibility(b.dynamicClient, currentCRD, crd); err != nil { | ||
return fmt.Errorf("error validating existing CRs against new CRD's schema for %q: %w", step.Resource.Name, err) | ||
vErr := &ValidationError{} | ||
// if the conversion strategy in the new CRD is "None" OR the error is not a ValidationError | ||
// return an error. This will catch and return any errors that occur unrelated to actual validation. | ||
// For example, the API server returning an error when performing a list operation | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be done in 209d783 |
||
} | ||
// If the conversion strategy in the new CRD is not "None" and the error that occurred | ||
// 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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two things:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (But keep this. Logging to the olm-operator log is helpful too) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be done in 209d783 |
||
step.Resource.Name, | ||
err.Error(), | ||
) | ||
} | ||
|
||
// check to see if stored versions changed and whether the upgrade could cause potential data loss | ||
|
@@ -267,9 +281,7 @@ func (b *builder) NewCRDV1Beta1Step(client apiextensionsv1beta1client.Apiextensi | |
} | ||
|
||
func setInstalledAlongsideAnnotation(a alongside.Annotator, dst metav1.Object, namespace string, name string, lister listersv1alpha1.ClusterServiceVersionLister, srcs ...metav1.Object) { | ||
var ( | ||
nns []alongside.NamespacedName | ||
) | ||
var nns []alongside.NamespacedName | ||
|
||
// Only keep references to existing and non-copied CSVs to | ||
// avoid unbounded growth. | ||
|
Uh oh!
There was an error while loading. Please reload this page.