Skip to content

K8SPSMDB-1593: Refactor user annotation key generation#2232

Open
ravisingal wants to merge 10 commits intopercona:mainfrom
ravisingal:secret-annotation-key-length
Open

K8SPSMDB-1593: Refactor user annotation key generation#2232
ravisingal wants to merge 10 commits intopercona:mainfrom
ravisingal:secret-annotation-key-length

Conversation

@ravisingal
Copy link

Refactor annotation key generation to ensure it adheres to Kubernetes naming constraints by limiting the prefix length.

CHANGE DESCRIPTION

Problem:
Short explanation of the problem.

Cause:
Short explanation of the root cause of the issue if applicable.

Solution:
Short explanation of the solution we are providing with this PR.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported MongoDB version?
  • Does the change support oldest and newest supported Kubernetes version?

Refactor annotation key generation to ensure it adheres to Kubernetes naming constraints by limiting the prefix length.
@CLAassistant
Copy link

CLAassistant commented Feb 11, 2026

CLA assistant check
All committers have signed the CLA.

@egegunes egegunes added this to the v1.23.0 milestone Feb 11, 2026
Copy link
Contributor

@egegunes egegunes left a comment

Choose a reason for hiding this comment

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

@ravisingal it'd be great to have some unit tests for this

@pull-request-size pull-request-size bot added size/L 100-499 lines and removed size/S 10-29 lines labels Feb 17, 2026
@ravisingal
Copy link
Author

@ravisingal it'd be great to have some unit tests for this

added unit tests

func buildAnnotationKey(crName, userName string) string {
annotationKeyBase := fmt.Sprintf("percona.com/%s-%s", crName, userName)
const hashSuffix = "-hash"
const maxAnnotationNameLength = 63
Copy link
Contributor

@egegunes egegunes Feb 18, 2026

Choose a reason for hiding this comment

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

i think we need to move this to outside of function and use it in unit tests instead of passing the same value separately in both places

Copy link
Author

Choose a reason for hiding this comment

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

done.

@egegunes egegunes changed the title Refactor user annotation key generation K8SPSMDB-1593: Refactor user annotation key generation Feb 19, 2026
egegunes
egegunes previously approved these changes Feb 23, 2026
Comment on lines +481 to +483
if !strings.HasPrefix(got, prefix) {
t.Errorf("buildAnnotationKey() = %v, should start with %v", got, prefix)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using these conditions, we can use assert and require from testify as we do in other tests in this repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

the same of some other cases in the same test

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ravisingal could you please check these comments

Copy link
Author

Choose a reason for hiding this comment

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

updated tests.

mayankshah1607
mayankshah1607 previously approved these changes Mar 6, 2026
Copy link
Collaborator

@hors hors left a comment

Choose a reason for hiding this comment

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

@ravisingal please sign cla

@ravisingal ravisingal dismissed stale reviews from egegunes and mayankshah1607 via e81adde March 11, 2026 14:38
@ravisingal
Copy link
Author

@ravisingal please sign cla

done.

@JNKPercona
Copy link
Collaborator

Test Name Result Time
arbiter passed 00:11:47
balancer failure 00:01:39
cross-site-sharded passed 00:22:06
custom-replset-name passed 00:10:54
custom-tls passed 00:14:43
custom-users-roles failure 00:09:05
custom-users-roles-sharded passed 00:11:56
data-at-rest-encryption passed 00:13:32
data-sharded failure 00:29:43
demand-backup passed 00:18:46
demand-backup-eks-credentials-irsa passed 00:00:08
demand-backup-fs passed 00:25:45
demand-backup-if-unhealthy failure 00:53:47
demand-backup-incremental-aws passed 00:15:54
demand-backup-incremental-azure passed 00:11:54
demand-backup-incremental-gcp-native passed 00:12:07
demand-backup-incremental-gcp-s3 failure 00:55:16
demand-backup-incremental-minio passed 00:27:15
demand-backup-incremental-sharded-aws failure 00:12:36
demand-backup-incremental-sharded-azure passed 00:21:58
demand-backup-incremental-sharded-gcp-native passed 00:18:32
demand-backup-incremental-sharded-gcp-s3 failure 01:03:12
demand-backup-incremental-sharded-minio passed 00:28:33
demand-backup-logical-minio-native-tls passed 00:08:39
demand-backup-physical-parallel passed 00:08:49
demand-backup-physical-aws passed 00:12:16
demand-backup-physical-azure passed 00:12:48
demand-backup-physical-gcp-s3 passed 00:12:54
demand-backup-physical-gcp-native passed 00:12:12
demand-backup-physical-minio passed 00:21:45
demand-backup-physical-minio-native passed 00:28:33
demand-backup-physical-minio-native-tls passed 00:20:02
demand-backup-physical-sharded-parallel failure 01:30:09
demand-backup-physical-sharded-aws failure 00:21:23
demand-backup-physical-sharded-azure passed 00:18:21
demand-backup-physical-sharded-gcp-native passed 00:18:10
demand-backup-physical-sharded-minio passed 00:17:29
demand-backup-physical-sharded-minio-native passed 00:20:30
demand-backup-sharded passed 00:28:59
demand-backup-snapshot passed 00:38:53
demand-backup-snapshot-vault failure 00:03:28
disabled-auth passed 00:17:24
expose-sharded failure 00:15:50
finalizer passed 00:10:25
ignore-labels-annotations passed 00:08:20
init-deploy passed 00:14:12
ldap passed 00:09:34
ldap-tls passed 00:12:51
limits passed 00:06:45
liveness passed 00:09:08
mongod-major-upgrade passed 00:13:34
mongod-major-upgrade-sharded passed 00:23:50
monitoring-2-0 passed 00:26:32
monitoring-pmm3 failure 00:09:11
multi-cluster-service failure 00:14:30
multi-storage passed 00:19:15
non-voting-and-hidden passed 00:20:05
one-pod passed 00:07:38
operator-self-healing-chaos passed 00:12:49
pitr passed 00:33:26
pitr-physical failure 00:15:47
pitr-sharded failure 00:04:49
pitr-to-new-cluster passed 00:26:44
pitr-physical-backup-source failure 00:57:06
preinit-updates passed 00:05:11
pvc-auto-resize passed 00:13:06
pvc-resize failure 00:17:47
recover-no-primary passed 00:27:37
replset-overrides passed 00:20:02
replset-remapping passed 00:19:12
replset-remapping-sharded passed 00:18:10
rs-shard-migration failure 00:06:01
scaling passed 00:11:28
scheduled-backup passed 00:18:30
security-context passed 00:08:40
self-healing-chaos passed 00:15:28
service-per-pod passed 00:22:51
serviceless-external-nodes passed 00:08:12
smart-update passed 00:08:44
split-horizon passed 00:14:30
stable-resource-version passed 00:04:47
storage passed 00:07:57
tls-issue-cert-manager passed 00:31:05
unsafe-psa passed 00:08:14
upgrade passed 00:10:07
upgrade-consistency passed 00:08:26
upgrade-consistency-sharded-tls failure 00:05:58
upgrade-sharded passed 00:20:39
upgrade-partial-backup passed 00:18:48
users failure 00:06:01
users-vault passed 00:14:02
version-service passed 00:25:29
Summary Value
Tests Run 92/92
Job Duration 04:12:57
Total Test Time 27:54:01

commit: bb80a94
image: perconalab/percona-server-mongodb-operator:PR-2232-bb80a94f

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

Labels

community size/L 100-499 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants