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

Don't use the last-applied-configuration annotation for CRDs #1882

Merged
merged 4 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Note: The `kubernetes:helm/v2:Chart` API was deprecated in this update and will
updates.

- Deprecate helm/v2:Chart resources (https://github.com/pulumi/pulumi-kubernetes/pull/1990)
- Don't use the last-applied-configuration annotation for CRDs (https://github.com/pulumi/pulumi-kubernetes/pull/1882)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we verify if this obviates the enableReplaceCRD flag? In which case lets remove and call it out explicitly in the changelog.

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 catch! I verified that the enableReplaceCRD option is no longer required, and added a deprecation notice to clarify that it is no longer used and will be removed in the future.


## 3.19.0 (May 3, 2022)

Expand Down
17 changes: 12 additions & 5 deletions provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2575,15 +2575,23 @@ func (k *kubeProvider) tryServerSidePatch(oldInputs, newInputs *unstructured.Uns
}

func (k *kubeProvider) withLastAppliedConfig(config *unstructured.Unstructured) (*unstructured.Unstructured, error) {
if k.enableReplaceCRD && clients.IsCRD(config) {
// Skip last-applied-config annotation when CRD replacement is enabled.
return config, nil
}
if k.supportsDryRun(config.GroupVersionKind()) {
// Skip last-applied-config annotation if the resource supports server-side apply.
return config, nil
}

// CRDs are updated using a separate mechanism, so skip the last-applied-configuration annotation, and delete it
// if it was present from a previous update.
if clients.IsCRD(config) {
// Deep copy the config before returning.
config = config.DeepCopy()

annotations := getAnnotations(config)
delete(annotations, lastAppliedConfigKey)
config.SetAnnotations(annotations)
return config, nil
}

// Serialize the inputs and add the last-applied-configuration annotation.
marshaled, err := config.MarshalJSON()
if err != nil {
Expand All @@ -2594,7 +2602,6 @@ func (k *kubeProvider) withLastAppliedConfig(config *unstructured.Unstructured)
config = config.DeepCopy()

annotations := getAnnotations(config)

annotations[lastAppliedConfigKey] = string(marshaled)
config.SetAnnotations(annotations)
return config, nil
Expand Down