From 45d85e692cd0a5ffee488223ce7a25986865898e Mon Sep 17 00:00:00 2001 From: brokenpip3 Date: Mon, 3 Jun 2024 17:50:19 +0200 Subject: [PATCH] fix tests --- api/v1alpha2/zz_generated.deepcopy.go | 5 +++++ pkg/configuration/base/resources/pod.go | 5 +++++ pkg/constants/constants.go | 1 + test/e2e/configuration_test.go | 5 +++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/api/v1alpha2/zz_generated.deepcopy.go b/api/v1alpha2/zz_generated.deepcopy.go index 6caa129b7..ef06493c8 100644 --- a/api/v1alpha2/zz_generated.deepcopy.go +++ b/api/v1alpha2/zz_generated.deepcopy.go @@ -368,6 +368,11 @@ func (in *JenkinsMaster) DeepCopyInto(out *JenkinsMaster) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.TerminationGracePeriodSeconds != nil { + in, out := &in.TerminationGracePeriodSeconds, &out.TerminationGracePeriodSeconds + *out = new(int64) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JenkinsMaster. diff --git a/pkg/configuration/base/resources/pod.go b/pkg/configuration/base/resources/pod.go index 1cfeec86b..783ccaa2b 100644 --- a/pkg/configuration/base/resources/pod.go +++ b/pkg/configuration/base/resources/pod.go @@ -369,6 +369,11 @@ func NewJenkinsMasterPod(objectMeta metav1.ObjectMeta, jenkins *v1alpha2.Jenkins objectMeta.Name = GetJenkinsMasterPodName(jenkins) objectMeta.Labels = GetJenkinsMasterPodLabels(*jenkins) + if jenkins.Spec.Master.TerminationGracePeriodSeconds == nil { + defaultGracePeriod := constants.DefaultTerminationGracePeriodSeconds + jenkins.Spec.Master.TerminationGracePeriodSeconds = &defaultGracePeriod + } + return &corev1.Pod{ TypeMeta: buildPodTypeMeta(), ObjectMeta: objectMeta, diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 9f7848541..7e26f4115 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -15,5 +15,6 @@ const ( DefaultSlavePortInt32 = int32(50000) // JavaOpsVariableName is the name of environment variable which consists Jenkins Java options JavaOpsVariableName = "JAVA_OPTS" + // DefaultTerminationGracePeriodSeconds is the default pod termination period second DefaultTerminationGracePeriodSeconds = int64(30) ) diff --git a/test/e2e/configuration_test.go b/test/e2e/configuration_test.go index dfd4f28a4..4bef64e04 100644 --- a/test/e2e/configuration_test.go +++ b/test/e2e/configuration_test.go @@ -111,6 +111,8 @@ func verifyJenkinsMasterPodAttributes(jenkins *v1alpha2.Jenkins) { jenkinsPod := getJenkinsMasterPod(jenkins) jenkins = getJenkins(jenkins.Namespace, jenkins.Name) + defaultGracePeriod := constants.DefaultTerminationGracePeriodSeconds + assertMapContainsElementsFromAnotherMap(jenkins.Spec.Master.Annotations, jenkinsPod.ObjectMeta.Annotations) Expect(jenkinsPod.Spec.NodeSelector).Should(Equal(jenkins.Spec.Master.NodeSelector)) @@ -125,8 +127,7 @@ func verifyJenkinsMasterPodAttributes(jenkins *v1alpha2.Jenkins) { Expect(jenkinsPod.Labels).Should(Equal(resources.GetJenkinsMasterPodLabels(*jenkins))) Expect(jenkinsPod.Spec.PriorityClassName).Should(Equal(jenkins.Spec.Master.PriorityClassName)) - - Expect(jenkinsPod.Spec.TerminationGracePeriodSeconds).Should(Equal(jenkins.Spec.Master.TerminationGracePeriodSeconds)) + Expect(jenkinsPod.Spec.TerminationGracePeriodSeconds).Should(Equal(&defaultGracePeriod)) for _, actualContainer := range jenkinsPod.Spec.Containers { if actualContainer.Name == resources.JenkinsMasterContainerName {