Skip to content

CLOUDP-331841 - remove the agent matrix work #267

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

Merged
merged 51 commits into from
Aug 8, 2025
Merged

Conversation

nammn
Copy link
Collaborator

@nammn nammn commented Jul 15, 2025

Summary

Database:

from:

+------------------------------------------------------------+
|                        Pod: rs1                            |
+------------------------------------------------------------+
| Container 1: mongodb-agent (operator suffixed)             |
|   - entry: agent-launcher.sh                               |
|   - livenessProbe                                          |
|   - readinessProbe                                         |
+------------------------------------------------------------+
| Container 2: mongodb-enterprise-database                   |
|   - mongod                                                 |
|   - mongosh                                                |
+------------------------------------------------------------+

to:

+------------------------------------------------------------+
|                        Pod: rs1                            |
+------------------------------------------------------------+
| Container 1: mongodb-agent (not operator suffixed)         |
|   - entry: agent-launcher-shim.sh                          |
|   - dummy-livenessProbe                                    |
|   - dummy-readinessProbe                                   |
+------------------------------------------------------------+
| Container 2: utilities-holder (name tbd)                   |
|   - readinessProbe                                         |
|   - livenessProbe                                          |
|   - agent-launcher.sh                                      |
+------------------------------------------------------------+
| Container 3: mongodb-enterprise-database                   |
|   - mongod                                                 |
|   - mongosh                                                |
+------------------------------------------------------------+

AppDB:

from:

+------------------------------------------------------------+
|                        Pod: rs1                            |
+------------------------------------------------------------+
| Container 1: mongodb-agent (operator suffixed)             |
|   - entry: agent/mongodb-agent                             |
|   - agent-launcher.sh                                      |
|   - livenessProbe                                          |
|   - readinessProbe                                         |
+------------------------------------------------------------+
| Container 2: mongodb-enterprise-database                   |
|   - mongod                                                 |
|   - mongosh                                                |
+------------------------------------------------------------+

to:

+------------------------------------------------------------+
|                        Pod: rs1                            |
+------------------------------------------------------------+
| Container 1: mongodb-agent (not operator suffixed)         |
|   - entry: /usr/local/bin/setup-agent-files.sh &&          |
|            agent/mongodb-agent                             |
|   - agent-launcher-shim.sh (unused)                        |
|   - dummy-livenessProbe                                    |
|   - dummy-readinessProbe                                   |
+------------------------------------------------------------+
| Container 2: utilities-holder (name tbd)                   |
|   - readinessProbe                                         |
|   - livenessProbe                                          |
+------------------------------------------------------------+
| Container 3: mongodb-enterprise-database                   |
|   - mongod                                                 |
|   - mongosh                                                |
+------------------------------------------------------------+

Summary Changes

This pull request introduces significant changes to the MongoDB Kubernetes operator, focusing on refactoring, architecture updates, and bug fixes. The changes include removing unused dependencies, improving the handling of static and non-static architectures, and enhancing test coverage. Below is a categorized summary of the most important changes:

Refactoring and Code Simplification

  • No operator suffixed agent returned by the operator for the agent
  • Consolidated logic for handling static and non-static architectures in the buildDatabaseStatefulSetConfigurationFunction by introducing shared and architecture-specific modifications. [1] [2]
  • Renamed InitDatabaseNonStaticImage to InitDatabaseImage in DatabaseStatefulSetOptions for clarity.

Static and Non-Static Architecture Handling

  • Introduced separate functions (buildStaticArchitecturePodTemplateSpec and buildNonStaticArchitecturePodTemplateSpec) to handle static and non-static architectures, improving modularity and maintainability.
  • Updated the AppDbStatefulSet function to include opts.InitAppDBImage when defining init containers, ensuring proper handling of both architectures.

Enhancements to StatefulSet and Pod Templates

  • Added a new container (automationUtilitiesPodTemplateFunc) to the appDbPodSpec for managing utility scripts and hooks, along with corresponding volume mounts. [1] [2]
  • Adjusted the AutomationAgentCommand to include additional startup parameters for better configuration.

Proof of Work

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you checked for release_note changes?

@nammn nammn force-pushed the remove-agent-matrix branch from d76eda3 to 08c2c49 Compare July 16, 2025 09:25
@nammn nammn added the wip label Jul 16, 2025
@nammn nammn changed the title refactor - agent matrix work wip - refactor - agent matrix work Jul 16, 2025
Comment on lines +177 to +183
} else {
staticMounts := []corev1.VolumeMount{hooksVolumeMount, scriptsVolumeMount, tmpVolumeMount}
withStaticContainerModification = podtemplatespec.WithContainer(util.AgentContainerUtilitiesName, mongodbAgentUtilitiesContainer(staticMounts, initAppDBImage))
mongodbAgentVolumeMounts = append(mongodbAgentVolumeMounts, staticMounts...)
shareProcessNs = func(sts *appsv1.StatefulSet) {
sts.Spec.Template.Spec.ShareProcessNamespace = ptr.To(true)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment to make it clear what each branch is for? Is the else branch for static appdb?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes you are correct -added a comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is not enough?

// we need the upgrade hook and readinessProbe either via init containers or via a side-car and /proc access
// if we don't use init containers we need to use static containers

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that for non-static appdb we are now adding 2 init containers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we've always had 2 init containers for non static

@nammn nammn enabled auto-merge (squash) August 8, 2025 14:13
@nammn nammn merged commit 79ae98d into master Aug 8, 2025
20 of 21 checks passed
@nammn nammn deleted the remove-agent-matrix branch August 8, 2025 14:42
MaciejKaras added a commit that referenced this pull request Aug 11, 2025
…ros propagation (#328)

# Summary

Fixes issue with conflicting `Dockerfile` files on master. Sonar is
creating Dockerfiles in the directory where new Dockerfile existed
already. They were added here ->
#289.

Additionally another PR
#267 made changes to
how the agent images were built and especially to agent Dockerfile ARGs:

https://github.com/mongodb/mongodb-kubernetes/blob/89866b79233745e27ade51dc2d9fd0e73c6124e5/docker/mongodb-agent/Dockerfile#L3-L6

This conflicted with
#303 where new
`atomic_pipeline.py` was still depending on the old Dockerfile
structure:


https://github.com/mongodb/mongodb-kubernetes/blob/774bbaca930a1752060cfe5e5bf60f24cd6c999c/docker/mongodb-agent/Dockerfile#L25-L26

## Proof of Work

Passing CI (especially agent build task)

## Checklist

- [ ] Have you linked a jira ticket and/or is the ticket in the title?
- [ ] Have you checked whether your jira ticket required DOCSP changes?
- [x] Have you added changelog file?
    - use `skip-changelog` label if not needed
- refer to [Changelog files and Release
Notes](https://github.com/mongodb/mongodb-kubernetes/blob/master/CONTRIBUTING.md#changelog-files-and-release-notes)
section in CONTRIBUTING.md for more details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants