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
add tool for pushing vendor updates to consuming repos easier #687
add tool for pushing vendor updates to consuming repos easier #687
Conversation
/cc @elmiko @JoelSpeed |
hack/push_updates.sh
Outdated
if [ -z "$SHA" ]; then | ||
echo "Determining SHA for machine-api-operator repository..." | ||
hub clone openshift/machine-api-operator | ||
(cd ./machine-api-operator && git checkout origin/$BRANCH_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should not be done in a temporary directory, and additionally cleaned up after completion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a temporary directory, see lines 86-87.
I didn't add a trap to clean it up because @elmiko wanted it to run in a container, and I figured everything would be removed when the container is removed. Maybe that assumption isn't safe or some folks will run this outside of the container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i certainly don't want to see us do extra work just for the container option. that said, it should be relatively safe to leave artifacts in a temporary directory as it will get cleaned by the o/s as needed. additionally it might help for debugging to have the artifacts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It certainly helped while developing the script. :-)
hack/push_updates.sh
Outdated
# Push updates that need to be vendored in other repositories. | ||
|
||
if ! which hub 2>/dev/null 1>&2; then | ||
echo "This tool requires the hub command line app." 1>&2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible just to use git
tool?.. Don't know all the details, but from visual inspection, it is possible to replicate all commandls with git clone
and git remote add ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git can't create the fork if you don't already have it
d07286e
to
f07e150
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks really nice to me, thanks Doug!
definitely think we should get Joel's thoughts, but he is out till next week.
/lgtm
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. My only concern is about the SHA length causing long commit messages and long branch names, should we always truncate to a 7 digit short commit SHA to prevent these long messages? Should still work with short SHAs right?
hack/push_updates.sh
Outdated
-s SHA | ||
The SHA from machine-api-operator repository to push. | ||
Defaults to HEAD of master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a full SHA or will it work with the 7 character short SHA? Might be worth a note in the help if it supports one and not the other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually any reference, but it seemed safer to suggest using a SHA because if you just pass "HEAD" or a branch name then the commit message wouldn't be very meaningful. The short SHA should be OK.
hack/push_updates.sh
Outdated
hub clone openshift/$repo | ||
pushd ./$repo | ||
|
||
hub fork --remote-name $REMOTE_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this succeed if there is already a fork?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it recognizes the fork even if it has a different name and sets up the remote appropriately.
I think I'm happy with this as is now, would be good to see it in action (maybe dry run?) so we can verify it works before merging, what do people think? |
Sure, that makes sense. Do you want me to do that and link to some PRs, or do you want to give it a spin to see how it behaves first hand? /retest |
Just cloned this myself to have a play, not sure how important these are but some observations:
|
Fixed
Fixed
I changed the logic so the fork isn't created in dry-run mode. I think if you create a fork yourself using a different repository name the hub command will use the Github API to figure that out. I could also see if I can make it try a simple clone if the fork fails.
I switched to using the abbreviated hash computed by git instead of truncating it in the script.
|
On second thought, I'm not sure that's actually possible. I wonder if because of the error handling we would actually want the script to run in 2 different phases. First to build all of the patches, and then either a second run to submit them or just leave it up to the user to submit them (and automate submission separately when we put this into a prow job). Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched to using the abbreviated hash computed by git instead of truncating it in the script.
+1 for this
I think the fallback to simple clone looks good, I haven't tested it, but I think it should work. I personally would prefer to keep the script so that it automates the whole thing. If I have to delete some of my forks and have them properly forked from the openshift forks to make that work, I think that's a sacrifice I'd be willing to make.
|
||
# Use -d option to avoid build errors because we aren't going to | ||
# build locally. | ||
go get -d github.com/openshift/machine-api-operator@${FULL_SHA} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think FULL_SHA is initialised when SHA is set explicitly, looks like it's only set when SHA is empty and we work it out in the script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed that, and also split the operation into 2 loops as we discussed in the meeting this morning.
@dhellmann Used the script earlier and it pretty much worked a treat! (https://bugzilla.redhat.com/show_bug.cgi?id=1877743) Had to manually fix one up because they're using a Only thing I will say is that it doens't look like ovirt is in a place where they need this script just yet, might be worth dropping them from the defaults for now. From this experience, future improvement ideas:
|
I think I assumed the GitHub.user setting was part of configuring hub, but apparently not. It looks like the script could read ~/.config/hub instead. At the very least we could have it require the user to set up the git config it's expecting.
Makes sense.
I thought about making it create the working directory with the SHA in the name, so it could find it again later. Then it could skip building the patch if it sees a cloned repo in that predictable temp directory, assuming that the user would have fixed whatever caused the failure before running again. What do you think?
Definitely.
See above |
617aadf
to
fa139d1
Compare
I rebased, squashed, and removed ovirt from the list of repositories. |
/retest |
/approve Thanks @dhellmann |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoelSpeed 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks mostly good to me, just had one question
hack/push-updates.sh
Outdated
|
||
function fork_repo () { | ||
local repo_name="$1" | ||
local remote_name="$2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like remote_name
is unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d'oh, it's using REMOTE_NAME below instead of the local variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i figured it had to be one or the other XD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the extra variable.
fa139d1
to
5d7fbe4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/retest Please review the full test history for this PR and help us cut down flakes. |
12 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/hold This will just keep retesting unnecessarily until it's merged Do we want to get this merged before master opens or do we not really care? |
It doesn't really make any difference to me, so if you'd like to wait that's fine. |
Saves us having to create a BZ, so let's just hold cancel when master opens, we can all use it from here until then |
Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
5d7fbe4
to
fc39af7
Compare
just wanted to note that i tried the script out in dry run mode today and everything is working as i would expect. |
/hold cancel I think this should be able to merge now that the 4.6 branch has been cut 🤔 |
/lgtm |
/retest Please review the full test history for this PR and help us cut down flakes. |
3 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
No description provided.