Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ko-364 fix managed by #84

Merged
merged 15 commits into from
May 20, 2020
Merged

ko-364 fix managed by #84

merged 15 commits into from
May 20, 2020

Conversation

johntrimble
Copy link
Collaborator

No description provided.

var service corev1.Service
service.ObjectMeta.Namespace = dc.Namespace
service.ObjectMeta.Labels = labels
service.Spec.Selector = labels
service.Spec.Selector = selector
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were including the managed-by label in the selector which is both not necessary and unhelpful for when we update the managed-by value to cass-operator (it will cause the services to, temporarily, not have any pods associated with them).

// label of "cassandra-operator" we have since fixed this to be "cass-operator",
// but unfortunately, we cannot modify the labels in the volumeClaimTemplates of a
// StatefulSet. Consequently, we must preserve the old labels in this case.
usesDefunct := usesDefunctPvcManagedByLabel(sts)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. It's dumb.

if shouldUpdateLabels {
logger.Info("Updating labels",
// if we found the service already, check if they need updating
if !resourcesHaveSameHash(currentService, desiredSvc) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out this change isn't necessary because we removed managed-by from the selector of our services. However, it's still a good idea so here it is.

@@ -0,0 +1,4 @@
apiVersion: v2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need access to the 1.1.0 helm chart somehow. It was easiest to just include it in the testdata. Open to suggestions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could get it with git, but this is fine with me

@johntrimble johntrimble marked this pull request as ready for review May 15, 2020 23:32
@@ -1,7 +1,7 @@
// Copyright DataStax, Inc.
// Please see the included license file for details.

package config_change
package config_change_condition
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

fmt.Sprintf("--namespace=%s", namespace),
}

func buildOverrideArgs(overrides map[string]string) []string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

ManagedByLabelValue = "cassandra-operator"
ManagedByLabel = "app.kubernetes.io/managed-by"
ManagedByLabelValue = "cass-operator"
ManagedByLabelDefunctValue = "cassandra-operator"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣 👍

@@ -104,18 +114,52 @@ func newNamespacedNameForStatefulSet(
}
}

// Create a statefulset object for the Datacenter.
func newStatefulSetForCassandraDatacenterWithDefunctPvcManagedBy(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a comment for why this is here - your other comment is really great - just edited the intro...

// We have to account for the fact that they might use the old managed-by label value
// (oplabels.ManagedByLabelDefunctValue) for CassandraDatacenters originally
// created in version 1.1.0 or earlier.

@@ -211,7 +212,7 @@ func TestCassandraDatacenter_buildPodTemplateSpec_labels_merge(t *testing.T) {

expected := dc.GetRackLabels("testrack")
expected[api.CassNodeState] = stateReadyToStart
expected["app.kubernetes.io/managed-by"] = "cassandra-operator"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel so much shame right now, but this is how name changes go - one leak and the costs add up later

shouldUpdateLabels := !reflect.DeepEqual(currentLabels, desiredLabels)
if shouldUpdateLabels {
logger.Info("Updating labels",
// if we found the service already, check if they need updating
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting the services updating in a proper/idiomatic-for-us way was a great side benefit of this work, great job!

Copy link
Collaborator

@jimdickinson jimdickinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@johntrimble johntrimble merged commit 39519b8 into master May 20, 2020
@johntrimble johntrimble deleted the ko-364-fix-managed-by branch May 20, 2020 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants