Skip to content

Add base36/63-sha224 helper - #4159

Merged
kcp-ci-bot merged 5 commits into
kcp-dev:mainfrom
ntnn:base36-62-sha224
May 27, 2026
Merged

kcp-ci-bot merged 5 commits into
kcp-dev:mainfrom
ntnn:base36-62-sha224

Conversation

@ntnn

@ntnn ntnn commented May 27, 2026 •

Copy link
Copy Markdown
Member

Summary

This is adjacent to #3498.

TL;DR:

  1. Moving pkg/crypto to apimachinery/.../pkg/util/crypto
    Why? To have one kcpcrypto
    Why there? Because the helpers added are used in staging repos as well and this mirrors upstreams apimachinery pkg/util/<pkg>
  2. Adding baseX{,sha224} helpers to kcpcrypto
    Why?
    1. Because we have many different iterations of this across the codebase, some use a library, some math/big.Int
    2. Because for migration operators need a library function to do the same hashing/encoding of shard names we do
  3. Update all hashing/encoding places to use kcpcrypto
    Why? For consistency.

Prose:

Shards names are stored hashed on the Workspace in an annotation internal.tenancy.kcp.io/shard, presumably to not intentionally leak shard names to users.
For migrations we need to provide a library function for operators utilizing the migration primitive to check which shard an LC currently is in and which shard to migrate to.
We currently have many different places where base36, base36sha224 is implemented in different ways, sometimes using the base36 library, sometimes via math/big.Int.
Since these are all roughly the same shape I consolidated them into a tested package.
Most of the callsites are just ephemeral.

These are not:

  • pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling.go:163
    written to the internal.tenancy.kcp.io/shard annotation on Workspace objects
  • pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling.go:445
    used as the LogicalCluster name (ws.Spec.Cluster); a durable workspace identifier
  • pkg/index/rewriters/user.go:39
    HomeClusterName becomes the actual logical cluster name for the user's home workspace
  • staging/src/github.com/kcp-dev/sdk/apis/apis/v1alpha1/permissionclaims/labels.go and v1alpha2
    produces Kubernetes label keys/values written onto API resources

But all of these produce equivalent output so existing installations are unaffected, this is verified by the commit adding stable hashing/encoding unit tests. To show that the behaviour did not change this commit was PR'd separately here: #4158

What Type of PR Is This?

/kind chore

Related Issue(s)

Fixes #

Release Notes

New utility crypto package in apimachinery for base36/63 related encoding
Updated existing code paths to use new apimachinery crypto package for base36/63 encoding

@kcp-ci-bot kcp-ci-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/chore Categorizes issue or PR as related to maintenance and other usually non-code changes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 27, 2026
@ntnn
ntnn force-pushed the base36-62-sha224 branch from dc7a56a to 606bf57 Compare May 27, 2026 08:02
ntnn added 2 commits May 27, 2026 10:24
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
@ntnn
ntnn force-pushed the base36-62-sha224 branch 3 times, most recently from e409f67 to 3c35188 Compare May 27, 2026 08:41
ntnn added 3 commits May 27, 2026 10:46
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
@ntnn
ntnn force-pushed the base36-62-sha224 branch from 3c35188 to b8e62c4 Compare May 27, 2026 08:46

@mjudeikis mjudeikis 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.

/lgtm
/approve

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2026
@kcp-ci-bot

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 888405df1a4eee0ce707999449e4d5a10f75836a

@kcp-ci-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjudeikis

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 27, 2026
@ntnn ntnn assigned ntnn and unassigned mjudeikis May 27, 2026
@kcp-ci-bot kcp-ci-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels May 27, 2026
@ntnn

ntnn commented May 27, 2026

Copy link
Copy Markdown
Member Author

/retest

unrelated:

 === FAIL: test/e2e/reconciler/workspacedeletion TestWorkspaceDeletion/nested_workspace_cleanup_when_an_org_workspace_is_deleted (31.39s) 

@ntnn

ntnn commented May 27, 2026

Copy link
Copy Markdown
Member Author

/retest

@kcp-ci-bot
kcp-ci-bot merged commit 4de1389 into kcp-dev:main May 27, 2026
14 checks passed
@ntnn
ntnn deleted the base36-62-sha224 branch May 27, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/chore Categorizes issue or PR as related to maintenance and other usually non-code changes. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants