Skip to content

K8SPSMDB-1387 certmanager --enable-certificate-owner-ref option causes no startup of any mongodb clusters #1850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Demch1k
Copy link

@Demch1k Demch1k commented Feb 28, 2025

K8SPSMDB-1387 Powered by Pull Request Badge

CHANGE DESCRIPTION

https://perconadev.atlassian.net/browse/K8SPSMDB-1387


Problem:
We have enabled --enable-certificate-owner-ref for certmanager and after that mongodb operator can not startup any mongodb clusters.

Cause:
Mongodb operator return error when can't update owner references for certificates recources. But with --enable-certificate-owner-ref certmanager do it by itselfs.

Solution:
Catch error connected with already exists owner ref and jus print it out

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?

@CLAassistant
Copy link

CLAassistant commented Feb 28, 2025

CLA assistant check
All committers have signed the CLA.

@Demch1k Demch1k force-pushed the fix-certmanager-owner-ref branch from e219161 to 227c0fe Compare February 28, 2025 12:06
@gkech gkech added the community label Mar 4, 2025
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.

few comments.

also I wonder if we need to set this flag while deploying cert-manager in our tests

return "", errors.Wrap(err, "set controller reference")
switch errors.Cause(err).(type) {
case *controllerutil.AlreadyOwnedError:
fmt.Sprintf("%s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we return error here?

return errors.Wrap(err, "set controller reference")
switch errors.Cause(err).(type) {
case *controllerutil.AlreadyOwnedError:
fmt.Sprintf("%s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we return error here?

@@ -314,7 +320,12 @@ func (c *certManagerController) WaitForCerts(ctx context.Context, cr *api.Percon
continue
}
if err = controllerutil.SetControllerReference(cr, secret, c.scheme); err != nil {
return errors.Wrap(err, "set controller reference")
switch errors.Cause(err).(type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@gkech wdyt of this errors.Cause maybe we should check with errors.Is?

Copy link
Contributor

@gkech gkech Mar 10, 2025

Choose a reason for hiding this comment

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

yes it is better @egegunes

@Demch1k let's use errors.Is and also, let's drop switch since it is not needed, so the following for all cases.

if err = controllerutil.SetControllerReference(cr, secret, c.scheme); err != nil {
if errors.Is(err, &controllerutil.AlreadyOwnedError{}) {
	return errors.Wrap(err, "set owner reference")
}
return errors.Wrap(err, "set controller reference")
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@Demch1k any updates on this one?

@github-actions github-actions bot added the stale label Apr 10, 2025
@hors hors added this to the v1.21.0 milestone Apr 14, 2025
@hors hors removed the stale label Apr 14, 2025
@egegunes
Copy link
Contributor

seems like we will need to take this over, i'm moving this to next release

@egegunes egegunes modified the milestones: v1.21.0, v1.22.0 May 19, 2025
@gkech gkech changed the title Fix for certmanager owner ref K8SPSMDB-1387 certmanager --enable-certificate-owner-ref option causes no startup of any mongodb clusters May 19, 2025
@JNKPercona
Copy link
Collaborator

Test name Status
arbiter failure
balancer failure
cross-site-sharded failure
custom-replset-name failure
custom-tls failure
custom-users-roles failure
custom-users-roles-sharded failure
data-at-rest-encryption failure
data-sharded failure
demand-backup failure
demand-backup-eks-credentials-irsa skipped
demand-backup-fs skipped
demand-backup-incremental skipped
demand-backup-incremental-sharded skipped
demand-backup-physical-parallel skipped
demand-backup-physical-aws skipped
demand-backup-physical-azure skipped
demand-backup-physical-gcp skipped
demand-backup-physical-minio skipped
demand-backup-physical-sharded-parallel skipped
demand-backup-physical-sharded-aws skipped
demand-backup-physical-sharded-azure skipped
demand-backup-physical-sharded-gcp skipped
demand-backup-physical-sharded-minio skipped
demand-backup-sharded skipped
expose-sharded skipped
finalizer skipped
ignore-labels-annotations skipped
init-deploy skipped
ldap skipped
ldap-tls skipped
limits skipped
liveness skipped
mongod-major-upgrade skipped
mongod-major-upgrade-sharded skipped
monitoring-2-0 skipped
monitoring-pmm3 skipped
multi-cluster-service skipped
multi-storage skipped
non-voting-and-hidden skipped
one-pod skipped
operator-self-healing-chaos skipped
pitr skipped
pitr-physical skipped
pitr-sharded skipped
pitr-physical-backup-source skipped
preinit-updates skipped
pvc-resize skipped
recover-no-primary skipped
replset-overrides skipped
rs-shard-migration skipped
scaling skipped
scheduled-backup skipped
security-context skipped
self-healing-chaos skipped
service-per-pod skipped
serviceless-external-nodes skipped
smart-update skipped
split-horizon skipped
stable-resource-version skipped
storage skipped
tls-issue-cert-manager skipped
upgrade skipped
upgrade-consistency skipped
upgrade-consistency-sharded-tls skipped
upgrade-sharded skipped
users skipped
version-service skipped
We run 10 out of 68

commit: b17da06
image: perconalab/percona-server-mongodb-operator:PR-1850-b17da06c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants