From d4c87c80ec9821faca033d4b9e3cb2869405b237 Mon Sep 17 00:00:00 2001 From: Luke Addison Date: Fri, 20 Dec 2024 19:03:39 +0000 Subject: [PATCH] Fix timeSinceToBeDeletedTaintAdded --- pkg/cloudprovider/gcp/cloud_provider.go | 2 +- pkg/cloudprovider/gcp/cloud_provider_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cloudprovider/gcp/cloud_provider.go b/pkg/cloudprovider/gcp/cloud_provider.go index 8fcca37..7f1c486 100644 --- a/pkg/cloudprovider/gcp/cloud_provider.go +++ b/pkg/cloudprovider/gcp/cloud_provider.go @@ -215,7 +215,7 @@ func timeSinceToBeDeletedTaintAdded(node *corev1.Node, now time.Time) time.Durat // Retrieve taint value toBeDeletedTaintAddedValue := "" for _, taint := range node.Spec.Taints { - if taint.Key == kubernetes.ToBeDeletedTaint && taint.Value == "ToBeDeletedByClusterAutoscaler" { + if taint.Key == kubernetes.ToBeDeletedTaint && taint.Effect == corev1.TaintEffectNoSchedule { toBeDeletedTaintAddedValue = taint.Value break } diff --git a/pkg/cloudprovider/gcp/cloud_provider_test.go b/pkg/cloudprovider/gcp/cloud_provider_test.go index ed676a3..4fc6f7f 100644 --- a/pkg/cloudprovider/gcp/cloud_provider_test.go +++ b/pkg/cloudprovider/gcp/cloud_provider_test.go @@ -106,8 +106,8 @@ func TestTimeSinceToBeDeletedTaintAdded(t *testing.T) { }, }, }, - now: time.Date(0, 0, 0, 0, 0, 60, 0, time.UTC), - timeSinceToBeDeletedTaintAdded: 60 * time.Second, + now: time.Date(0, 0, 0, 0, 1, 0, 0, time.UTC), + timeSinceToBeDeletedTaintAdded: time.Minute, }, "futureTaint": { node: &corev1.Node{ @@ -115,7 +115,7 @@ func TestTimeSinceToBeDeletedTaintAdded(t *testing.T) { Taints: []corev1.Taint{ { Key: "ToBeDeletedByClusterAutoscaler", - Value: fmt.Sprint(time.Date(0, 0, 0, 0, 0, 60, 0, time.UTC).Unix()), + Value: fmt.Sprint(time.Date(0, 0, 0, 0, 1, 0, 0, time.UTC).Unix()), Effect: corev1.TaintEffectNoSchedule, }, },