From 403cc63ddd0cb06a3829b741e333ff941dc61dd6 Mon Sep 17 00:00:00 2001 From: Phil Kates Date: Sun, 18 Sep 2022 10:09:16 -0400 Subject: [PATCH] Fix GracePeriodSeconds (#1739) `var x int64` means the value is 0 rather than the intended nil (default). `Delete` doesn't provide a way to configure the grace period anyway so remove the variable and only override on a `force` Co-authored-by: Phil Kates --- internal/dao/generic.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/dao/generic.go b/internal/dao/generic.go index d287df57..7e8afc8c 100644 --- a/internal/dao/generic.go +++ b/internal/dao/generic.go @@ -98,14 +98,13 @@ func (g *Generic) Delete(ctx context.Context, path string, propagation *metav1.D return fmt.Errorf("user is not authorized to delete %s", path) } - const defaultKillGrace = 1 - var grace int64 - if force { - grace = defaultKillGrace - } opts := metav1.DeleteOptions{ - PropagationPolicy: propagation, - GracePeriodSeconds: &grace, + PropagationPolicy: propagation, + } + + if force { + var defaultKillGrace int64 = 1 + opts.GracePeriodSeconds = &defaultKillGrace } dial, err := g.dynClient()