Skip to content

[v3.32] Add calicoctl datastore migrate-policy-names command - #13288

Merged
nelljerram merged 2 commits into
projectcalico:release-v3.32from
nelljerram:auto-pick-of-#13257-origin-release-v3.32
Jul 23, 2026
Merged

[v3.32] Add calicoctl datastore migrate-policy-names command#13288
nelljerram merged 2 commits into
projectcalico:release-v3.32from
nelljerram:auto-pick-of-#13257-origin-release-v3.32

Conversation

@nelljerram

Copy link
Copy Markdown
Member

Cherry-pick history

Policies created before v3.32 on an etcdv3 datastore (for example OpenStack) keep their old tier-prefixed name in the datastore after an in-place upgrade. calicoctl can't fetch them by the name it displays, and the tier prefix leaks into Felix log prefixes. kube-controllers already fixes this on Kubernetes datastores, but etcdv3 deployments don't run kube-controllers.

This adds calicoctl datastore migrate-policy-names, which rewrites default-tier policy names in the datastore to match their v3 names. It's safe to re-run.

The create-then-delete migration logic is extracted into shared functions owned by the migration controller, so the controller and the CLI can't drift.

Related: CORE-13170

Adds a calicoctl datastore migrate-policy-names command to fix pre-v3.32 policy names on an etcdv3 datastore that was upgraded in place.

…3257)

The migration controller and calicoctl share the predicate and the
per-policy create-then-delete operation.

Rewrites default-tier policy datastore names to match their v3 names, for
etcdv3 deployments that don't run kube-controllers.

(cherry picked from commit a5d862f)
@nelljerram
nelljerram requested a review from a team as a code owner July 22, 2026 16:20
Copilot AI review requested due to automatic review settings July 22, 2026 16:20
@nelljerram nelljerram added release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Jul 22, 2026
@marvin-tigera marvin-tigera added this to the Calico v3.32.2 milestone Jul 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR backports the addition of a calicoctl datastore migrate-policy-names command onto release-v3.32, to rewrite legacy default-tier policy keys in an etcdv3 datastore so their stored names match the v3 resource names introduced in v3.32. It also factors the underlying create-then-delete migration logic into shared functions used by both kube-controllers and calicoctl.

Changes:

  • Add shared migration helpers (NeedsMigration, MigratePolicyKVP, PolicyKinds) in kube-controllers’ networkpolicy controller package.
  • Add calicoctl datastore migrate-policy-names command + unit tests, reusing the shared migration helpers.
  • Update calicoctl command dispatch and adjust Semaphore change-detection inputs for the calicoctl block.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
kube-controllers/pkg/controllers/networkpolicy/policymigrate.go New shared policy-name migration primitives used by both controller and CLI.
kube-controllers/pkg/controllers/networkpolicy/policy_name_migrator.go Switch controller to use the extracted shared migration helpers + shared backend accessor interface.
calicoctl/calicoctl/commands/datastore/migrate/policyname.go New CLI command implementation for migrating legacy policy datastore names.
calicoctl/calicoctl/commands/datastore/migrate/policyname_test.go Unit tests validating idempotent migration behavior over a fake backend.
calicoctl/calicoctl/commands/datastore.go Wire the new migrate-policy-names subcommand into calicoctl datastore.
.semaphore/semaphore.yml Update calicoctl block change-detection to include the new dependency surface.

Comment thread calicoctl/calicoctl/commands/datastore/migrate/policyname.go
Comment thread calicoctl/calicoctl/commands/datastore/migrate/policyname.go
Comment on lines +86 to +90
logrus.WithFields(logrus.Fields{
"kind": k.Kind,
"oldName": k.Name,
"newName": newKey.Name,
}).Info("Migrated policy datastore name")
Comment thread calicoctl/calicoctl/commands/datastore/migrate/policyname.go
@nelljerram

Copy link
Copy Markdown
Member Author

Docs at tigera/docs#2851

@nelljerram
nelljerram force-pushed the auto-pick-of-#13257-origin-release-v3.32 branch from da67e09 to cb859b7 Compare July 22, 2026 23:10
@nelljerram
nelljerram merged commit 5c3e88f into projectcalico:release-v3.32 Jul 23, 2026
3 checks passed
@nelljerram
nelljerram deleted the auto-pick-of-#13257-origin-release-v3.32 branch July 23, 2026 09:26
@danudey danudey added kind/bug and removed kind/bug labels Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-pr-required Change is not yet documented release-note-required Change has user-facing impact (no matter how small)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants