Skip to content

Pods are not restarted on update - label issue #724

@paepke

Description

@paepke

The crate operator does not find pods to restart as the app.kubernetes.io/managed-by label copied over from the cratedb resource is not overwritten.
We are using helm to deploy a cratedb definition to the cluster and as of Helm 3.2 (quite old) it adds automatically the app.kubernetes.io/managed-by label with the value Helm to it. This ends up in the StatefulSet which gets initially deployed. On an update of the cratedb version attribute the StatefulSet gets updated, but the operator cannot find the pods to restart as the value of the managed-by label is not set to crate-operator.
It looks like in the following snippet that label gets overwritten by the one from the cratedb resource.

base_labels = {
LABEL_MANAGED_BY: "crate-operator",
LABEL_NAME: name,
LABEL_PART_OF: "cratedb",
}
cratedb_labels = base_labels.copy()
cratedb_labels[LABEL_COMPONENT] = "cratedb"
cratedb_labels.update(meta.get("labels", {}))

Also the lookup of the pods are defined in the following snippet validates my assumption

async def get_pods_in_cluster(
core: CoreV1Api, namespace: str, name: str
) -> Tuple[Tuple[str], Tuple[str]]:
"""
Return a two-tuple with two tuples, the first containing all pod IDs, the
second the corresponding pod names within the cluster.
:param core: An instance of the Kubernetes Core V1 API.
:param namespace: The Kubernetes namespace where to look up the CrateDB
cluster.
:param name: The CrateDB custom resource name defining the CrateDB cluster.
"""
labels = {
LABEL_COMPONENT: "cratedb",
LABEL_MANAGED_BY: "crate-operator",
LABEL_NAME: name,
LABEL_PART_OF: "cratedb",
}
label_selector = ",".join(f"{k}={v}" for k, v in labels.items())

I'm guessing the sequence should be turned around that the StatefulSet managed-by label should have the correct value of crate-operator.

Steps to reproduce

  1. Create a cratedb resource with the label app.kubernetes.io/manged-by: foobar
  2. a statefulset with that label will be created by by the operator
  3. update the version of the cratedb created in step1
  4. StatefulSet gets updated, but the pods were not restarted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions