Skip to content

Commit 489c791

Browse files
authored
Multi refactoring arch (#354)
# Summary This pull request refactors the agent build and validation logic to improve multi-architecture support and maintainability. It centralizes platform mapping logic, simplifies platform-specific filename resolution, and updates configuration files to reflect platform support changes. Additionally, it documents the new multi-architecture capabilities in the changelog. **Multi-architecture support and configuration updates:** * Updated `build_info.json` to restrict supported platforms for all images to only `linux/amd64`, removing `arm64`, `s390x`, and `ppc64le` from all relevant entries. [[1]](diffhunk://#diff-ac3b10589f332066db566cb08c01afea746d5f16e704beef946107a0c5de5225L8-R8) [[2]](diffhunk://#diff-ac3b10589f332066db566cb08c01afea746d5f16e704beef946107a0c5de5225L28-R25) [[3]](diffhunk://#diff-ac3b10589f332066db566cb08c01afea746d5f16e704beef946107a0c5de5225L57-R51) [[4]](diffhunk://#diff-ac3b10589f332066db566cb08c01afea746d5f16e704beef946107a0c5de5225L89-R80) [[5]](diffhunk://#diff-ac3b10589f332066db566cb08c01afea746d5f16e704beef946107a0c5de5225L144-R132) [[6]](diffhunk://#diff-ac3b10589f332066db566cb08c01afea746d5f16e704beef946107a0c5de5225L208-R193) [[7]](diffhunk://#diff-ac3b10589f332066db566cb08c01afea746d5f16e704beef946107a0c5de5225L241-R223) [[8]](diffhunk://#diff-ac3b10589f332066db566cb08c01afea746d5f16e704beef946107a0c5de5225L274-R253) * Changed the key in `build_info_agent.json` from `platform_mappings` to `platforms` for consistency and clarity. **Agent build and validation code refactoring:** * Introduced a `PlatformConfiguration` class in `validation.py` to encapsulate platform mapping logic, lazy-load build info, and provide unified methods for generating agent and tools build arguments. * Refactored functions to use the new `platforms` key and centralized filename resolution logic, including helper methods for finding valid filenames and checking URL existence. [[1]](diffhunk://#diff-f3a4c7975fde6557a1d05e5170380f65cfef432faf4e5441a1538d003527e449L3-R181) [[2]](diffhunk://#diff-f3a4c7975fde6557a1d05e5170380f65cfef432faf4e5441a1538d003527e449L95-R210) [[3]](diffhunk://#diff-f3a4c7975fde6557a1d05e5170380f65cfef432faf4e5441a1538d003527e449L162-R243) [[4]](diffhunk://#diff-f3a4c7975fde6557a1d05e5170380f65cfef432faf4e5441a1538d003527e449L193-R274) [[5]](diffhunk://#diff-f3a4c7975fde6557a1d05e5170380f65cfef432faf4e5441a1538d003527e449L231-R291) * Updated import statements and removed now-redundant code in `atomic_pipeline.py` to use the new build argument generation functions from the refactored validation logic. [[1]](diffhunk://#diff-f8ee125fd34cdec2e03d7e7282177410cfd21756f4ba3a1ce4f8f2062bfee792R23-L28) [[2]](diffhunk://#diff-f8ee125fd34cdec2e03d7e7282177410cfd21756f4ba3a1ce4f8f2062bfee792L56-L122) * Removed unused imports and cleaned up code in `atomic_pipeline.py`. **Documentation:** * Added a changelog entry describing the addition of comprehensive multi-architecture support for the Kubernetes operator and its images. ## Proof of Work - green ci ## 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 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
1 parent af2eee3 commit 489c791

10 files changed

+380
-484
lines changed

build_info.json

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
"patch": {
66
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes",
77
"platforms": [
8-
"linux/arm64",
9-
"linux/amd64",
10-
"linux/s390x",
11-
"linux/ppc64le"
8+
"linux/amd64"
129
]
1310
},
1411
"staging": {
@@ -54,11 +51,8 @@
5451
"patch": {
5552
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-init-database",
5653
"platforms": [
57-
"linux/arm64",
58-
"linux/amd64",
59-
"linux/s390x",
60-
"linux/ppc64le"
61-
]
54+
"linux/amd64"
55+
]
6256
},
6357
"staging": {
6458
"sign": true,
@@ -86,10 +80,7 @@
8680
"patch": {
8781
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-init-appdb",
8882
"platforms": [
89-
"linux/arm64",
90-
"linux/amd64",
91-
"linux/s390x",
92-
"linux/ppc64le"
83+
"linux/amd64"
9384
]
9485
},
9586
"staging": {
@@ -141,10 +132,7 @@
141132
"patch": {
142133
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-database",
143134
"platforms": [
144-
"linux/arm64",
145-
"linux/amd64",
146-
"linux/s390x",
147-
"linux/ppc64le"
135+
"linux/amd64"
148136
]
149137
},
150138
"staging": {
@@ -173,7 +161,6 @@
173161
"patch": {
174162
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-tests",
175163
"platforms": [
176-
"linux/arm64",
177164
"linux/amd64"
178165
]
179166
},
@@ -205,10 +192,7 @@
205192
"patch": {
206193
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-readinessprobe",
207194
"platforms": [
208-
"linux/arm64",
209-
"linux/amd64",
210-
"linux/s390x",
211-
"linux/ppc64le"
195+
"linux/amd64"
212196
]
213197
},
214198
"staging": {
@@ -238,10 +222,7 @@
238222
"patch": {
239223
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-operator-version-upgrade-post-start-hook",
240224
"platforms": [
241-
"linux/arm64",
242-
"linux/amd64",
243-
"linux/s390x",
244-
"linux/ppc64le"
225+
"linux/amd64"
245226
]
246227
},
247228
"staging": {
@@ -271,10 +252,7 @@
271252
"patch": {
272253
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-agent-ubi",
273254
"platforms": [
274-
"linux/arm64",
275-
"linux/amd64",
276-
"linux/s390x",
277-
"linux/ppc64le"
255+
"linux/amd64"
278256
]
279257
},
280258
"staging": {

build_info_agent.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
{
2-
"platform_mappings": {
2+
"platforms": {
33
"linux/amd64": {
44
"agent_suffixes": ["linux_x86_64.tar.gz"],
5-
"tools_suffix": "rhel93-x86_64-{TOOLS_VERSION}.tgz",
6-
"tools_suffix_old": "rhel90-x86_64-{TOOLS_VERSION}.tgz"
5+
"tools_suffixes": ["rhel93-x86_64-{TOOLS_VERSION}.tgz", "rhel90-x86_64-{TOOLS_VERSION}.tgz"]
76
},
87
"linux/arm64": {
98
"agent_suffixes": ["amzn2_aarch64.tar.gz"],
10-
"tools_suffix": "rhel93-aarch64-{TOOLS_VERSION}.tgz",
11-
"tools_suffix_old": "rhel90-aarch64-{TOOLS_VERSION}.tgz"
9+
"tools_suffixes": ["rhel93-aarch64-{TOOLS_VERSION}.tgz", "rhel90-aarch64-{TOOLS_VERSION}.tgz"]
1210
},
1311
"linux/s390x": {
1412
"agent_suffixes": ["rhel7_s390x.tar.gz", "rhel8_s390x.tar.gz", "rhel9_s390x.tar.gz"],
15-
"tools_suffix": "rhel9-s390x-{TOOLS_VERSION}.tgz",
16-
"tools_suffix_old": "rhel83-s390x-{TOOLS_VERSION}.tgz"
13+
"tools_suffixes": ["rhel9-s390x-{TOOLS_VERSION}.tgz", "rhel83-s390x-{TOOLS_VERSION}.tgz"]
1714
},
1815
"linux/ppc64le": {
1916
"agent_suffixes": ["rhel8_ppc64le.tar.gz", "rhel7_ppc64le.tar.gz", "rhel9_ppc64le.tar.gz"],
20-
"tools_suffix": "rhel9-ppc64le-{TOOLS_VERSION}.tgz",
21-
"tools_suffix_old": "rhel81-ppc64le-{TOOLS_VERSION}.tgz"
17+
"tools_suffixes": ["rhel9-ppc64le-{TOOLS_VERSION}.tgz", "rhel81-ppc64le-{TOOLS_VERSION}.tgz"]
2218
}
2319
},
2420
"base_names": {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: multi-arch support
3+
kind: feature
4+
date: 2025-08-20
5+
---
6+
7+
# Multi-Architecture Support
8+
We've added comprehensive multi-architecture support for the kubernetes operator. This enhancement enables deployment on IBM Power (ppc64le) and IBM Z (s390x) architectures alongside
9+
existing x86_64 support. All core images (operator, agent, init containers, database, readiness probe) now support multiple architectures

scripts/release/agent/detect_ops_manager_changes.py

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -264,152 +264,3 @@ def detect_ops_manager_changes() -> List[Tuple[str, str]]:
264264
return get_changed_agents(current_mapping, base_mapping)
265265
else:
266266
return []
267-
268-
269-
def get_tools_version_for_agent(agent_version: str) -> str:
270-
"""Get tools version for a given agent version from release.json"""
271-
release_data = load_current_release_json()
272-
if not release_data:
273-
return "100.12.2" # Default fallback
274-
275-
ops_manager_mapping = extract_ops_manager_mapping(release_data)
276-
ops_manager_versions = ops_manager_mapping.get("ops_manager", {})
277-
278-
# Search through all OM versions to find matching agent version
279-
for om_version, agent_tools in ops_manager_versions.items():
280-
if agent_tools.get("agent_version") == agent_version:
281-
return agent_tools.get("tools_version", "100.12.2")
282-
283-
# Check cloud_manager tools version as fallback
284-
return ops_manager_mapping.get("cloud_manager_tools", "100.12.2")
285-
286-
287-
def get_all_agents_for_rebuild() -> List[Tuple[str, str]]:
288-
"""Returns list of (agent_version, tools_version) tuples for all agents in release.json"""
289-
agents = []
290-
291-
release_data = load_current_release_json()
292-
if not release_data:
293-
logger.error("Could not load release.json")
294-
return []
295-
296-
ops_manager_mapping = extract_ops_manager_mapping(release_data)
297-
298-
# Get all ops_manager agents
299-
ops_manager_versions = ops_manager_mapping.get("ops_manager", {})
300-
for om_version, agent_tools in ops_manager_versions.items():
301-
agent_version = agent_tools.get("agent_version")
302-
tools_version = agent_tools.get("tools_version")
303-
if agent_version and tools_version:
304-
agents.append((agent_version, tools_version))
305-
306-
# Get cloud_manager agent
307-
cloud_manager_agent = ops_manager_mapping.get("cloud_manager")
308-
cloud_manager_tools = ops_manager_mapping.get("cloud_manager_tools")
309-
if cloud_manager_agent and cloud_manager_tools:
310-
agents.append((cloud_manager_agent, cloud_manager_tools))
311-
312-
# Get the main agent version from release.json root
313-
main_agent_version = release_data.get("agentVersion")
314-
if main_agent_version:
315-
tools_version = get_tools_version_for_agent(main_agent_version)
316-
agents.append((main_agent_version, tools_version))
317-
318-
return list(set(agents))
319-
320-
321-
def get_currently_used_agents() -> List[Tuple[str, str]]:
322-
"""Returns list of (agent_version, tools_version) tuples for agents currently used in contexts and cloudmanager agent from release.json"""
323-
logger.info("Getting currently used agents from contexts")
324-
agents = []
325-
326-
try:
327-
release_data = load_current_release_json()
328-
if not release_data:
329-
logger.error("Could not load release.json")
330-
return []
331-
332-
ops_manager_mapping = extract_ops_manager_mapping(release_data)
333-
ops_manager_versions = ops_manager_mapping.get("ops_manager", {})
334-
335-
# Search all context files
336-
context_pattern = "scripts/dev/contexts/**/*"
337-
context_files = glob.glob(context_pattern, recursive=True)
338-
339-
for context_file in context_files:
340-
if os.path.isfile(context_file):
341-
try:
342-
with open(context_file, "r") as f:
343-
content = f.read()
344-
345-
# Extract AGENT_VERSION from the context file
346-
for line in content.split("\n"):
347-
if line.startswith("export AGENT_VERSION="):
348-
agent_version = line.split("=")[1].strip()
349-
tools_version = get_tools_version_for_agent(agent_version)
350-
agents.append((agent_version, tools_version))
351-
logger.info(f"Found agent {agent_version} in {context_file}")
352-
break
353-
354-
# Extract CUSTOM_OM_VERSION and map to agent version
355-
for line in content.split("\n"):
356-
if line.startswith("export CUSTOM_OM_VERSION="):
357-
om_version = line.split("=")[1].strip()
358-
if om_version in ops_manager_versions:
359-
agent_tools = ops_manager_versions[om_version]
360-
agent_version = agent_tools.get("agent_version")
361-
tools_version = agent_tools.get("tools_version")
362-
if agent_version and tools_version:
363-
agents.append((agent_version, tools_version))
364-
logger.info(
365-
f"Found OM version {om_version} -> agent {agent_version} in {context_file}"
366-
)
367-
break
368-
369-
except Exception as e:
370-
logger.debug(f"Error reading context file {context_file}: {e}")
371-
372-
# Also add the cloudmanager agent from release.json
373-
cloud_manager_agent = ops_manager_mapping.get("cloud_manager")
374-
cloud_manager_tools = ops_manager_mapping.get("cloud_manager_tools")
375-
if cloud_manager_agent and cloud_manager_tools:
376-
agents.append((cloud_manager_agent, cloud_manager_tools))
377-
logger.info(f"Found cloudmanager agent from release.json: {cloud_manager_agent}")
378-
379-
# Also add the main agentVersion from release.json
380-
main_agent_version = release_data.get("agentVersion")
381-
if main_agent_version:
382-
tools_version = get_tools_version_for_agent(main_agent_version)
383-
agents.append((main_agent_version, tools_version))
384-
logger.info(f"Found main agent version from release.json: {main_agent_version}")
385-
386-
unique_agents = list(set(agents))
387-
logger.info(f"Found {len(unique_agents)} currently used agents")
388-
return unique_agents
389-
390-
except Exception as e:
391-
logger.error(f"Error getting currently used agents: {e}")
392-
return []
393-
394-
395-
def detect_ops_manager_changes() -> List[Tuple[str, str]]:
396-
"""Returns (has_changes, changed_agents_list)"""
397-
logger.info("=== Detecting OM Mapping Changes (Local vs Base) ===")
398-
399-
current_release = load_current_release_json()
400-
if not current_release:
401-
logger.error("Could not load current local release.json")
402-
return []
403-
404-
master_release = load_release_json_from_master()
405-
if not master_release:
406-
logger.warning("Could not load base release.json, assuming changes exist")
407-
return []
408-
409-
current_mapping = extract_ops_manager_mapping(current_release)
410-
base_mapping = extract_ops_manager_mapping(master_release)
411-
412-
if current_mapping != base_mapping:
413-
return get_changed_agents(current_mapping, base_mapping)
414-
else:
415-
return []

0 commit comments

Comments
 (0)