Skip to content

Commit

Permalink
Merge pull request #81 from imjasonh/delete-syncer-ns
Browse files Browse the repository at this point in the history
Delete syncer-system namespace on cleanup
  • Loading branch information
imjasonh authored May 13, 2021
2 parents a63fad3 + 9eceb8a commit 55d3dea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (c *Controller) cleanup(ctx context.Context, deletedCluster *v1alpha1.Clust
return
}

uninstallSyncer(ctx, client, logicalCluster)
uninstallSyncer(ctx, client)
case SyncerModePush:
s, ok := c.syncers[deletedCluster.Name]
if !ok {
Expand Down
14 changes: 5 additions & 9 deletions pkg/reconciler/cluster/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func installSyncer(ctx context.Context, client kubernetes.Interface, syncerImage
args = append(args, resourcesToSync...)

var one int32 = 1
// Create or Update Pod
// Create or Update Deployment
deployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: syncerNS,
Expand Down Expand Up @@ -211,14 +211,10 @@ func installSyncer(ctx context.Context, client kubernetes.Interface, syncerImage
return nil
}

// uninstallSyncer uninstalls the syncer image from the target cluster.
func uninstallSyncer(ctx context.Context, client kubernetes.Interface, logicalCluster string) {
if err := client.CoreV1().ConfigMaps(syncerNS).Delete(ctx, syncerConfigMapName(logicalCluster), metav1.DeleteOptions{}); err != nil {
klog.Error(err)
}

if err := client.AppsV1().Deployments(syncerNS).Delete(ctx, syncerWorkloadName(logicalCluster), metav1.DeleteOptions{}); err != nil {
klog.Error(err)
// uninstallSyncer uninstalls the syncer from the target cluster by deleting the syncer namespace.
func uninstallSyncer(ctx context.Context, client kubernetes.Interface) {
if err := client.CoreV1().Namespaces().Delete(ctx, syncerNS, metav1.DeleteOptions{}); err != nil {
klog.Errorf("Deleting namespace %q: %v", syncerNS, err)
}
}

Expand Down

0 comments on commit 55d3dea

Please sign in to comment.