Skip to content

bug: PartitionSet endlessly recreates Partitions when a dimension is also in shardSelector.matchLabels #4549

Open

Description

@officialasishkumar

Describe the bug

When a PartitionSet uses a label both as a dimension and in spec.shardSelector.matchLabels, the PartitionSet controller never stops deleting and recreating the generated Partition.

partition() in pkg/reconciler/topology/partitionset/partitionset_reconcile.go builds its label list by appending the selector matchLabels keys to the dimensions without removing duplicates. For a label that appears in both, the computed key comes out as +region=eu+region=eu. The key computed for an existing Partition comes from its spec.selector.matchLabels map, so it can only be +region=eu. The two keys never match. Each reconcile therefore deletes the existing Partition and creates a new one with a new generated name. Each delete/create event re-enqueues the PartitionSet, so the loop never ends.

The unit test case Partitions created with selector and dimension overlapping covers only the first reconcile, when no Partition exists yet, so it doesn't catch this.

Steps To Reproduce

  1. Start kcp and, in root, create a shard labelled region: eu.
  2. Create:
    kind: PartitionSet
    apiVersion: topology.kcp.io/v1alpha1
    metadata:
      name: regions
    spec:
      dimensions:
      - region
      shardSelector:
        matchLabels:
          region: eu
  3. Run kubectl get partitions a few times. The partition name keeps changing (regions-eu-xxxxx). With -v=2, the kcp log fills with creating partition / deleting partition lines. In a local run, about 7,600 such lines were logged within 45 seconds.

Expected Behaviour

A single Partition (matchLabels: {region: eu}) is created and then left alone, just as when the label is only a dimension.

Additional Context

Deduplicating the label list in partition() makes both keys match again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions