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

Ignore no match errors on deleting obsolete resources #1739

Merged
Changes from all 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
14 changes: 12 additions & 2 deletions pkg/reconciler/common/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ package common

import (
"context"
"fmt"

mf "github.com/manifestival/manifestival"
"knative.dev/operator/pkg/apis/operator/base"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"knative.dev/pkg/logging"

"knative.dev/operator/pkg/apis/operator/base"
)

// Stage represents a step in the reconcile process
Expand Down Expand Up @@ -110,6 +114,12 @@ func DeleteObsoleteResources(ctx context.Context, instance base.KComponent, fetc
return NoOp
}
return func(_ context.Context, manifest *mf.Manifest, _ base.KComponent) error {
return installed.Filter(mf.NoCRDs, mf.Not(mf.In(*manifest))).Delete()
for _, r := range installed.Filter(mf.NoCRDs, mf.Not(mf.In(*manifest))).Resources() {
m, _ := mf.ManifestFrom(mf.Slice([]unstructured.Unstructured{r}), mf.UseClient(manifest.Client))
if err := m.Delete(); err != nil && !meta.IsNoMatchError(err) {
return fmt.Errorf("failed to delete obsolete resources: %w", err)
}
}
return nil
}
}
Loading