Skip to content
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

K8SPSMDB-1256 refactor backup agent (pbm) mongo uri construction #1835

Merged
merged 19 commits into from
Feb 25, 2025

Conversation

gkech
Copy link
Contributor

@gkech gkech commented Feb 18, 2025

K8SPSMDB-1256 Powered by Pull Request Badge

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.

tested image: export IMAGE=perconalab/percona-server-mongodb-operator:K8SPSMDB-1256-9911

Screenshot 2025-02-20 at 7 41 47 PM

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?

@pull-request-size pull-request-size bot added the size/XS 0-9 lines label Feb 18, 2025
@gkech gkech changed the title K8SPSMDB-1256 pbm-entry.sh manages symlinks properly K8SPSMDB-1256 pbm-entry.sh manages symlink files properly Feb 18, 2025
@pull-request-size pull-request-size bot added size/M 30-99 lines and removed size/XS 0-9 lines labels Feb 19, 2025
@gkech gkech changed the title K8SPSMDB-1256 pbm-entry.sh manages symlink files properly K8SPSMDB-1256 refactor pbm mongo uri construction Feb 19, 2025
@gkech gkech changed the title K8SPSMDB-1256 refactor pbm mongo uri construction K8SPSMDB-1256 refactor backup agent (pbm) mongo uri construction Feb 19, 2025
@gkech gkech marked this pull request as ready for review February 20, 2025 08:58
@pull-request-size pull-request-size bot added size/L 100-499 lines and removed size/M 30-99 lines labels Feb 24, 2025
@@ -419,7 +425,7 @@ func backupAgentContainer(cr *api.PerconaServerMongoDB, replsetName string, port
},
{
Name: "PBM_MONGODB_URI",
Value: "mongodb://$(PBM_AGENT_MONGODB_USERNAME):$(PBM_AGENT_MONGODB_PASSWORD)@$(POD_NAME)",
Value: buildMongoDBURI(ctx, tlsEnabled, sslSecret),
Copy link
Collaborator

Choose a reason for hiding this comment

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

@gkech, we need to use the new value only in case of
if cr.CompareVersion("1.20.0") >= 0 {

please check the code how we use it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do, thanks Slava

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gkech gkech requested a review from hors February 25, 2025 09:23
@hors hors added this to the v1.20.0 milestone Feb 25, 2025
mongoDBURI := "mongodb://$(PBM_AGENT_MONGODB_USERNAME):$(PBM_AGENT_MONGODB_PASSWORD)@$(POD_NAME)"
if cr.CompareVersion("1.20.0") >= 0 {
mongoDBURI = buildMongoDBURI(ctx, tlsEnabled, sslSecret)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

it's ok for me and we merge like this, but I prefer to use inverted logic:

mongoDBURI = buildMongoDBURI(ctx, tlsEnabled, sslSecret)
if cr.CompareVersion("1.20.0") < 0 {
			mongoDBURI := "mongodb://$(PBM_AGENT_MONGODB_USERNAME):$(PBM_AGENT_MONGODB_PASSWORD)@$(POD_NAME)"
		}

It's easier delete unnecessary code when we don't need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When it is time to delete code from this implementation, we will have to touch either way the whole block since this part is nested in the if cr.CompareVersion("1.14.0") >= 0 clause. And since we already have this kind of nesting, inverting the logic makes it harder to read because the logical operations are on different direction 😅

I recommend to keep it as is for now and revisit this when it is time to handle old versions.

@JNKPercona
Copy link
Collaborator

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

commit: 1a907df
image: perconalab/percona-server-mongodb-operator:PR-1835-1a907dfc

@hors hors merged commit af09366 into main Feb 25, 2025
16 checks passed
@hors hors deleted the K8SPSMDB-1256 branch February 25, 2025 13:01
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