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

Add Periodic MetalLB Bump workflow #341

Merged
merged 2 commits into from
May 9, 2023

Conversation

liornoy
Copy link
Contributor

@liornoy liornoy commented Apr 3, 2023

This commit adds a new workflow to periodically align
with the upstream MetalLB repository.

This is setup to run daily at 7AM and 7PM (GMT+2 clock),
run the make bump_metallb and if differences exist,
then open a PR with the bump,
and on the commit message added details of the old commit,
and the new commit, just so it will be easier
for developers to maintain and keep track of changes.

Created metallb_ref.txt as the single source of truth for
the metallb commit hash.

Also deleted the make test from the bump_metallb, because we want
the workflow not to fail and to open PR even if the unit tests are
failing, so we could catch and fix that.

Notice: Every time this workflow runs it fetches latest metallb
and force-push to already open PR under the "bumpmetallb" branch.

Signed-off-by: liornoy lnoy@redhat.com

@@ -256,7 +256,6 @@ bump_metallb: ## Bumps metallb commit ID and creates manifests. It also validate
hack/bump_metallb.sh
$(MAKE) bin
$(MAKE) bundle-release
$(MAKE) test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this was removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Also deleted the make test from the bump_metallb, because we want the workflow not to fail and to open PR even if the unit tests are failing, so we could catch and fix that."

commit-message: |
Bump MetalLB

This commit bumps MetalLB from `${{ steps.old-commit-info.outputs.commit_sha }}` to `${{ steps.new-commit-info.outputs.commit_sha }}`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to close any existing already opened pr?
Thinking about a scenario where we bump metallb multiple times but we wait to bump the operator.
Ideally, only the most recent one should be open

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that could be nice. Need to figure out how to query the open PR and check if it should be kept or closed.

Copy link
Contributor Author

@liornoy liornoy Apr 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fedepaol the workflow will periodically override old PRs with the latest metallb. so I think it could work for us.

@liornoy liornoy force-pushed the add-bump-metallb-automation branch from ac0f8be to a986206 Compare April 16, 2023 14:41
@mlguerrero12
Copy link
Contributor

please remove the .idea/workspace.xml file. It'd be nice if we add it to .gitignore

@liornoy
Copy link
Contributor Author

liornoy commented Apr 19, 2023

please remove the .idea/workspace.xml file. It'd be nice if we add it to .gitignore

sure will do.

@liornoy liornoy force-pushed the add-bump-metallb-automation branch 2 times, most recently from 6357ccd to 887f44e Compare April 19, 2023 16:41
@liornoy
Copy link
Contributor Author

liornoy commented Apr 19, 2023

@fedepaol I pushed my working workflow to here, running twice a day.
regarding your comment about closing existing pr and having only the latest -
I found out that this workflow is going to force-push to an existing PR, so it will
update to the latest on its own.

BUT for this to work we must create a dedicated personal auth token for metallb
with the permission for "workflows" - and that is required because during the bump we
update the metallb_e2e.yml workflow and that requires a non-default token.
I named the secret "PAT" here, so you'll need to create that secret with this name holding the token
with the "workflows" permissions.

@liornoy
Copy link
Contributor Author

liornoy commented Apr 23, 2023

Also, note that I count on us being able to checkout into the automated sync PR and resolve conflicts if need with force-push.

@fedepaol
Copy link
Member

fedepaol commented May 8, 2023

@fedepaol I pushed my working workflow to here, running twice a day. regarding your comment about closing existing pr and having only the latest - I found out that this workflow is going to force-push to an existing PR, so it will update to the latest on its own.

BUT for this to work we must create a dedicated personal auth token for metallb with the permission for "workflows" - and that is required because during the bump we update the metallb_e2e.yml workflow and that requires a non-default token. I named the secret "PAT" here, so you'll need to create that secret with this name holding the token with the "workflows" permissions.

Sorry for the delay. There's one thing that I am maybe missing. This won't bump anything, it will just file a pr. So, why the token is required? And if it is required because we change it on a local branch, can we change the workflow so it will read from a file (which we can treat as the source of truth) so we can avoid the extra permission?

@liornoy
Copy link
Contributor Author

liornoy commented May 8, 2023

@fedepaol I pushed my working workflow to here, running twice a day. regarding your comment about closing existing pr and having only the latest - I found out that this workflow is going to force-push to an existing PR, so it will update to the latest on its own.
BUT for this to work we must create a dedicated personal auth token for metallb with the permission for "workflows" - and that is required because during the bump we update the metallb_e2e.yml workflow and that requires a non-default token. I named the secret "PAT" here, so you'll need to create that secret with this name holding the token with the "workflows" permissions.

Sorry for the delay. There's one thing that I am maybe missing. This won't bump anything, it will just file a pr. So, why the token is required? And if it is required because we change it on a local branch, can we change the workflow so it will read from a file (which we can treat as the source of truth) so we can avoid the extra permission?

it won't just file a pr. it will run the metallb bump script that includes the bin and bundle-release.
see example: https://github.com/liornoy/metallb-operator/pull/43/files.

