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

Commit

Permalink
EVEREST-838 delete OLM namespace during uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
recharte committed Feb 13, 2024
1 parent 382fe7b commit c7e7dc2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
6 changes: 2 additions & 4 deletions pkg/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ const (
pgOperatorChannel = "stable-v2"
vmOperatorChannel = "stable-v0"

// catalogSourceNamespace is the namespace where the catalog source is installed.
catalogSourceNamespace = "everest-olm"
// catalogSource is the name of the catalog source.
catalogSource = "everest-catalog"

Expand Down Expand Up @@ -202,7 +200,7 @@ func (o *Install) installVMOperator(ctx context.Context) error {
Name: vmOperatorName,
OperatorGroup: monitoringOperatorGroup,
CatalogSource: catalogSource,
CatalogSourceNamespace: catalogSourceNamespace,
CatalogSourceNamespace: kubernetes.OLMNamespace,
Channel: vmOperatorChannel,
InstallPlanApproval: v1alpha1.ApprovalManual,
}
Expand Down Expand Up @@ -484,7 +482,7 @@ func (o *Install) installOperator(ctx context.Context, channel, operatorName, na
Name: operatorName,
OperatorGroup: systemOperatorGroup,
CatalogSource: catalogSource,
CatalogSourceNamespace: catalogSourceNamespace,
CatalogSourceNamespace: kubernetes.OLMNamespace,
Channel: channel,
InstallPlanApproval: v1alpha1.ApprovalManual,
SubscriptionConfig: &v1alpha1.SubscriptionConfig{
Expand Down
11 changes: 6 additions & 5 deletions pkg/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ const (
// then either ran to completion or failed for some reason.
ContainerStateTerminated ContainerState = "terminated"

olmNamespace = "everest-olm"
// OLMNamespace is the namespace where OLM is installed.
OLMNamespace = "everest-olm"
olmOperatorName = "olm-operator"

// APIVersionCoreosV1 constant for some API requests.
Expand Down Expand Up @@ -396,7 +397,7 @@ func (k *Kubernetes) GetStorageClasses(ctx context.Context) (*storagev1.StorageC

// InstallOLMOperator installs the OLM in the Kubernetes cluster.
func (k *Kubernetes) InstallOLMOperator(ctx context.Context, upgrade bool) error {
deployment, err := k.client.GetDeployment(ctx, olmOperatorName, olmNamespace)
deployment, err := k.client.GetDeployment(ctx, olmOperatorName, OLMNamespace)
if err == nil && deployment != nil && deployment.ObjectMeta.Name != "" && !upgrade {
k.l.Info("OLM operator is already installed")
return nil // already installed
Expand All @@ -415,7 +416,7 @@ func (k *Kubernetes) InstallOLMOperator(ctx context.Context, upgrade bool) error
return err
}

if err := k.client.DoRolloutWait(ctx, types.NamespacedName{Namespace: olmNamespace, Name: "packageserver"}); err != nil {
if err := k.client.DoRolloutWait(ctx, types.NamespacedName{Namespace: OLMNamespace, Name: "packageserver"}); err != nil {
return errors.Join(err, errors.New("error while waiting for deployment rollout"))
}

Expand Down Expand Up @@ -518,12 +519,12 @@ func (k *Kubernetes) applyResources(ctx context.Context) ([]unstructured.Unstruc

func (k *Kubernetes) waitForDeploymentRollout(ctx context.Context) error {
if err := k.client.DoRolloutWait(ctx, types.NamespacedName{
Namespace: olmNamespace,
Namespace: OLMNamespace,
Name: olmOperatorName,
}); err != nil {
return errors.Join(err, errors.New("error while waiting for deployment rollout"))
}
if err := k.client.DoRolloutWait(ctx, types.NamespacedName{Namespace: olmNamespace, Name: "catalog-operator"}); err != nil {
if err := k.client.DoRolloutWait(ctx, types.NamespacedName{Namespace: OLMNamespace, Name: "catalog-operator"}); err != nil {
return errors.Join(err, errors.New("error while waiting for deployment rollout"))
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/uninstall/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package uninstall

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -130,6 +129,12 @@ This will uninstall Everest and all its components from the cluster.`
return err
}

// There are no resources with finalizers in the monitoring namespace, so
// we can delete it directly
if err := u.deleteNamespaces(ctx, []string{kubernetes.OLMNamespace}); err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit c7e7dc2

Please sign in to comment.