Skip to content

Failed gh release create with files leaves behind a draft release #6645

Description

@mkolesnik

Describe the bug

Sometimes gh release create with files fails due to upload errors. When it does, the draft release gets left behind.

Steps to reproduce the behavior

  1. Run gh release create with files
  2. If it failed, observe the draft release still on the repo

Expected vs actual behavior

Expected the draft release to be deleted in such a case (or at least CLI should attempt to delete it).
Actual behavior is the draft release left behind and needing to be manually deleted.

Logs

We retry failed releases in our jobs - https://github.com/submariner-io/releases/actions/runs/3491034412/jobs/5843200596#step:4:536

Attempt 1/3 to run 'dryrun gh release create v0.14.0-rc4 projects/subctl/dist/subctl-v0.14.0-rc4-darwin-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-ppc64le.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-s390x.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-windows-amd64.exe.tar.xz --prerelease --title 0.14.0-rc4 --repo submariner-io/releases --target 028e897467e763af21965593387796a99ab3a1ec'
[18:56:13.824] [dir=releases; fn=dryrun]$ gh release create v0.14.0-rc4 projects/subctl/dist/subctl-v0.14.0-rc4-darwin-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-ppc64le.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-s390x.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-windows-amd64.exe.tar.xz --prerelease --title 0.14.0-rc4 --repo submariner-io/releases --target 028e897467e763af21965593387796a99ab3a1ec
Post "https://uploads.github.com/repos/submariner-io/releases/releases/83445511/assets?label=&name=subctl-v0.14.0-rc4-windows-amd64.exe.tar.xz": http2: client connection force closed via ClientConn.Close
Attempt 2/3 to run 'dryrun gh release create v0.14.0-rc4 projects/subctl/dist/subctl-v0.14.0-rc4-darwin-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-ppc64le.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-s390x.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-windows-amd64.exe.tar.xz --prerelease --title 0.14.0-rc4 --repo submariner-io/releases --target 028e897467e763af21965593387796a99ab3a1ec'
[18:56:15.543] [dir=releases; fn=dryrun]$ gh release create v0.14.0-rc4 projects/subctl/dist/subctl-v0.14.0-rc4-darwin-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-ppc64le.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-s390x.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-windows-amd64.exe.tar.xz --prerelease --title 0.14.0-rc4 --repo submariner-io/releases --target 028e897467e763af21965593387796a99ab3a1ec
Post "https://uploads.github.com/repos/submariner-io/releases/releases/83445512/assets?label=&name=subctl-v0.14.0-rc4-linux-arm64.tar.xz": unexpected EOF
Attempt 3/3 to run 'dryrun gh release create v0.14.0-rc4 projects/subctl/dist/subctl-v0.14.0-rc4-darwin-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-ppc64le.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-s390x.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-windows-amd64.exe.tar.xz --prerelease --title 0.14.0-rc4 --repo submariner-io/releases --target 028e897467e763af21965593387796a99ab3a1ec'
[18:56:18.020] [dir=releases; fn=dryrun]$ gh release create v0.14.0-rc4 projects/subctl/dist/subctl-v0.14.0-rc4-darwin-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-amd64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-arm64.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-ppc64le.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-linux-s390x.tar.xz projects/subctl/dist/subctl-v0.14.0-rc4-windows-amd64.exe.tar.xz --prerelease --title 0.14.0-rc4 --repo submariner-io/releases --target 028e897467e763af21965593387796a99ab3a1ec
https://github.com/submariner-io/releases/releases/tag/v0.14.0-rc4

The releases page (we will delete the drafts, so I took a screenshot):
image

Activity

  1. added
    discussFeature changes that require discussion primarily among the GitHub CLI team
    and removed on Nov 21, 2022
  2. added
    priority-3Affects a small number of users or is largely cosmetic
    and removed
    discussFeature changes that require discussion primarily among the GitHub CLI team
    on Nov 21, 2022
  3. mislav commented on Nov 21, 2022

    @mislav
    Contributor

    Hi, thank you for reporting, and agreed that creating a draft release first (and then uploading files to it) is an implementation detail of gh release create <files>... and that when the operation fails, it shouldn't leave unexpected artifacts behind.

    However, would you say that gh release create <files>... could have a better retry mechanism built in so that uploads are retried automatically within gh and that your automation doesn't have to do it?

    We already have some rudimentary retry logic, but we could expand it to also handle the types of errors you are experiencing:

    _, err := uploadAsset(httpClient, uploadURL, a)
    // retry upload several times upon receiving HTTP 5xx
    if err == nil || !errors.As(err, &httpError) || httpError.StatusCode < 500 || retries < maxRetries {
    return err
    }
    retries++
    time.Sleep(time.Duration(retries) * time.Second)

    Ref. https://github.com/golang/net/blob/ecf7fda6a59edbedc58c1207f55285a9ad98e10a/http2/transport.go#L1130

    Ref. io.ErrUnexpectedEOF https://pkg.go.dev/io#pkg-variables

  4. mkolesnik commented on Nov 22, 2022

    @mkolesnik
    Author

    Thanks @mislav , it would be very useful if file uploads could be retried automatically more thoroughly.
    I think the draft release should still be deleted in case of failure to create the release with the files.

    Do you want me to report a separate issue for retrying file uploads?

  5. mislav commented on Nov 22, 2022

    @mislav
    Contributor

    @mkolesnik Sure! Let's treat retrying logic as a separate issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions welcomepriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions