Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

krel: Merge any commits in the remote branch before push #2128

Merged
merged 1 commit into from
Jun 17, 2021

Conversation

puerco
Copy link
Member

@puerco puerco commented Jun 17, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

To prevent divergent branches, we now fetch the remote and merge any commits found at the origin before pushing release branches.

Signed-off-by: Adolfo García Veytia (Puerco) [email protected]

Which issue(s) this PR fixes:

Special notes for your reviewer:

Please take a good look at the change and if you think of a way to test it in gcb lets do it.

When running on release, krel will merge the commits from the remote branch if it finds any. It will create a merge commit. The image below is from my local test with the code of the PR in this branch:

https://github.com/puerco/lab/commits/release-1.16

The following graph shows the result. The commits at the top were made in github directly, those on the bottom on my local machine:

image

The code to test it:

package main

import (
	"github.com/sirupsen/logrus"
	"k8s.io/release/pkg/release"
)

func main() {
	pusher, err := release.NewGitPusher(&release.GitObjectPusherOptions{
		DryRun:     false,
		MaxRetries: 0,
		RepoPath:   "/path/to/repo",
	})
	if err != nil {
		logrus.Fatal(err)
	}
	if err := pusher.PushBranch("release-1.16"); err != nil {
		logrus.Fatal(err)
	}
	logrus.Info("Pushed")
}

/assign @saschagrunert @xmudrii
/priority critical-urgent
/milestone v1.22
/cc @kubernetes/release-engineering

Does this PR introduce a user-facing change?

When running release from a non-main branch, krel will now merge any commits before pushing the branch back to github, avoiding conflicts due to divergent branches. 

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. labels Jun 17, 2021
@k8s-ci-robot k8s-ci-robot requested a review from a team June 17, 2021 07:01
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone Jun 17, 2021
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 17, 2021
To prevent divergent branches, we now fetch the remote and
merge any commits found at the origin before pushing release
branches.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@puerco puerco force-pushed the merge-unexpected-commits branch from d949364 to 8096998 Compare June 17, 2021 07:05
@saschagrunert
Copy link
Member

Testing manually for the latest 1.19 staged sources:

> export TOOL_ORG=puerco TOOL_REF=merge-unexpected-commits && \
    go run ./cmd/krel release --type=official --branch=release-1.19 \
        --build-version=v1.19.12-rc.0.48+5dd397c4514b63

https://console.cloud.google.com/cloud-build/builds/c2cc13dd-28ac-4557-80c2-479d7f9d28a5?project=648026197307

@saschagrunert
Copy link
Member

saschagrunert commented Jun 17, 2021

Looking good:

Step #3: INFO[2021-06-17T07:49:55Z] Verifying release-1.19 branch exists in the repo 
Step #3: INFO[2021-06-17T07:49:55Z] Branch release-1.19 found in the repository  
Step #3: INFO[2021-06-17T07:49:55Z] Checking out branch release-1.19 to merge upstream changes 
Step #3: INFO[2021-06-17T07:49:56Z] Fetching origin                              
Step #3: INFO[2021-06-17T07:50:00Z] Merging origin/release-1.19                    

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 17, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: puerco, saschagrunert, xmudrii

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit e8b49f0 into kubernetes:master Jun 17, 2021
xmudrii added a commit to xmudrii/release that referenced this pull request Dec 8, 2021
This commit is a revert of the following PRs:
kubernetes#2128
kubernetes#2131

The reason why we are reverting this change is that merging on the main
(master) branch can cause the git mainline to end up in an undesired
state (i.e. it can become not straight). This can cause publishing-bot
to stop working or to miss commits around the release.

This issue can occur if there are merges between starting the stage
and running the release step. This often happens on the master
branch, especially when there's no code freeze in the effect
(e.g. for alpha/beta releases).

Signed-off-by: Marko Mudrinić <[email protected]>
xmudrii added a commit to xmudrii/release that referenced this pull request Dec 8, 2021
This commit is a revert of the following PRs:
kubernetes#2128
kubernetes#2131

The reason why we are reverting this change is that merging on the main
(master) branch can cause the git mainline to end up in an undesired
state (i.e. it can become not straight). This can cause publishing-bot
to stop working or to miss commits around the release.

This issue can occur if there are merges between starting the stage
and running the release step. This often happens on the master
branch, especially when there's no code freeze in the effect
(e.g. for alpha/beta releases).

Signed-off-by: Marko Mudrinić <[email protected]>
xmudrii added a commit to xmudrii/release that referenced this pull request Dec 8, 2021
This commit is a revert of the following PRs:
kubernetes#2128
kubernetes#2131

The reason why we are reverting this change is that merging on the main
(master) branch can cause the git mainline to end up in an undesired
state (i.e. it can become not straight). This can cause publishing-bot
to stop working or to miss commits around the release.

This issue can occur if there are merges between starting the stage
and running the release step. This often happens on the master
branch, especially when there's no code freeze in the effect
(e.g. for alpha/beta releases).

Signed-off-by: Marko Mudrinić <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/release Categorizes an issue or PR as relevant to SIG Release. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants