Skip to content

Commit

Permalink
Fix ScyllaDB version upgrade being stuck on Pod staying in maintenanc…
Browse files Browse the repository at this point in the history
…e mode

Service controller copied maintenance mode label into required object
from cached informer when it was present.
Labels are also rewritten from existing objects in all Apply methods.
If maitenance mode label was removed in between when required object is
constructed, and Apply method is called, it would make it persitently
available in the Service object.
Instead adding it to required object, it should be carried over from
existing object only in Apply method, because this label is managed by
patches.

Fixes #1252
  • Loading branch information
zimnx committed Jun 9, 2023
1 parent 3355662 commit 1c05996
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
6 changes: 0 additions & 6 deletions pkg/controller/scyllacluster/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ func MemberService(sc *scyllav1.ScyllaCluster, rackName, name string, oldService
if hasReplaceLabel {
labels[naming.ReplaceLabel] = replaceAddr
}

// Copy the maintenance label, if present
oldMaintenanceLabel, oldMaintenanceLabelPresent := oldService.Labels[naming.NodeMaintenanceLabel]
if oldMaintenanceLabelPresent {
labels[naming.NodeMaintenanceLabel] = oldMaintenanceLabel
}
}

// Only new service should get the replace address, old service keeps "" until deleted.
Expand Down
26 changes: 26 additions & 0 deletions pkg/controller/scyllacluster/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,32 @@ func TestMemberService(t *testing.T) {
},
},
},
{
name: "existing service with maintenance mode label, it is not carried over into required object - #1252",
scyllaCluster: basicSC,
rackName: basicRackName,
svcName: basicSVCName,
oldService: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
naming.NodeMaintenanceLabel: "42",
},
},
},
expectedService: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: basicSVCName,
Labels: basicSVCLabels(),
OwnerReferences: basicSCOwnerRefs,
},
Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
Selector: basicSVCSelector,
PublishNotReadyAddresses: true,
Ports: basicPorts,
},
},
},
}

for _, tc := range tt {
Expand Down

0 comments on commit 1c05996

Please sign in to comment.