Skip to content

Commit b53cebe

Browse files
committed
[fix] dont delete deployment
Signed-off-by: Stepan Paksashvili <[email protected]>
1 parent 78edf19 commit b53cebe

File tree

1 file changed

+3
-20
lines changed
  • common-hooks/storage-class-change

1 file changed

+3
-20
lines changed

common-hooks/storage-class-change/hook.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func storageClassChange(ctx context.Context, input *pkg.HookInput, args Args) er
194194
},
195195
}
196196

197-
input.Logger.Info("evict pod due",
197+
input.Logger.Info("evict pod",
198198
slog.String("namespace", pod.Namespace),
199199
slog.String("pod", pod.Name),
200200
slog.String("pvc", pvc.Name))
@@ -232,7 +232,7 @@ func storageClassChange(ctx context.Context, input *pkg.HookInput, args Args) er
232232
}
233233
}
234234

235-
input.Logger.Info("storageClass changed. Deleting objects",
235+
input.Logger.Info("storageClass changed, delete objects",
236236
slog.String("namespace", args.Namespace),
237237
slog.String("object_kind", args.ObjectKind),
238238
slog.String("name", args.ObjectName))
@@ -251,13 +251,7 @@ func storageClassChange(ctx context.Context, input *pkg.HookInput, args Args) er
251251
}
252252
err = kubeClient.Delete(ctx, obj)
253253
case "Deployment":
254-
obj := &appsv1.Deployment{
255-
ObjectMeta: metav1.ObjectMeta{
256-
Name: args.ObjectName,
257-
Namespace: args.Namespace,
258-
},
259-
}
260-
err = kubeClient.Delete(ctx, obj)
254+
return nil
261255
default:
262256
return fmt.Errorf("unknown object kind %s", args.ObjectKind)
263257
}
@@ -315,23 +309,12 @@ func calculateEffectiveStorageClass(input *pkg.HookInput, args Args, currentStor
315309
internalValuesPath = fmt.Sprintf("%s.internal.%s.effectiveStorageClass", strcase.ToLowerCamel(args.ModuleName), args.InternalValuesSubPath)
316310
}
317311

318-
emptydirUsageMetricValue := 0.0
319312
if len(effectiveStorageClass) == 0 || effectiveStorageClass == "false" {
320313
input.Values.Set(internalValuesPath, false)
321-
emptydirUsageMetricValue = 1.0
322314
} else {
323315
input.Values.Set(internalValuesPath, effectiveStorageClass)
324316
}
325317

326-
input.MetricsCollector.Set(
327-
"d8_emptydir_usage",
328-
emptydirUsageMetricValue,
329-
map[string]string{
330-
"namespace": args.Namespace,
331-
"module_name": args.ModuleName,
332-
},
333-
)
334-
335318
return effectiveStorageClass, nil
336319
}
337320

0 commit comments

Comments
 (0)