Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions release.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@
"search": {
"version": "0.55.0"
},
"latestOpsManagerAgentMapping": [
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you think we can replace the existing code here to use what you've implemented here?

func newAgentVersionManager(omVersionToAgentVersion map[omv1.OpsManagerVersion]omv1.AgentVersion, cmVersion string) *AgentVersionManager {
omVersionsByMajor := make(map[string]string)
if cmVersion == "" {
zap.S().Warnf("No version provided for Cloud Manager agent")
}
for omVersion := range omVersionToAgentVersion {
majorOmVersion := getMajorVersion(string(omVersion))
if currentVersion, exists := omVersionsByMajor[majorOmVersion]; !exists || isLaterVersion(string(omVersion), currentVersion) {
omVersionsByMajor[majorOmVersion] = string(omVersion)
}
}
return &AgentVersionManager{
omToAgentVersionMapping: omVersionToAgentVersion,
latestOMVersionsByMajor: omVersionsByMajor,
agentVersionCM: cmVersion,
}
}

{
"6": {
"opsManagerVersion": "6.0.27",
"agentVersion": "12.0.35.7911-1"
}
},
{
"7": {
"opsManagerVersion": "7.0.19",
"agentVersion": "107.0.19.8805-1"
}
},
{
"8": {
"opsManagerVersion": "8.0.16",
"agentVersion": "108.0.16.8895-1"
}
}
],
"supportedImages": {
"ops-manager": {
"ssdlc_name": "MongoDB Controllers for Kubernetes Enterprise Ops Manager",
Expand Down
49 changes: 49 additions & 0 deletions scripts/evergreen/release/update_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def update_release_json():
newest_operator_version = data["mongodbOperator"]
update_operator_related_versions(data, newest_operator_version)

# Adds mapping between latest major version of OM and agent to the release.json
update_latest_om_agent_mapping(data, newest_om_version)

with open(release, "w") as f:
json.dump(
data,
Expand All @@ -40,6 +43,52 @@ def update_release_json():
f.write("\n")


def update_latest_om_agent_mapping(data, new_om_version):
"""
Updates the 'latestOpsManagerAgentMapping' in release.json with
newly released Ops Manager version and its corresponding Agent version.

If a OM's major version entry already exists, it updates the 'opsManagerVersion'
for that entry. Otherwise, it adds a new entry for the major version.

Args:
data (dict): The complete configuration dictionary.
new_om_version (str): The new Ops Manager version (e.g., "8.0.11").
"""

try:
om_agent_mapping = data["latestOpsManagerAgentMapping"]
except KeyError:
logger.error("Error: 'latestOpsManagerAgentMapping' field not found in the release.json data.")

new_agent_version = data["supportedImages"]["mongodb-agent"]["opsManagerMapping"]["ops_manager"][new_om_version][
"agent_version"
]

try:
new_om_major_version = new_om_version.split(".")[0]
except IndexError:
logger.error(f"Error: Invalid version format for new_om_version: {new_om_version}")

new_om_agent_mapping = {"opsManagerVersion": new_om_version, "agentVersion": new_agent_version}

new_entry = {new_om_major_version: new_om_agent_mapping}

major_version_found = False
for mapping in om_agent_mapping:
if new_om_major_version in mapping:
# Update the existing entry
mapping[new_om_major_version] = new_om_agent_mapping
major_version_found = True
logger.info(f"Updated existing entry for major version '{new_om_major_version}' to {new_om_version}.")
break

# this is new major version of OM, a new entry will be added
if not major_version_found:
om_agent_mapping.append(new_entry)
logger.info(f"Added new entry for major version '{new_om_major_version}' with version {new_om_version}.")


def update_operator_related_versions(release: dict, version: str):
"""
Updates version on `source`, that corresponds to `release.json`.
Expand Down