Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
EVEREST-203 Better deletion handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gen1us2k committed Sep 25, 2023
1 parent 81b1053 commit b9849ce
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/install/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ import (
"net/url"
"time"

k8serrors "k8s.io/apimachinery/pkg/api/errors"

"github.com/AlecAivazis/survey/v2"
"github.com/operator-framework/api/pkg/operators/v1alpha1"
"github.com/percona/percona-everest-backend/client"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"

"github.com/percona/percona-everest-cli/commands/common"
Expand Down Expand Up @@ -786,6 +789,14 @@ func (o *Operators) connectToEverest(ctx context.Context) (*client.KubernetesClu
}
for _, cluster := range clusters {
if cluster.Name == o.config.Name {
ns, err := o.kubeClient.GetNamespace(ctx, cluster.Namespace)
if err != nil && !k8serrors.IsNotFound(err) {
return nil, errors.Join(err, errors.New("could not get namespace from Kubernetes"))
}

if ns.UID != types.UID(cluster.Uid) {
return nil, errors.New("namespace UID mismatch. It looks like you're trying to register a new kubernetes cluster using the existing name. Please unregister the existing kubernetes cluster first")
}
// Cluster is already registered. Do nothing
return &cluster, nil
}
Expand Down

0 comments on commit b9849ce

Please sign in to comment.