Skip to content

Conversation

@mayankshah1607
Copy link
Member

@mayankshah1607 mayankshah1607 commented Dec 22, 2025

K8SPSMDB-1548 Powered by Pull Request Badge

CHANGE DESCRIPTION

Allows configuring env variables for the mongod, mongos and logollector containers

Example:

apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
  name: minimal-cluster
spec:
  # ...
  replsets:
  - name: rs0
    size: 1
    env:
    - name: NAME
      value: VALUE
    envFrom:
    - configMapRef:
        name: config-map-name
    - secretRef:
        name: secret-name
  sharding:
    enabled: true
    configsvrReplSet:
      size: 1
      env:
      - name: NAME
        value: VALUE
      envFrom:
      - configMapRef:
          name: config-map-name
      - secretRef:
          name: secret-name
    mongos:
      size: 1
      env:
      - name: NAME
        value: VALUE
      envFrom:
      - configMapRef:
          name: config-map-name
      - secretRef:
          name: secret-name

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?

Copilot AI review requested due to automatic review settings December 22, 2025 12:49
@pull-request-size pull-request-size bot added the size/XXL 1000+ lines label Dec 22, 2025
@github-actions github-actions bot added the tests label Dec 22, 2025
Copy link
Contributor

Copilot AI left a comment

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 adds support for configuring custom environment variables on MongoDB containers through the env and envFrom fields in the Custom Resource Definition (CRD). The feature is version-gated to operator version 1.22.0 and above.

Key changes:

  • Added Env and EnvFrom fields to ReplsetSpec, NonVotingSpec, HiddenSpec, and MongosSpec types
  • Refactored the container function in statefulset.go to use a parameter struct pattern
  • Applied version gating (1.22.0+) to conditionally append custom environment variables

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/apis/psmdb/v1/psmdb_types.go Added Env and EnvFrom fields to ReplsetSpec, NonVotingSpec, HiddenSpec, and MongosSpec structs
pkg/apis/psmdb/v1/zz_generated.deepcopy.go Generated DeepCopy methods for new Env and EnvFrom fields
pkg/psmdb/container.go Refactored container function to accept parameters struct; added version-gated Env/EnvFrom appending
pkg/psmdb/statefulset.go Updated to pass containerFnParams struct with Env and EnvFrom fields to container function
pkg/psmdb/mongos.go Added version-gated Env appending for mongos containers
pkg/apis/psmdb/v1/psmdb_defaults.go Minor whitespace formatting change
deploy/crd.yaml, deploy/bundle.yaml, deploy/cw-bundle.yaml, config/crd/bases/*.yaml, e2e-tests/version-service/conf/crd.yaml Updated CRD definitions with env and envFrom field schemas

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Copilot AI review requested due to automatic review settings December 23, 2025 10:26
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

pkg/controller/perconaservermongodb/statefulset_test.go:138

  • Several test cases for the cfg replica set (arbiter, non-voting, and hidden) have been commented out. These tests should either be re-enabled with updated expectations, or if they are intentionally being removed, they should be deleted rather than commented out. Commented-out code reduces code maintainability and can lead to confusion about the intended state of the test suite.
		{
			name:        "cfg-arbiter",
			cr:          defaultCR.DeepCopy(),
			rsName:      "cfg",
			component:   naming.ComponentArbiter,
			expectedSts: expectedSts(t, "reconcile-statefulset/cfg-arbiter.yaml"),
		},
		{
			name:        "cfg-non-voting",
			cr:          defaultCR.DeepCopy(),
			rsName:      "cfg",
			component:   naming.ComponentNonVoting,
			expectedSts: expectedSts(t, "reconcile-statefulset/cfg-nv.yaml"),
		},
		{
			name:        "cfg-hidden",
			cr:          defaultCR.DeepCopy(),
			rsName:      "cfg",
			component:   naming.ComponentHidden,
			expectedSts: expectedSts(t, "reconcile-statefulset/cfg-hidden.yaml"),
		},

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Copilot AI review requested due to automatic review settings December 23, 2025 11:13
Signed-off-by: Mayank Shah <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Copilot AI review requested due to automatic review settings December 23, 2025 11:34
Signed-off-by: Mayank Shah <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

pkg/psmdb/mongos_test.go:16

  • The duplicate import of the same package with different aliases is unnecessary. Line 15 imports api from the psmdb/v1 package, and line 16 imports psmdbv1 from the same package. Consider removing the duplicate import on line 16 and using the api alias consistently throughout the test.
	api "github.com/percona/percona-server-mongodb-operator/pkg/apis/psmdb/v1"
	"github.com/percona/percona-server-mongodb-operator/pkg/version"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JNKPercona
Copy link
Collaborator

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

commit: 64e6d5c
image: perconalab/percona-server-mongodb-operator:PR-2163-64e6d5ce

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.

7 participants