Skip to content

Commit b5ad3ef

Browse files
MaciejKarasfealebenpae
authored andcommitted
CLOUDP-295945 - stop calling mms repo in precommit hook (#4100)
# Summary This PR removes calls to mms repository in precommit hook. [update_agent_and_tools_version](https://github.com/10gen/ops-manager-kubernetes/blob/008c01523d5a1576a1ed2aaeecb08e208315c3a1/scripts/evergreen/release/update_release.py#L95) function is the only code that calls mms to get agent and mongo tools version for the most recent OM version in release.json (`["supportedImages"]["ops-manager"]["versions"][-1]`). This information is used for: - `update_om_mapping` -> it updates the `["supportedImages"]["mongodb-agent"]["opsManagerMapping"]["ops_manager"][latest_version]` agent and tools mapping. I see that those values are set [by PCT during OM release](10gen/ops-manager-kubernetes@53b970c) and precommit hook tries to update this path again with no changes - `update_mongodb_tools_bundle` -> this updates `["mongodbToolsBundle"]["ubi"]` bundle version that is used when building `init_appdb` and `init_database`. We can get this information from latest version in opsManagerMapping that PCT sets during OM release ## Followup tasks (after merging) - [ ] update docs [here](REDACTED) and [here](REDACTED) after merging PR ## Proof of Work Run locally precommit hook with updated OM mapping in `release.json` and it updated `mongodbToolsBundle` entry. Without changes to release.json there are no updates - CI lint task [succeeded](https://spruce.mongodb.com/task/ops_manager_kubernetes_unit_tests_lint_repo_patch_f316028ac429a42806039a834ce78906b5e2c1f1_67ae19a200e9150007c7d8ab_25_02_13_16_11_16/logs?execution=0). ## Checklist - [x] Have you linked a jira ticket and/or is the ticket in the title? - [x] Have you checked whether your jira ticket required DOCSP changes? - [x] Have you checked for release_note changes? ## Reminder (Please remove this when merging) - Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible - Our Short Guide for PRs: [Link](REDACTED) - Remember the following Communication Standards - use comment prefixes for clarity: * **blocking**: Must be addressed before approval. * **follow-up**: Can be addressed in a later PR or ticket. * **q**: Clarifying question. * **nit**: Non-blocking suggestions. * **note**: Side-note, non-actionable. Example: Praise * --> no prefix is considered a question
1 parent 80c9a24 commit b5ad3ef

File tree

2 files changed

+7
-65
lines changed

2 files changed

+7
-65
lines changed

.evergreen-functions.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,12 @@ functions:
205205
add_to_path:
206206
- ${workdir}/bin
207207
command: scripts/evergreen/setup_yq.sh
208-
- command: github.generate_token
209-
params:
210-
owner: 10gen
211-
repo: ops-manager-kubernetes
212-
expansion_name: GITHUB_TOKEN_READ
213208
- command: subprocess.exec
214209
type: test
215210
params:
216211
add_to_path:
217212
- ${workdir}/bin
218213
- ${workdir}/venv/bin
219-
include_expansions_in_env:
220-
- GITHUB_TOKEN_READ
221214
working_dir: src/github.com/10gen/ops-manager-kubernetes
222215
binary: scripts/evergreen/check_precommit.sh
223216

Lines changed: 7 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#!/usr/bin/env python3
22

3-
import configparser
43
import json
54
import logging
65
import os
7-
import sys
86

9-
import requests
107
import yaml
11-
from packaging.version import Version
128

139
logger = logging.getLogger(__name__)
1410

@@ -21,22 +17,6 @@ def get_latest_om_versions_from_evergreen_yml():
2117
return data["variables"][0], data["variables"][1]
2218

2319

24-
def get_headers():
25-
"""
26-
Returns an authentication header that can be used when accessing
27-
the Github API. This is used to access private 10gen repos.
28-
"""
29-
30-
github_token = os.getenv("GITHUB_TOKEN_READ")
31-
if github_token is None:
32-
raise Exception(
33-
"Missing GITHUB_TOKEN_READ environment variable; see https://wiki.corp.mongodb.com/display/MMS/Pre-Commit+Hook"
34-
)
35-
return {
36-
"Authorization": f"token {github_token}",
37-
}
38-
39-
4020
def update_release_json():
4121
# Define a custom constructor to preserve the anchors in the YAML file
4222
release = os.path.join(os.getcwd(), "release.json")
@@ -45,7 +25,7 @@ def update_release_json():
4525

4626
# PCT already bumps the release.json, such that the last element contains the newest version, since they are sorted
4727
newest_om_version = data["supportedImages"]["ops-manager"]["versions"][-1]
48-
update_agent_and_tools_version(data, newest_om_version)
28+
update_mongodb_tools_bundle(data, newest_om_version)
4929

5030
# PCT bumps this field, and we can use this as a base to set the version for everything else in release.json
5131
newest_operator_version = data["mongodbOperator"]
@@ -92,43 +72,12 @@ def update_operator_related_versions(release: dict, version: str):
9272
logger.debug(f"Updated content {release}")
9373

9474

95-
def update_agent_and_tools_version(data, missing_version):
96-
repo_owner = "10gen"
97-
repo_name = "mms"
98-
file_path = "server/conf/conf-hosted.properties"
99-
if missing_version.startswith("6."):
100-
tag_to_search = f"on-prem-{missing_version}"
101-
else:
102-
# starting om 7 our tag starts with ops-manager-<version> instead
103-
tag_to_search = f"ops-manager-{missing_version}"
104-
105-
url = f"https://raw.githubusercontent.com/{repo_owner}/{repo_name}/{tag_to_search}/{file_path}"
106-
response = requests.get(url=url, headers=get_headers())
107-
# Check if the request was successful
108-
if response.status_code == 200:
109-
config = configparser.ConfigParser()
110-
input_data = (
111-
"[DEFAULT]\n" + response.text
112-
) # configparser needs a section, but our properties do not contain one.
113-
config.read_string(input_data)
114-
mongo_tool_version = config.get("DEFAULT", "mongotools.version")
115-
agent_version = config.get("DEFAULT", "automation.agent.version")
116-
update_om_mapping(agent_version, data, missing_version, mongo_tool_version)
117-
118-
new_rhel_tools_version = "100.10.0"
119-
arch = "rhel88" if Version(mongo_tool_version) >= Version(new_rhel_tools_version) else "rhel80"
120-
version_name = f"mongodb-database-tools-{arch}-x86_64-{mongo_tool_version}.tgz"
121-
data["mongodbToolsBundle"]["ubi"] = version_name
122-
else:
123-
print(f"was not able to request file from {url}: {response.text}")
124-
sys.exit(1)
125-
126-
127-
def update_om_mapping(agent_version, data, missing_version, mongo_tool_version):
128-
data["supportedImages"]["mongodb-agent"]["opsManagerMapping"]["ops_manager"][missing_version] = {
129-
"agent_version": f"{agent_version}",
130-
"tools_version": f"{mongo_tool_version}",
131-
}
75+
def update_mongodb_tools_bundle(data, newest_om_version):
76+
om_mapping = data["supportedImages"]["mongodb-agent"]["opsManagerMapping"]["ops_manager"][newest_om_version]
77+
mongo_tool_version = om_mapping["tools_version"]
78+
79+
version_name = f"mongodb-database-tools-rhel88-x86_64-{mongo_tool_version}.tgz"
80+
data["mongodbToolsBundle"]["ubi"] = version_name
13281

13382

13483
update_release_json()

0 commit comments

Comments
 (0)