Skip to content
Open
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
37 changes: 29 additions & 8 deletions scripts/auto-rebase/rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ def run_rebase_cert_manager_sh(release):
return RebaseScriptResult(success=result.returncode == 0, output=result.stdout)


def run_rebase_cluster_monitoring_operator_sh(release_amd64, release_arm64):
"""Run the 'rebase_cluster_monitoring_operator.sh' script with the given release versions and return the script's output."""
script_dir = os.path.abspath(os.path.dirname(__file__))
args = [f"{script_dir}/rebase_cluster_monitoring_operator.sh", "to", release_amd64, release_arm64]
logging.info(f"Running: '{' '.join(args)}'")
start = timer()
result = subprocess.run(
args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, check=False)
logging.info(f"Return code: {result.returncode}. Output:\n" +
"==================================================\n" +
f"{result.stdout}" +
"==================================================\n")
end = timer() - start
logging.info(f"Script returned code: {result.returncode}. It ran for {end/60:.0f}m{end%60:.0f}s.")
return RebaseScriptResult(success=result.returncode == 0, output=result.stdout)


def make_sure_rebase_script_created_new_commits_or_exit(git_repo, base_branch):
"""Exit the script if the 'rebase.sh' script did not create any new commits."""
if git_repo.active_branch.commit == git_repo.branches[base_branch].commit:
Expand Down Expand Up @@ -327,8 +344,10 @@ def main():
ai_rebase_result = run_rebase_ai_model_serving_sh(rhoai_release)
sriov_rebase_result = run_rebase_sriov_sh(sriov_release)
cert_manager_rebase_result = run_rebase_cert_manager_sh(opm_version)
monitoring_rebase_result = run_rebase_cluster_monitoring_operator_sh(release_amd, release_arm)

rebases_succeeded = all([rebase_result.success, ai_rebase_result.success, sriov_rebase_result.success, cert_manager_rebase_result.success])
rebases_succeeded = all([rebase_result.success, ai_rebase_result.success, sriov_rebase_result.success,
cert_manager_rebase_result.success, monitoring_rebase_result.success])

if rebases_succeeded:
# TODO How can we inform team that rebase job ran successfully just there was nothing new?
Expand All @@ -341,11 +360,13 @@ def main():
else:
logging.warning("Rebase script failed - everything will be committed")
with open('rebase.log', mode='w', encoding='utf-8') as writer:
output = ("rebase.sh:\n" +
f"{rebase_result.output}" +
"==================================================\n" +
"rebase_ai_model_serving.sh:\n" +
f"{ai_rebase_result.output}")
separator = "==================================================\n"
output = (
"rebase.sh:\n" + f"{rebase_result.output}" + separator +
"rebase_ai_model_serving.sh:\n" + f"{ai_rebase_result.output}" + separator +
"rebase_sriov.sh:\n" + f"{sriov_rebase_result.output}" + separator +
"rebase_cert_manager.sh:\n" + f"{cert_manager_rebase_result.output}" + separator +
"rebase_cluster_monitoring_operator.sh:\n" + f"{monitoring_rebase_result.output}")
writer.write(output)
if g.git_repo.active_branch.name == base_branch:
# rebase.sh didn't reach the step that would create a branch
Expand All @@ -372,8 +393,8 @@ def main():
g.push(rebase_branch_name, base_branch, gh.gh_repo)

prow_job_url = try_create_prow_job_url()
pr_title = create_pr_title(rebase_branch_name, rebase_result.success)
desc = generate_pr_description(get_release_tag(release_amd), get_release_tag(release_arm), prow_job_url, rebase_result.success)
pr_title = create_pr_title(rebase_branch_name, rebases_succeeded)
desc = generate_pr_description(get_release_tag(release_amd), get_release_tag(release_arm), prow_job_url, rebases_succeeded)

comment = ""
pull_req = gh.get_existing_pr_for_a_branch(adjusted_base_branch, rebase_branch_name)
Expand Down
12 changes: 12 additions & 0 deletions scripts/auto-rebase/rebase_cluster_monitoring_operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@ EOF
fi)
}

commit_cluster_monitoring_operator_changes() {
title "## Committing changes to cluster-monitoring-operator assets"
(cd "${REPOROOT}" && \
if test -n "$(git status -s ./assets)"; then \
git add ./assets && \
git commit -m "update cluster-monitoring-operator manifests and images"; \
else \
echo "No changes in cluster-monitoring-operator assets."; \
fi)
}

rebase_cluster_monitoring_operator_to() {
local release_image_amd64="$1"
local release_image_arm64="$2"
Expand All @@ -338,6 +349,7 @@ rebase_cluster_monitoring_operator_to() {
update_kube_state_metrics_manifests
update_node_exporter_manifests
update_cluster_monitoring_operator_images
commit_cluster_monitoring_operator_changes
update_last_rebase "${release_image_amd64}" "${release_image_arm64}"
}

Expand Down
4 changes: 0 additions & 4 deletions scripts/auto-rebase/rebase_job_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ SRIOV_RELEASE=${sriov_release} \
OPM_RELEASE=${opm_release} \
./scripts/auto-rebase/rebase.py

# Monitoring images (metrics-server, kube-state-metrics, node-exporter) are
# part of the OCP release payload and must be rebased with every nightly.
./scripts/auto-rebase/rebase_cluster_monitoring_operator.sh to "${PULLSPEC_RELEASE_AMD64}" "${PULLSPEC_RELEASE_ARM64}"

# LVMS is not tracked in the OCP release image. Instead, rely on the
# latest z-stream for a given X.Y version. Only the X.Y needs manual
# updating between releases.
Expand Down