-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix archive for non-existent labels #14
Conversation
The latest Buf updates on your PR.
|
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.
How did we figure out this was an issue?
src/main.ts
Outdated
@@ -279,7 +279,14 @@ async function archive(bufPath: string, inputs: Inputs): Promise<Result> { | |||
for (const label of inputs.archive_labels) { | |||
args.push("--label", label); | |||
} | |||
return run(bufPath, args); | |||
const result = await run(bufPath, args); |
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.
How does the backend behave if we try to archive multiple labels at once and one of the labels doesn't exist. Does the whole RPC atomically fail? If so, I think we want to best effort archive as many labels as possible so I think we might want to make one archive command per label that needs to be archived.
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.
Whats the use case for one to succeed?
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.
not sure I understand your question, can chat tomorrow if you want
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.
If one of the labels doesn't exist it will fail atomically. The default, and the most common case, would be to archive the one label from the delete event. So if multiple tags got deleted at once each event would fire and archive them in separate CI events. If a user overrides and wants multiple events I think failing if one doesn't exist it is correct to fail and we shouldn't try to run them one by one. Happy to chat through.
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.
Ok, so the difference here only matters if the user configured the GHA with one or more extra labels for archiving. Thinking about it now, why do we allow them to configure extra labels for archiving? Not sure that actually makes sense.
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.
We allow configuring more than one label for push, so makes sense if they have a multiple label pattern.
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.
We allow configuring more than one label for push, so makes sense if they have a multiple label pattern.
Ok, yeah makes sense.
If a user overrides and wants multiple events I think failing if one doesn't exist it is correct to fail and we shouldn't try to run them one by one.
Can chat about this live today, but I guess I view archiving state in the BSR as a cleanup task. If the archive task has been configured with let's say 2 labels, and one is valid but the other isn't, wouldn't you as a user prefer that the valid one gets archived even thought the other one doesn't exist?
Whether to mark the job as failed or not if this happens is a separate question, but I would be fine not marking the job has failed because we have asserted some state (i.e. the labels in question have been archived or don't exist)
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.
Passing-by comment: All APIs in v1/v1beta1 are atomic in its implementation, either all of them succeed or all of them fail, no partial success.
It's not explicitly documented in the ArchiveLabels
RPC, but it would be weird having some RPCs that support partial success and others that are atomic. If we go down the path of partial success, we'd probably need a way to communicate in the response which ones were archived and which ones were not found, and it would open the gate to allow partial success for other RPCs like Get*
or Delete*
.
I think another approach, probably much more cumbersome from the client side, but according to the API requirements, is to loop one by one doing Get -> Exists? -> Archive
. That way even if some of the labels exist and some don't, the job doesn't fail.
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.
Correct, I was not suggesting changing the API, I am suggesting changing the implementation here to loop and make multiple calls.
This is an issue from testing. The current bug from #10 is currently obscuring it. We would noticed this for a CI setup with events filtered on push, so not every label is pushed but every delete triggers an archive:
Deletes aren't filterable, so we are required to handle the 404 case either in the action or as part of the CLI. |
Tested both the new default archive label name and handling of non-existent errors.
|
Does this implementation fail the job or not fail the job if one archive fails but others succeed? |
@nicksnyder does not fail the job if one fails for non-exist. Reports the failure in the logs of CI. |
Great, thanks for confirming! |
This PR fixes two issues with the archive step. First is a typo in the default event name of
archive_labels
. This should begithub.event.ref
notgithub.event.ref_name
. The other fix is for more robust handling of multiple non existent labels. Fordelete
events we cannot guarantee the branch or tag is matched to a label in the BSR. We now iterate over all labels and handle missing failures. On a label not existing the archive command will log the failed output but still succeed.