Skip to content

Commit

Permalink
Don't use the last-applied-configuration annotation for CRDs
Browse files Browse the repository at this point in the history
  • Loading branch information
lblackstone committed May 24, 2022
1 parent eff0634 commit f2494e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Unreleased
(None)

- Don't use the last-applied-configuration annotation for CRDs (https://github.com/pulumi/pulumi-kubernetes/pull/1882)

## 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

0 comments on commit f2494e2

Please sign in to comment.