From 66897cb9d0f4d0b8572d3966506448df24e054c3 Mon Sep 17 00:00:00 2001 From: Shubham Bansal <62992590+shubham-bansal96@users.noreply.github.com> Date: Sat, 12 Nov 2022 09:11:05 +0530 Subject: [PATCH] Delete builder service associated with environment name (#2616) --- pkg/buildermgr/envwatcher.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/buildermgr/envwatcher.go b/pkg/buildermgr/envwatcher.go index 597d9945..bba2ed90 100644 --- a/pkg/buildermgr/envwatcher.go +++ b/pkg/buildermgr/envwatcher.go @@ -113,9 +113,10 @@ func makeEnvironmentWatcher( return envWatcher } -func (env *environmentWatcher) getLabelForDeploymentOwner() map[string]string { +func (env *environmentWatcher) getDeploymentLabels(envName string) map[string]string { return map[string]string{ LABEL_DEPLOYMENT_OWNER: BUILDER_MGR, + LABEL_ENV_NAME: envName, } } @@ -202,7 +203,7 @@ func (envw *environmentWatcher) getNamespace(env *fv1.Environment) string { func (envw *environmentWatcher) DeleteBuilderService(ctx context.Context, env *fv1.Environment) { ns := envw.getNamespace(env) - svcList, err := envw.getBuilderServiceList(ctx, envw.getLabelForDeploymentOwner(), ns) + svcList, err := envw.getBuilderServiceList(ctx, envw.getDeploymentLabels(env.ObjectMeta.Name), ns) if err != nil { envw.logger.Error("error getting the builder service list", zap.Error(err)) } @@ -227,7 +228,7 @@ func (envw *environmentWatcher) DeleteBuilderService(ctx context.Context, env *f func (envw *environmentWatcher) DeleteBuilderDeployment(ctx context.Context, env *fv1.Environment) { ns := envw.getNamespace(env) - deployList, err := envw.getBuilderDeploymentList(ctx, envw.getLabelForDeploymentOwner(), ns) + deployList, err := envw.getBuilderDeploymentList(ctx, envw.getDeploymentLabels(env.ObjectMeta.Name), ns) if err != nil { envw.logger.Error("error getting the builder deployment list", zap.Error(err)) }