From ad3721dce85c3662564e17b45513d6903988ce97 Mon Sep 17 00:00:00 2001 From: Patryk Matuszak <305846+pmtk@users.noreply.github.com> Date: Wed, 15 Mar 2023 16:05:22 +0100 Subject: [PATCH] backport rebase.py and edit KAS defaultconfig --- scripts/auto-rebase/create_pr.py | 125 ------ scripts/auto-rebase/rebase.py | 424 +++++++++++++++++++ scripts/auto-rebase/rebase.sh | 7 +- scripts/auto-rebase/rebase_job_entrypoint.sh | 22 +- 4 files changed, 440 insertions(+), 138 deletions(-) delete mode 100755 scripts/auto-rebase/create_pr.py create mode 100755 scripts/auto-rebase/rebase.py diff --git a/scripts/auto-rebase/create_pr.py b/scripts/auto-rebase/create_pr.py deleted file mode 100755 index b921a4b16a..0000000000 --- a/scripts/auto-rebase/create_pr.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env python - -"""Pull Request Creator - -This script pushes current branch and creates GitHub Pull Request. -It's intended to be used as a GitHub App and requires following environment variables: -- APP_ID - application id, get from app's about page (https://github.com/settings/apps/$APP_NAME) -- KEY - path to application's private key - generate on app's about page -- ORG - organization -- REPO - repository - -App requires following permissions: -- Contents Read+Write - to push branches -- Pull requests Read+Write - to create PRs -""" - -import os -import re -import sys -from git import Repo, PushInfo # GitPython -from github import GithubIntegration, Github, GithubException # pygithub -from pathlib import Path - -APP_ID_ENV = "APP_ID" -KEY_ENV = "KEY" -ORG_ENV = "ORG" -REPO_ENV = "REPO" -JOB_NAME_ENV = "JOB_NAME" - -BOT_REMOTE_NAME = "bot-creds" -JOB_NAME_REGEXP = "periodic-ci-openshift-microshift-(.+)-periodics-rebase-on-nightlies" - - -def try_get_env(var_name): - val = os.getenv(var_name) - if val is None or val == "": - sys.exit(f"Env var {var_name} is empty") - return val - - -def get_expected_base_branch(): - return re.search(JOB_NAME_REGEXP, try_get_env(JOB_NAME_ENV)).group(1) - - -app_id = try_get_env(APP_ID_ENV) -key_path = try_get_env(KEY_ENV) -org = try_get_env(ORG_ENV) -repo = try_get_env(REPO_ENV) -expected_base = get_expected_base_branch() - - -def commit_str(commit): - return f"{commit.hexsha[:8]} - {commit.summary}" - - -def create_or_get_pr_url(ghrepo): - prs = ghrepo.get_pulls( - base=expected_base, head=f"{org}:{r.active_branch.name}", state="all") - if prs.totalCount == 1: - print( - f"{prs[0].state.capitalize()} pull request exists already: {prs[0].html_url}") - elif prs.totalCount > 1: - print( - f"Found several existing PRs for '{r.active_branch.name}': {[(x.state, x.html_url) for x in prs]}") - else: - body = f"{r.active_branch.name}\n\n/label tide/merge-method-squash" - pr = ghrepo.create_pull(title=r.active_branch.name, body=body, - base=expected_base, head=r.active_branch.name, maintainer_can_modify=True) - print(f"Created pull request: {pr.html_url}") - - -integration = GithubIntegration(app_id, Path(key_path).read_text()) -app_installation = integration.get_installation(org, repo) -if app_installation == None: - sys.exit( - f"Failed to get app_installation for {org}/{repo}. Response: {app_installation.raw_data}") -installation_access_token = integration.get_access_token( - app_installation.id).token -gh = Github(installation_access_token) -ghrepo = gh.get_repo(f"{org}/{repo}") - -r = Repo('.') -if r.active_branch.commit == r.branches[expected_base].commit: - print( - f"There's no new commit on branch {r.active_branch} compared to '{expected_base}'.\nLast commit: {r.active_branch.commit.hexsha[:8]} - \n\n{r.active_branch.commit.summary}'") - sys.exit(0) - -remote_url = f"https://x-access-token:{installation_access_token}@github.com/{org}/{repo}" -try: - remote = r.remote(BOT_REMOTE_NAME) - remote.set_url(remote_url) -except ValueError: - r.create_remote(BOT_REMOTE_NAME, remote_url) - -remote = r.remote(BOT_REMOTE_NAME) -remote.fetch() - -# Check if branch with the same name exists in remote -matching_remote_branches = [ - ref for ref in remote.refs if BOT_REMOTE_NAME + "/" + r.active_branch.name == ref.name] -if len(matching_remote_branches) == 1: - # Compare local and remote rebase branches by looking at their start on {expected_base} branch (commit from which they branched off) - merge_base_prev_rebase = r.merge_base( - expected_base, matching_remote_branches[0].name) - merge_base_cur_rebase = r.merge_base(expected_base, r.active_branch.name) - if merge_base_prev_rebase[0] == merge_base_cur_rebase[0]: - print(f"Branch {r.active_branch} already exists on remote and it's up to date.\n\ -Branch-off commit: {commit_str(merge_base_cur_rebase[0])}\n") - create_or_get_pr_url(ghrepo) - sys.exit(0) - else: - print(f"Branch {r.active_branch} already exists on remote but it's out of date.\n\ -Old branch-off commit: {commit_str(merge_base_prev_rebase[0])}\n\ -New branch-off commit: {commit_str(merge_base_cur_rebase[0])}\n") - -push_result = remote.push(r.active_branch.name, force=True) -if len(push_result) != 1: - sys.exit( - f"Unexpected amount ({len(push_result)}) of items in push_result: {push_result}") -if push_result[0].flags & PushInfo.ERROR: - sys.exit(f"Pushing branch failed: {push_result[0].summary}") -if push_result[0].flags & PushInfo.FORCED_UPDATE: - print("Branch was updated (force push)") - -create_or_get_pr_url(ghrepo) diff --git a/scripts/auto-rebase/rebase.py b/scripts/auto-rebase/rebase.py new file mode 100755 index 0000000000..785efe4f35 --- /dev/null +++ b/scripts/auto-rebase/rebase.py @@ -0,0 +1,424 @@ +#!/usr/bin/env python + +import json +import logging +import os +import subprocess +import sys +import textwrap +from collections import namedtuple +from pathlib import Path +from timeit import default_timer as timer + +from git import PushInfo, Repo # GitPython +from github import Github, GithubException, GithubIntegration # pygithub + +APP_ID_ENV = "APP_ID" # GitHub App's ID +KEY_ENV = "KEY" # Path to GitHub App's key +PAT_ENV = "TOKEN" # Personal Access Token +ORG_ENV = "ORG" +REPO_ENV = "REPO" +AMD64_RELEASE_ENV = "AMD64_RELEASE" +ARM64_RELEASE_ENV = "ARM64_RELEASE" +JOB_NAME_ENV = "JOB_NAME" +BUILD_ID_ENV = "BUILD_ID" +DRY_RUN_ENV = "DRY_RUN" +BASE_BRANCH_ENV = "BASE_BRANCH" + +BOT_REMOTE_NAME = "bot-creds" +REMOTE_ORIGIN = "origin" + +# List of reviewers to always requestes review from +REVIEWERS = [] + +# If True, then just log action such as branch push and PR or comment creation +REMOTE_DRY_RUN = False + +_extra_msgs = [] + +logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s') + + +RebaseScriptResult = namedtuple("RebaseScriptResult", ["success", "output"]) + + +def try_get_env(var_name, die=True): + val = os.getenv(var_name) + if val is None or val == "": + if die: + logging.error(f"Could not get environment variable '{var_name}'") + sys.exit(f"Could not get environment variable '{var_name}'") + else: + logging.info(f"Could not get environment variable '{var_name}' - ignoring") + return "" + return val + + +def run_rebase_sh(release_amd64, release_arm64): + script_dir = os.path.abspath(os.path.dirname(__file__)) + args = [f"{script_dir}/rebase.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) + 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 commit_str(commit): + return f"{commit.hexsha[:8]} - {commit.summary}" + + +def get_installation_access_token(app_id, key_path, org, repo): + integration = GithubIntegration(app_id, Path(key_path).read_text()) + app_installation = integration.get_installation(org, repo) + if app_installation == None: + sys.exit(f"Failed to get app_installation for {org}/{repo}. Response: {app_installation.raw_data}") + return integration.get_access_token(app_installation.id).token + + +def make_sure_rebase_script_created_new_commits_or_exit(git_repo, base_branch): + if git_repo.active_branch.commit == git_repo.branches[base_branch].commit: + logging.info(f"There's no new commit on branch {git_repo.active_branch} compared to '{base_branch}' " + "meaning that the rebase.sh script didn't create any commits and " + "MicroShift is already rebased on top of given release.\n" + f"Last commit: {commit_str(git_repo.active_branch.commit)}") + sys.exit(0) + + +def rebase_script_made_changes_considered_functional(git_repo, base_branch): + logging.info(f"Deciding if PR should be created by diffing against {base_branch} branch") + diffs = git_repo.active_branch.commit.diff(base_branch) + logging.info(f"Following files changed: {[ d.a_path for d in diffs ]}") + + for d in diffs: + if 'scripts/auto-rebase/' in d.a_path: + logging.info(f" - {d.a_path} - ignoring") + continue + + if "assets/release/release-" in d.a_path: + old_images = set(json.loads(d.a_blob.data_stream.read())['images'].items()) + new_images = set(json.loads(d.b_blob.data_stream.read())['images'].items()) + diff = old_images ^ new_images + if not diff: + logging.info(f" - {d.a_path} - images did not change - ignoring") + continue + logging.info(f" - {d.a_path} - images changed") + return True + + logging.info(f" - File {d.a_path} is considered functional") + return True + + return False + + +def get_remote_with_token(git_repo, token, org, repo): + remote_url = f"https://x-access-token:{token}@github.com/{org}/{repo}" + try: + remote = git_repo.remote(BOT_REMOTE_NAME) + remote.set_url(remote_url) + except ValueError: + git_repo.create_remote(BOT_REMOTE_NAME, remote_url) + + return git_repo.remote(BOT_REMOTE_NAME) + + +def try_get_rebase_branch_ref_from_remote(remote, branch_name): + remote.fetch() + matching_remote_refs = [ref for ref in remote.refs if BOT_REMOTE_NAME + "/" + branch_name == ref.name] + + if len(matching_remote_refs) == 0: + logging.info(f"Branch '{branch_name}' does not exist on remote") + return None + + if len(matching_remote_refs) > 1: + matching_branches = ", ".join([r.name for r in matching_remote_refs]) + logging.warning(f"Found more than one branch matching '{branch_name}' on remote: {matching_branches}. Taking first one") + _extra_msgs.append(f"Found more than one branch matching '{branch_name}' on remote: {matching_branches}.") + return matching_remote_refs[0] + + if len(matching_remote_refs) == 1: + logging.info(f"Branch '{branch_name}' already exists on remote") + return matching_remote_refs[0] + + +def is_local_branch_based_on_newer_base_branch_commit(git_repo, base_branch_name, remote_branch_name, local_branch_name): + """ + Compares local and remote rebase branches by looking at their start on base branch. + Returns True if local branch is starts on newer commit and needs to be pushed to remote, otherwise False. + """ + remote_merge_base = git_repo.merge_base(base_branch_name, remote_branch_name) + local_merge_base = git_repo.merge_base(base_branch_name, local_branch_name) + + if remote_merge_base[0] == local_merge_base[0]: + logging.info(f"Remote branch is up to date. Branch-off commit: {commit_str(remote_merge_base[0])}") + return False + else: + logging.info(f"Remote branch is older - it needs updating. " + f"Remote branch is on top of {base_branch_name}'s commit: '{commit_str(remote_merge_base[0])}'. " + f"Local branch is on top of {base_branch_name}'s commit '{commit_str(local_merge_base[0])}'") + return True + + +def try_get_pr(gh_repo, org, base_branch, branch_name): + prs = gh_repo.get_pulls(base=base_branch, head=f"{org}:{branch_name}", state="all") + + if prs.totalCount == 0: + logging.info(f"PR for branch {branch_name} does not exist yet on {gh_repo.full_name}") + return None + + pr = None + if prs.totalCount > 1: + pr = prs[0] + logging.warning(f"Found more than one PR for branch {branch_name} on {gh_repo.full_name} - this is unexpected, continuing with first one of: {[(x.state, x.html_url) for x in prs]}") + + if prs.totalCount == 1: + pr = prs[0] + logging.info(f"Found PR #{pr.number} for branch {branch_name} on {gh_repo.full_name}: {pr.html_url}") + + if pr.state == 'closed': + logging.warning(f"PR #{pr.number} is not open - new PR will be created") + if pr.is_merged(): + logging.warning(f"PR #{pr.number} for '{branch_name}' branch is already merged but rebase.sh produced results") + _extra_msgs.append(f"PR #{pr.number} for '{branch_name}' was already merged but rebase.sh produced results") + else: + _extra_msgs.append(f"PR #{pr.number} for '{branch_name}' exists already but was closed") + return None + return pr + + +def generate_pr_description(branch_name, amd_tag, arm_tag, prow_job_url, rebase_script_succeded): + try: + with open("scripts/auto-rebase/changelog.txt", "r") as f: + changelog = f.read() + except Exception as e: + logging.warn(f"Unable to read changelog file: {e}") + changelog = "" + + base = textwrap.dedent(f""" + amd64: {amd_tag} + arm64: {arm_tag} + prow job: {prow_job_url} + + {changelog} + + /label tide/merge-method-squash + """) + return (base if rebase_script_succeded + else "# rebase.sh failed - check committed rebase_sh.log\n\n" + base) + + +def create_pr(gh_repo, base_branch, branch_name, title, desc): + if REMOTE_DRY_RUN: + logging.info(f"[DRY RUN] Create PR: branch='{branch_name}', title='{title}', desc='{desc}'") + logging.info(f"[DRY RUN] Requesting review from {REVIEWERS}") + return + + pr = gh_repo.create_pull(title=title, body=desc, base=base_branch, head=branch_name, maintainer_can_modify=True) + logging.info(f"Created pull request: {pr.html_url}") + try: + pr.create_review_request(reviewers=REVIEWERS) + logging.info(f"Requested review from {REVIEWERS}") + except GithubException as e: + logging.info(f"Failed to request review from {REVIEWERS} because: {e}") + return pr + + +def update_pr(pr, title, desc): + if REMOTE_DRY_RUN: + logging.info(f"[DRY RUN] Update PR #{pr.number}: {title}\n{desc}") + return + + pr.edit(title=title, body=desc) + pr.update() # arm64 release or prow job url might've changed + logging.info(f"Updated PR #{pr.number}: {title}\n{desc}") + + +def post_comment(pr, comment=""): + if len(_extra_msgs) != 0: + if comment != "": + comment += "\n\n" + comment += "Extra messages:\n - " + "\n - ".join(_extra_msgs) + + if comment.strip() != "": + logging.info(f"Comment to post: {comment}") + if REMOTE_DRY_RUN: + logging.info(f"[DRY RUN] Posted a comment") + return + issue = pr.as_issue() + issue.create_comment(comment) + else: + logging.info(f"No content for comment") + + +def push_branch_or_die(remote, branch_name): + if REMOTE_DRY_RUN: + logging.info(f"[DRY RUN] git push --force {branch_name}") + return + + # TODO add retries + push_result = remote.push(branch_name, force=True) + + if len(push_result) != 1: + sys.exit(f"Unexpected amount ({len(push_result)}) of items in push_result: {push_result}") + if push_result[0].flags & PushInfo.ERROR: + sys.exit(f"Pushing branch failed: {push_result[0].summary}") + if push_result[0].flags & PushInfo.FORCED_UPDATE: + logging.info(f"Branch '{branch_name}' existed and was updated (force push)") + + +def get_release_tag(release): + parts = release.split(":") + if len(parts) == 2: + return parts[1] + else: + logging.error(f"Couldn't find tag in '{release}' - using it as is as branch name") + _extra_msgs.append(f"Couldn't find tag in '{release}' - using it as is as branch name") + return release + + +def try_create_prow_job_url(): + job_name = try_get_env(JOB_NAME_ENV, False) + build_id = try_get_env(BUILD_ID_ENV, False) + if job_name != "" and build_id != "": + url = f"https://prow.ci.openshift.org/view/gs/origin-ci-test/logs/{job_name}/{build_id}" + logging.info(f"Inferred probable prow job url: {url}") + return url + else: + logging.warning(f"Couldn't infer prow job url. Env vars: '{JOB_NAME_ENV}'='{job_name}', '{BUILD_ID_ENV}'='{build_id}'") + _extra_msgs.append(f"Couldn't infer prow job url. Env vars: '{JOB_NAME_ENV}'='{job_name}', '{BUILD_ID_ENV}'='{build_id}'") + return "-" + + +def create_pr_title(branch_name, successful_rebase): + return branch_name if successful_rebase else f"**FAILURE** {branch_name}" + + +def get_expected_branch_name(amd, arm): + amd_tag, arm_tag = get_release_tag(amd), get_release_tag(arm) + import re + rx = "(?P.+)-(?P[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6})" + match_amd, match_arm = re.match(rx, amd_tag), re.match(rx, arm_tag) + return f"rebase-{match_amd['version_stream']}_amd64-{match_amd['date']}_arm64-{match_arm['date']}" + + +def cleanup_branches(gh_repo): + logging.info("Cleaning up branches for closed PRs") + rebase_branches = [b for b in gh_repo.get_branches() if b.name.startswith("rebase-4")] + deleted_branches = [] + for branch in rebase_branches: + prs = gh_repo.get_pulls(head=f"{gh_repo.owner.login}:{branch.name}", state="all") + all_prs_are_closed = all([pr.state == "closed" for pr in prs]) + logging.info(f"'{branch.name}' is referenced in following PRs: " + ", ".join([f"#{pr.number} ({pr.state})" for pr in prs])) + if all_prs_are_closed: + ref = gh_repo.get_git_ref(f"heads/{branch.name}") + if REMOTE_DRY_RUN: + logging.info(f"[DRY RUN] Delete '{ref.ref}'") + deleted_branches.append(branch.name) + else: + try: + ref.delete() + logging.info(f"Deleted '{ref.ref}'") + deleted_branches.append(branch.name) + except GithubException as e: + logging.warning(f"Failed to delete '{ref.ref}' because: {e}") + _extra_msgs.append(f"Failed to delete '{ref.ref}' because: {e}") + + if len(deleted_branches) != 0: + _extra_msgs.append(f"Deleted following branches: " + ", ".join(deleted_branches)) + + +def get_token(org, repo): + """ + Returns a token to be used with GitHub API. + It's either Personal Access Token if TOKEN env is set, + or Installation Access Token which is intended to be used with GitHub Apps. + """ + personal_access_token = try_get_env(PAT_ENV, die=False) + if personal_access_token != "": + logging.info("Using Personal Access Token to access GitHub API") + return personal_access_token + + app_id = try_get_env(APP_ID_ENV) + key_path = try_get_env(KEY_ENV) + return get_installation_access_token(app_id, key_path, org, repo) + + +def main(): + org = try_get_env(ORG_ENV) + repo = try_get_env(REPO_ENV) + release_amd = try_get_env(AMD64_RELEASE_ENV) + release_arm = try_get_env(ARM64_RELEASE_ENV) + base_branch_override = try_get_env(BASE_BRANCH_ENV, die=False) + + global REMOTE_DRY_RUN + REMOTE_DRY_RUN = False if try_get_env(DRY_RUN_ENV, die=False) == "" else True + if REMOTE_DRY_RUN: + logging.info("Dry run mode") + + token = get_token(org, repo) + gh_repo = Github(token).get_repo(f"{org}/{repo}") + git_repo = Repo('.') + base_branch = (git_repo.active_branch.name + if base_branch_override == "" + else base_branch_override) + + rebase_result = run_rebase_sh(release_amd, release_arm) + if rebase_result.success: + # TODO How can we inform team that rebase job ran successfully just there was nothing new? + make_sure_rebase_script_created_new_commits_or_exit(git_repo, base_branch) + if rebase_script_made_changes_considered_functional(git_repo, base_branch): + logging.info("Detected functional changes made by rebase script - proceeding with creating PR") + else: + logging.info("Rebase did not produce any change considered to be functional - quiting") + sys.exit(0) + else: + logging.warning("Rebase script failed - everything will be committed") + with open('rebase_sh.log', 'w') as writer: + writer.write(rebase_result.output) + if git_repo.active_branch.name == base_branch: + # rebase.sh didn't reach the step that would create a branch + # so script needs to create it + branch = git_repo.create_head(get_expected_branch_name(release_amd, release_arm)) + branch.checkout() + git_repo.git.add(A=True) + git_repo.index.commit("rebase.sh failure artifacts") + + rebase_branch_name = git_repo.active_branch.name + git_remote = get_remote_with_token(git_repo, token, org, repo) + remote_branch = try_get_rebase_branch_ref_from_remote(git_remote, rebase_branch_name) # {BOT_REMOTE_NAME}/{rebase_branch_name} + + rbranch_does_not_exists = remote_branch == None + rbranch_exists_and_needs_update = ( + remote_branch != None and + is_local_branch_based_on_newer_base_branch_commit(git_repo, base_branch, remote_branch.name, rebase_branch_name) + ) + if rbranch_does_not_exists or rbranch_exists_and_needs_update: + push_branch_or_die(git_remote, rebase_branch_name) + + prow_job_url = try_create_prow_job_url() + pr_title = create_pr_title(rebase_branch_name, rebase_result.success) + desc = generate_pr_description(rebase_branch_name, get_release_tag(release_amd), get_release_tag(release_arm), prow_job_url, rebase_result.success) + + comment = "" + pr = try_get_pr(gh_repo, org, base_branch, rebase_branch_name) + if pr == None: + pr = create_pr(gh_repo, base_branch, rebase_branch_name, pr_title, desc) + else: + update_pr(pr, pr_title, desc) + comment = f"Rebase job updated the branch\n{desc}" + + if base_branch == "main": + cleanup_branches(gh_repo) + post_comment(pr, comment) + + git_remote.remove(git_repo, BOT_REMOTE_NAME) + sys.exit(0 if rebase_result.success else 1) + + +if __name__ == "__main__": + main() diff --git a/scripts/auto-rebase/rebase.sh b/scripts/auto-rebase/rebase.sh index 8385b2d527..57084f90d2 100755 --- a/scripts/auto-rebase/rebase.sh +++ b/scripts/auto-rebase/rebase.sh @@ -59,7 +59,7 @@ clone_repo() { git init "${repodir}" pushd "${repodir}" >/dev/null git remote add origin "${repo}" - git fetch origin --filter=tree:0 --tags "${commit}" + git fetch origin --quiet --filter=tree:0 --tags "${commit}" git checkout "${commit}" popd >/dev/null } @@ -539,6 +539,9 @@ update_manifests() { # The following manifests are just MicroShift specific and are not present in any other OpenShift repo. # - assets/core/securityv1-local-apiservice.yaml (local API service for security API group, needed if OpenShift API server is not present) + yq -i 'with(.admission.pluginConfig.PodSecurity.configuration.defaults; + .enforce = "restricted" | .audit = "restricted" | .warn = "restricted" | + .enforce-version = "latest" | .audit-version = "latest" | .warn-version = "latest")' "${REPOROOT}"/assets/controllers/kube-apiserver/defaultconfig.yaml yq -i 'del(.extendedArguments.pv-recycler-pod-template-filepath-hostpath)' "${REPOROOT}"/assets/controllers/kube-controller-manager/defaultconfig.yaml yq -i 'del(.extendedArguments.pv-recycler-pod-template-filepath-nfs)' "${REPOROOT}"/assets/controllers/kube-controller-manager/defaultconfig.yaml yq -i 'del(.extendedArguments.flex-volume-plugin-dir)' "${REPOROOT}"/assets/controllers/kube-controller-manager/defaultconfig.yaml @@ -560,7 +563,7 @@ update_manifests() { # 1) Adopt resource manifests # Replace all openshift-dns operand manifests rm -f "${REPOROOT}"/assets/components/openshift-dns/dns/* - cp "${STAGING_DIR}"/cluster-dns-operator/assets/dns/* "${REPOROOT}"/assets/components/openshift-dns/dns || true + cp "${STAGING_DIR}"/cluster-dns-operator/assets/dns/* "${REPOROOT}"/assets/components/openshift-dns/dns || true rm -f "${REPOROOT}"/assets/components/openshift-dns/node-resolver/* cp "${STAGING_DIR}/"cluster-dns-operator/assets/node-resolver/* "${REPOROOT}"/assets/components/openshift-dns/node-resolver || true # Restore the openshift-dns ConfigMap. It's content is the Corefile that the operator generates diff --git a/scripts/auto-rebase/rebase_job_entrypoint.sh b/scripts/auto-rebase/rebase_job_entrypoint.sh index f6e6158380..478edca6fa 100755 --- a/scripts/auto-rebase/rebase_job_entrypoint.sh +++ b/scripts/auto-rebase/rebase_job_entrypoint.sh @@ -12,20 +12,20 @@ cp /secrets/ci-pull-secret/.dockercfg "$HOME/.pull-secret.json" || { echo "WARN: Could not copy registry secret file" } -release_amd64="$(oc get configmap/release-release-images-nightly-amd64 -o yaml \ - | yq '.data."release-images-nightly-amd64.yaml"' \ - | jq -r '.metadata.name')" -release_arm64="$(oc get configmap/release-release-images-nightly-arm64 -o yaml \ - | yq '.data."release-images-nightly-arm64.yaml"' \ - | jq -r '.metadata.name')" +release_amd64="$(oc get configmap/release-release-images-nightly-amd64 -o yaml | + yq '.data."release-images-nightly-amd64.yaml"' | + jq -r '.metadata.name')" +release_arm64="$(oc get configmap/release-release-images-nightly-arm64 -o yaml | + yq '.data."release-images-nightly-arm64.yaml"' | + jq -r '.metadata.name')" pullspec_release_amd64="registry.ci.openshift.org/ocp/release:${release_amd64}" pullspec_release_arm64="registry.ci.openshift.org/ocp-arm64/release-arm64:${release_arm64}" -./scripts/auto-rebase/rebase.sh to "${pullspec_release_amd64}" "${pullspec_release_arm64}" - APP_ID=$(cat /secrets/pr-creds/app_id) \ KEY=/secrets/pr-creds/key.pem \ -ORG=openshift \ -REPO=microshift \ -./scripts/auto-rebase/create_pr.py +ORG=${ORG:-openshift} \ +REPO=${REPO:-microshift} \ +AMD64_RELEASE=${pullspec_release_amd64} \ +ARM64_RELEASE=${pullspec_release_arm64} \ + ./scripts/auto-rebase/rebase.py