Regarding the special token, we need that for allowing this workflow to change the metallb ref under
.github/workflows/metallb_e2e.yml which is a key part of this metallb bump procedure
I don't understand how reading a file will replace the extra permission.

@liornoy
Copy link
Contributor Author

liornoy commented May 8, 2023

Adding an example of how an auto-gen bump MetalLB PR will look like: liornoy#43

@fedepaol
Copy link
Member

fedepaol commented May 8, 2023

Regarding the special token, we need that for allowing this workflow to change the metallb ref under .github/workflows/metallb_e2e.yml which is a key part of this metallb bump procedure I don't understand how reading a file will replace the extra permission.

The reason for changing the e2e workflow is because the commit id is embedded in the file. What I am suggesting here is, change the workflow so that it reads a file. In this way the pr will bump the file instead of the workflow and we'll avoid the extra permission.

@fedepaol
Copy link
Member

fedepaol commented May 8, 2023

it won't just file a pr. it will run the metallb bump script that includes the bin and bundle-release. see example: https://github.com/liornoy/metallb-operator/pull/43/files.

But it won't bump it directly on main right? It will file a pr with the bump so we can just accept it as in liornoy#43 ?

@liornoy
Copy link
Contributor Author

liornoy commented May 8, 2023

Regarding the special token, we need that for allowing this workflow to change the metallb ref under .github/workflows/metallb_e2e.yml which is a key part of this metallb bump procedure I don't understand how reading a file will replace the extra permission.

The reason for changing the e2e workflow is because the commit id is embedded in the file. What I am suggesting here is, change the workflow so that it reads a file. In this way the pr will bump the file instead of the workflow and we'll avoid the extra permission.

oh I get it. will do.

@liornoy
Copy link
Contributor Author

liornoy commented May 8, 2023

it won't just file a pr. it will run the metallb bump script that includes the bin and bundle-release. see example: https://github.com/liornoy/metallb-operator/pull/43/files.

But it won't bump it directly on main right? It will file a pr with the bump so we can just accept it as in liornoy#43 ?

yes. under "bumpmetallb" branch

@liornoy liornoy force-pushed the add-bump-metallb-automation branch 2 times, most recently from 7b05bfe to 5c45334 Compare May 8, 2023 14:05
@liornoy
Copy link
Contributor Author

liornoy commented May 8, 2023

Regarding the special token, we need that for allowing this workflow to change the metallb ref under .github/workflows/metallb_e2e.yml which is a key part of this metallb bump procedure I don't understand how reading a file will replace the extra permission.

The reason for changing the e2e workflow is because the commit id is embedded in the file. What I am suggesting here is, change the workflow so that it reads a file. In this way the pr will bump the file instead of the workflow and we'll avoid the extra permission.

@fedepaol Done

@liornoy
Copy link
Contributor Author

liornoy commented May 8, 2023

I just realised that I don't must use this github action to read the metallb ref file, but just use a "run" block with bash script.
I'll update it soon

@liornoy liornoy force-pushed the add-bump-metallb-automation branch from 5c45334 to 3b6c179 Compare May 9, 2023 09:02
This commit adds a new workflow to periodically align
with the upstream MetalLB repository.

This is setup to run daily at 7AM and 7PM (GMT+2 clock),
run the make `bump_metallb` and if differences exist,
then open a PR with the bump,
and on the commit message added details of the old commit,
and the new commit, just so it will be easier
for developers to maintain and keep track of changes.

Created metallb_ref.txt as single source of truth for
the metallb commit hash.

Also deleted the `make test` from the bump_metallb, because we want
the workflow not to fail and to open PR even if the unit tests are
failing, so we could catch and fix that.

Notice: Every time this workflow runs it fetches latest metallb
and force-push to already open pr under the "bumpmetallb" branch.

Signed-off-by: liornoy <lnoy@redhat.com>
This commit adds .idea/ to the .gitignore
in order to help developers using Goland.

Signed-off-by: liornoy <lnoy@redhat.com>
@liornoy liornoy force-pushed the add-bump-metallb-automation branch from 3b6c179 to 66ade5e Compare May 9, 2023 09:06
- name: Checkout MetalLB
uses: actions/checkout@v2
with:
repository: metallb/metallb
path: metallb
ref: 1424dbaef1313b8bb20df136e8eacd2dbacdae02
ref: "${{ steps.metallb_ref.outputs.content }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

@fedepaol
Copy link
Member

fedepaol commented May 9, 2023

lgtm

@liornoy
Copy link
Contributor Author

liornoy commented May 9, 2023

It failed because of the BGP large communities commit.
And the fact that it's not currently aligned to latest metallb

@liornoy
Copy link
Contributor Author

liornoy commented May 9, 2023

@fedepaol do you want me to add another commit to bump metallb to be aligned?
or let's merge it like that and see at 19:00 how the PR looks like when there is a difference in the commit ref?

@fedepaol fedepaol merged commit 7b1bdfa into metallb:main May 9, 2023
@fedepaol
Copy link
Member

fedepaol commented May 9, 2023

Merged. Let's see if it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants