Skip to content

Commit 9db598c

Browse files
authored
Fix stuck tls migration (#2327)
* Fix stuck tls migration when pod spec is changed
1 parent 5578468 commit 9db598c

File tree

4 files changed

+61
-16
lines changed

4 files changed

+61
-16
lines changed

controllers/update_pods.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,24 @@ func getPodsToUpdate(
339339

340340
// The Pod is updated, so we can continue.
341341
if pod.ObjectMeta.Annotations[fdbv1beta2.LastSpecKey] == specHash {
342-
continue
342+
// Check here if the Pod spec matches the desired Pod spec.
343+
var updated bool
344+
updated, err = reconciler.PodLifecycleManager.PodIsUpdated(
345+
ctx,
346+
reconciler,
347+
cluster,
348+
pod,
349+
)
350+
if err != nil {
351+
logger.Info("Skipping Pod due to error generating spec hash",
352+
"processGroupID", processGroup.ProcessGroupID,
353+
"error", err.Error())
354+
continue
355+
}
356+
357+
if updated {
358+
continue
359+
}
343360
}
344361

345362
needsReplacement, err := replacements.ProcessGroupNeedsReplacements(

e2e/test_operator/operator_test.go

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -790,18 +790,49 @@ var _ = Describe("Operator", Label("e2e", "pr"), func() {
790790
checkCoordinatorsTLSFlag(fdbCluster.GetCluster(), initialTLSSetting)
791791
})
792792

793-
// Currently disabled until a new release of the operator is out
794-
It("should update the TLS setting and keep the cluster available", func() {
795-
// Only change the TLS setting for the cluster and not for the sidecar otherwise we have to recreate
796-
// all Pods which takes a long time since we recreate the Pods one by one.
797-
Expect(
798-
fdbCluster.SetTLS(
799-
!initialTLSSetting,
800-
fdbCluster.GetCluster().Spec.SidecarContainer.EnableTLS,
801-
),
802-
).NotTo(HaveOccurred())
803-
Expect(fdbCluster.HasTLSEnabled()).To(Equal(!initialTLSSetting))
804-
checkCoordinatorsTLSFlag(fdbCluster.GetCluster(), !initialTLSSetting)
793+
When("the pod spec stays the same", func() {
794+
It("should update the TLS setting and keep the cluster available", func() {
795+
// Only change the TLS setting for the cluster and not for the sidecar otherwise we have to recreate
796+
// all Pods which takes a long time since we recreate the Pods one by one.
797+
Expect(
798+
fdbCluster.SetTLS(
799+
!initialTLSSetting,
800+
fdbCluster.GetCluster().Spec.SidecarContainer.EnableTLS,
801+
),
802+
).NotTo(HaveOccurred())
803+
Expect(fdbCluster.HasTLSEnabled()).To(Equal(!initialTLSSetting))
804+
checkCoordinatorsTLSFlag(fdbCluster.GetCluster(), !initialTLSSetting)
805+
})
806+
})
807+
808+
PWhen("the pod spec is changed", func() {
809+
It("should update the TLS setting and keep the cluster available", func() {
810+
spec := fdbCluster.GetCluster().Spec.DeepCopy()
811+
spec.MainContainer.EnableTLS = !initialTLSSetting
812+
813+
// Add a new env variable to ensure this will cause some additional replacements.
814+
processSettings := spec.Processes[fdbv1beta2.ProcessClassGeneral]
815+
for i, container := range processSettings.PodTemplate.Spec.Containers {
816+
if container.Name != fdbv1beta2.MainContainerName {
817+
continue
818+
}
819+
820+
container.Env = append(container.Env, corev1.EnvVar{
821+
Name: "TESTING_TLS_CHANGE",
822+
Value: "EMPTY",
823+
})
824+
825+
processSettings.PodTemplate.Spec.Containers[i] = container
826+
break
827+
}
828+
829+
spec.Processes[fdbv1beta2.ProcessClassGeneral] = processSettings
830+
831+
fdbCluster.UpdateClusterSpecWithSpec(spec)
832+
Expect(fdbCluster.WaitForReconciliation()).To(Succeed())
833+
Expect(fdbCluster.HasTLSEnabled()).To(Equal(!initialTLSSetting))
834+
checkCoordinatorsTLSFlag(fdbCluster.GetCluster(), !initialTLSSetting)
835+
})
805836
})
806837
})
807838

internal/restarts/restarts.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func GetFilterConditions(
3636
// not get any ConfigMap updates.
3737
return map[fdbv1beta2.ProcessGroupConditionType]bool{
3838
fdbv1beta2.IncorrectCommandLine: true,
39-
fdbv1beta2.IncorrectPodSpec: false,
4039
fdbv1beta2.SidecarUnreachable: false,
4140
fdbv1beta2.IncorrectConfigMap: false,
4241
}

internal/restarts/restarts_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ var _ = Describe("restarts", func() {
4343
},
4444
map[fdbv1beta2.ProcessGroupConditionType]bool{
4545
fdbv1beta2.IncorrectCommandLine: true,
46-
fdbv1beta2.IncorrectPodSpec: false,
4746
fdbv1beta2.SidecarUnreachable: false,
4847
fdbv1beta2.IncorrectConfigMap: false,
4948
}),
@@ -55,7 +54,6 @@ var _ = Describe("restarts", func() {
5554
},
5655
map[fdbv1beta2.ProcessGroupConditionType]bool{
5756
fdbv1beta2.IncorrectCommandLine: true,
58-
fdbv1beta2.IncorrectPodSpec: false,
5957
fdbv1beta2.SidecarUnreachable: false,
6058
fdbv1beta2.IncorrectConfigMap: false,
6159
}),

0 commit comments

Comments
 (0)