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
16 changes: 7 additions & 9 deletions REBASE.openshift.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,8 @@ The following repositories have been already bumped as well:

<URLs to api/client-go/library-go/apiserver-library-go/operators>

Followup work has been assigned to appropriate teams
through bugzillas linked in the code. Please treat
them as the highest priority after landing the bump.
A Jira ticket has been opened for the rebase process.
It has been linked to the pull request.

Finally, this means we are blocking ALL PRs to our
kubernetes fork.
Expand Down Expand Up @@ -518,19 +517,18 @@ The above steps are available as a script that will merge and rebase along the h
resolution and at the end will create a PR for you.

Here are the steps:
1. Create a new BugZilla with the respective OpenShift version to rebase (Target Release stays ---),
Prio&Severity to High with a proper description of the change logs.
See [BZ2021468](https://bugzilla.redhat.com/show_bug.cgi?id=2021468) as an example.
1. Create a new Jira ticket under OCPBUGS with the respective OpenShift version to rebase,
Target Backport Version to the previous minor version + .z
2. It's best to start off with a fresh fork of [openshift/kubernetes](https://github.com/openshift/kubernetes/). Stay on the master branch.
3. This script requires `jq`, `git`, `podman` and `bash`, `gh` is optional.
4. In the root dir of that fork run:
```
openshift-hack/rebase.sh --k8s-tag=v1.25.2 --openshift-release=release-4.12 --bugzilla-id=2003027
openshift-hack/rebase.sh --k8s-tag=v1.25.2 --openshift-release=release-4.12 --jira-id=OCPBUGS-90150
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.

where `k8s-tag` is the [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes/) release tag, the `openshift-release`
is the OpenShift release branch in [openshift/kubernetes](https://github.com/openshift/kubernetes/) and the `bugzilla-id` is the
BugZilla ID created in step (1).
is the OpenShift release branch in [openshift/kubernetes](https://github.com/openshift/kubernetes/) and the `jira-id` is the
Jira ticket number created in step (1).

5. In case of conflicts, it will ask you to step into another shell to resolve those. The script will continue by committing the resolution with `UPSTREAM: <drop>`.
6. At the end, there will be a "rebase-$VERSION" branch pushed to your fork.
Expand Down
45 changes: 26 additions & 19 deletions openshift-hack/rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
#
# The usage is described in /Rebase.openshift.md.

# validate input args --k8s-tag=v1.21.2 --openshift-release=release-4.8 --bugzilla-id=2003027
# validate input args --k8s-tag=v1.21.2 --openshift-release=release-4.8 --jira-id=OCPBUGS-91759
k8s_tag=""
openshift_release=""
bugzilla_id=""
jira_id=""

usage() {
echo "Available arguments:"
echo " --k8s-tag (required) Example: --k8s-tag=v1.21.2"
echo " --openshift-release (required) Example: --openshift-release=release-4.8"
echo " --bugzilla-id (optional) creates new PR against openshift/kubernetes:${openshift-release}: Example: --bugzilla-id=2003027"
echo " --jira-id (optional) Include Jira ticket in PR title: Example: --jira-id=OCPBUGS-1234"
}

for i in "$@"; do
Expand All @@ -33,8 +33,8 @@ for i in "$@"; do
openshift_release="${i#*=}"
shift
;;
--bugzilla-id=*)
bugzilla_id="${i#*=}"
--jira-id=*)
jira_id="${i#*=}"
shift
;;
*)
Expand All @@ -61,7 +61,7 @@ fi
echo "Processed arguments are:"
echo "--k8s_tag=${k8s_tag}"
echo "--openshift_release=${openshift_release}"
echo "--bugzilla_id=${bugzilla_id}"
echo "--jira_id=${jira_id}"

# prerequisites (check git, podman, ... is present)
if ! command -v git &>/dev/null; then
Expand Down Expand Up @@ -98,9 +98,13 @@ git fetch upstream --tags -f
git remote add openshift git@github.com:openshift/kubernetes.git
git fetch openshift

#git checkout --track "openshift/$openshift_release"
git checkout --track "openshift/$openshift_release"
git pull openshift "$openshift_release"

if [ -z "$(git tag -l "$k8s_tag")" ]; then
echo "No such tag exists in upstream for: $k8s_tag"
exit 1
fi
git merge "$k8s_tag"
Comment thread
JSampsonIV marked this conversation as resolved.
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
Expand All @@ -125,25 +129,30 @@ fi

# openshift-hack/images/hyperkube/Dockerfile.rhel still has FROM pointing to old tag
# we need to remove the prefix "v" from the $k8s_tag to stay compatible
sed -i -E "s/(io.openshift.build.versions=\"kubernetes=)(1.[1-9]+.[1-9]+)/\1${k8s_tag:1}/" openshift-hack/images/hyperkube/Dockerfile.rhel
podman run --rm -v "$(pwd):/workspace:Z" alpine:latest \
sed -i -E "s/(io.openshift.build.versions=\"kubernetes=)(1.[1-9]+.[1-9]+)/\1${k8s_tag:1}/" \
/workspace/openshift-hack/images/hyperkube/Dockerfile.rhel
go_mod_go_ver=$(grep -E 'go 1\.[1-9][0-9]?' go.mod | sed -E 's/go (1\.[1-9][0-9]?)/\1/' | cut -d '.' -f 1,2) # Need to handle mod versions like 1.23 and 1.23.4; our release images only have major.minor
tag="rhel-8-release-golang-${go_mod_go_ver}-openshift-${openshift_release#release-}"

# update openshift go.mod dependencies
sed -i -E "/=>/! s/(\tgithub.com\/openshift\/[a-z|-]+) (.*)$/\1 $openshift_release/" go.mod
tag=$(grep "^ tag:" .ci-operator.yaml | head -n1 | sed -E 's/.*: (.*)/\1/')

echo "> go mod tidy && hack/update-vendor.sh"
podman run -it --rm -v "$(pwd):/go/k8s.io/kubernetes:Z" \
--workdir=/go/k8s.io/kubernetes \
"registry.ci.openshift.org/openshift/release:$tag" \
go mod tidy && hack/update-vendor.sh
/bin/bash -c "go mod tidy && hack/update-vendor.sh"

# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "updating the vendor folder failed, is any dependency missing?"
exit 1
fi

echo "> make clean to remove stale _output directory"
podman run -it --rm -v "$(pwd):/go/k8s.io/kubernetes:Z" \
--workdir=/go/k8s.io/kubernetes \
"registry.ci.openshift.org/openshift/release:$tag" \
make clean

podman run -it --rm -v "$(pwd):/go/k8s.io/kubernetes:Z" \
--workdir=/go/k8s.io/kubernetes \
"registry.ci.openshift.org/openshift/release:$tag" \
Expand All @@ -158,18 +167,16 @@ git push origin "$openshift_release:$remote_branch"
XY=$(echo "$k8s_tag" | sed -E "s/v(1\.[0-9]+)\.[0-9]+/\1/")
ver=$(echo "$k8s_tag" | sed "s/\.//g")
link="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-$XY.md#$ver"
if [ -n "${bugzilla_id}" ]; then
if [ -n "${jira_id}" ]; then
if command -v gh &>/dev/null; then
XY=$(echo "$k8s_tag" | sed -E "s/v(1\.[0-9]+)\.[0-9]+/\1/")
ver=$(echo "$k8s_tag" | sed "s/\.//g")
link="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-$XY.md#$ver"

# opens a web browser, because we can't properly create PRs against remote repositories with the GH CLI (yet):
# https://github.com/cli/cli/issues/2691
gh pr create \
--title "Bug $bugzilla_id: Rebase $k8s_tag" \
--title "$jira_id: Rebase $k8s_tag in $openshift_release" \
--body "CHANGELOG $link" \
--web

--base "$openshift_release" \
--head "$remote_branch"
fi
fi