Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cmd/datasource-syncer/datasource-syncer.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
100 changes: 0 additions & 100 deletions e2e/webhook_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion manifests/operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion manifests/rule-evaluator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
69 changes: 0 additions & 69 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ import (
"github.com/go-logr/logr"
"github.com/prometheus/client_golang/api"
"github.com/prometheus/client_golang/prometheus"
arv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apiextensions "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -338,9 +336,6 @@ func New(logger logr.Logger, clientConfig *rest.Config, opts Options) (*Operator
func (o *Operator) Run(ctx context.Context, registry prometheus.Registerer) error {
defer runtimeutil.HandleCrash()

if err := o.cleanupOldResources(ctx); err != nil {
return fmt.Errorf("cleanup old resources: %w", err)
}
if err := setupAdmissionWebhooks(ctx, o.logger, o.client, o.manager.GetWebhookServer().(*webhook.DefaultServer), &o.opts, o.vpaAvailable); err != nil {
return fmt.Errorf("init admission resources: %w", err)
}
Expand All @@ -366,70 +361,6 @@ func (o *Operator) Run(ctx context.Context, registry prometheus.Registerer) erro
return o.manager.Start(ctx)
}

func (o *Operator) cleanupOldResources(ctx context.Context) error {
// Delete old ValidatingWebhookConfiguration that was installed directly by the operator.
// in previous versions.
validatingWebhookConfig := arv1.ValidatingWebhookConfiguration{
ObjectMeta: metav1.ObjectMeta{Name: "gmp-operator"},
}
if err := o.client.Delete(ctx, &validatingWebhookConfig); err != nil {
switch {
case apierrors.IsForbidden(err):
o.logger.Info("delete legacy ValidatingWebHookConfiguration was not allowed. Please remove it manually")
case !apierrors.IsNotFound(err):
return fmt.Errorf("delete legacy ValidatingWebHookConfiguration failed: %w", err)
}
}

// If cleanup annotations are not provided, do not clean up any further.
if o.opts.CleanupAnnotKey == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we remove this option now?

return nil
}

// Cleanup resources without the provided annotation.
// Check the collector DaemonSet.
dsKey := client.ObjectKey{
Name: NameCollector,
Namespace: o.opts.OperatorNamespace,
}
var ds appsv1.DaemonSet
if err := o.client.Get(ctx, dsKey, &ds); apierrors.IsNotFound(err) {
return fmt.Errorf("get collector DaemonSet: %w", err)
}
if _, ok := ds.Annotations[o.opts.CleanupAnnotKey]; !ok {
if err := o.client.Delete(ctx, &ds); err != nil {
switch {
case apierrors.IsForbidden(err):
o.logger.Info("delete collector was not allowed. Please remove it manually", "err", err)
case !apierrors.IsNotFound(err):
return fmt.Errorf("cleanup collector failed: %w", err)
}
}
}

// Check the rule-evaluator Deployment.
deployKey := client.ObjectKey{
Name: NameRuleEvaluator,
Namespace: o.opts.OperatorNamespace,
}
var deploy appsv1.Deployment
if err := o.client.Get(ctx, deployKey, &deploy); apierrors.IsNotFound(err) {
return fmt.Errorf("get rule-evaluator Deployment: %w", err)
}
if _, ok := deploy.Annotations[o.opts.CleanupAnnotKey]; !ok {
if err := o.client.Delete(ctx, &deploy); err != nil {
switch {
case apierrors.IsForbidden(err):
o.logger.Info("delete rule-evaluator was not allowed. Please remove it manually", "err", err)
case !apierrors.IsNotFound(err):
return fmt.Errorf("cleanup rule-evaluator failed: %w", err)
}
}
}

return nil
}

// namespacedNamePredicate is an event filter predicate that only allows events with
// a single object.
type namespacedNamePredicate struct {
Expand Down
164 changes: 0 additions & 164 deletions pkg/operator/operator_test.go

This file was deleted.

Loading