From 111b74ab8ee280b2dfe9e93b047d839d83d97cf1 Mon Sep 17 00:00:00 2001 From: Manases Leal Date: Mon, 14 Nov 2022 15:08:38 -0600 Subject: [PATCH 1/6] Added Exponential backoff retry to resourceTopicCreate --- client/topic.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/client/topic.go b/client/topic.go index 7329ed9..87e2754 100644 --- a/client/topic.go +++ b/client/topic.go @@ -6,6 +6,8 @@ import ( "fmt" "net/http" "strconv" + "time" + "math" ) type Topics struct { @@ -149,10 +151,23 @@ func createTopic(c Client, t *NewTopic) (*Topic, error) { return nil, err } - res, err := c.doRequest(req) - if err != nil { - return nil, err - } + retryCap := 3 + res, err := c.doRequest(req) + for retry := 1; retry <= retryCap; retry++{ + if err != nil { + fmt.Errorf("%s\n",err) + fmt.Println("Waiting to retry...") + time.Sleep(time.Duration(math.Pow(float64(retry), 2)) * time.Second) + fmt.Printf("Starting retry attempt %d of %d\n", retry, retryCap) + res, err := c.doRequest(req) + _,_ = res, err + } else { + break + } + } + if err != nil { + return nil, err + } var topic Topic err = json.Unmarshal(res, &topic) From 619de5d6a15621b046ef9360f5bb6c46a80c507f Mon Sep 17 00:00:00 2001 From: Manases Leal Date: Wed, 16 Nov 2022 13:28:19 -0600 Subject: [PATCH 2/6] Attempt to fix gpg-agent is already running error --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1176cd1..2a06080 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,8 +16,8 @@ jobs: with: go-version: 1.15.x - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v5 id: import_gpg - uses: hashicorp/ghaction-import-gpg@v2.1.0 env: GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} PASSPHRASE: ${{ secrets.PASSPHRASE }} From b1f1c51cbe0cc248cabb8131c7f3bb181a550e11 Mon Sep 17 00:00:00 2001 From: Manases Leal Date: Wed, 16 Nov 2022 13:47:05 -0600 Subject: [PATCH 3/6] Pasted the updated release.yml --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2a06080..5046804 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,31 +1,51 @@ +# This GitHub action can publish assets for release when a tag is created. +# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0). +# +# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your +# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` +# secret. If you would rather own your own GPG handling, please fork this action +# or use an alternative one for key handling. +# +# You will need to pass the `--batch` flag to `gpg` in your signing step +# in `goreleaser` to indicate this is being used in a non-interactive mode. +# name: release on: push: tags: - 'v*' +permissions: + contents: write jobs: goreleaser: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2.4.0 - - name: Unshallow + - + name: Checkout + uses: actions/checkout@v3 + - + name: Unshallow run: git fetch --prune --unshallow - - name: Set up Go - uses: actions/setup-go@v2 + - + name: Set up Go + uses: actions/setup-go@v3 with: - go-version: 1.15.x - - name: Import GPG key + go-version-file: 'go.mod' + cache: true + - + name: Import GPG key uses: crazy-max/ghaction-import-gpg@v5 id: import_gpg - env: - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - PASSPHRASE: ${{ secrets.PASSPHRASE }} - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2.8.1 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3.2.0 with: version: latest args: release --rm-dist env: GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # GitHub sets this automatically + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From ab1096de41ddca7d3d405df00c28411f05d3b37c Mon Sep 17 00:00:00 2001 From: Manases Leal Date: Wed, 16 Nov 2022 13:52:31 -0600 Subject: [PATCH 4/6] Removed cache: true from yml --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5046804..6d96cc8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,6 @@ jobs: uses: actions/setup-go@v3 with: go-version-file: 'go.mod' - cache: true - name: Import GPG key uses: crazy-max/ghaction-import-gpg@v5 From 14cee9de1c59be4388da1baca463808e067cc630 Mon Sep 17 00:00:00 2001 From: Manases Leal Date: Wed, 16 Nov 2022 14:11:40 -0600 Subject: [PATCH 5/6] Revert release.yml changes and added crazy-max --- .github/workflows/release.yml | 48 ++++++++++------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d96cc8..fee3ae3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,50 +1,30 @@ -# This GitHub action can publish assets for release when a tag is created. -# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0). -# -# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your -# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` -# secret. If you would rather own your own GPG handling, please fork this action -# or use an alternative one for key handling. -# -# You will need to pass the `--batch` flag to `gpg` in your signing step -# in `goreleaser` to indicate this is being used in a non-interactive mode. -# name: release on: push: tags: - 'v*' -permissions: - contents: write jobs: goreleaser: runs-on: ubuntu-latest steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Unshallow + - name: Checkout + uses: actions/checkout@v2.4.0 + - name: Unshallow run: git fetch --prune --unshallow - - - name: Set up Go - uses: actions/setup-go@v3 + - name: Set up Go + uses: actions/setup-go@v2 with: - go-version-file: 'go.mod' - - - name: Import GPG key - uses: crazy-max/ghaction-import-gpg@v5 - id: import_gpg - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.PASSPHRASE }} - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v3.2.0 + go-version: 1.15.x + - name: Import GPG + uses: crazy-max/ghaction-import-gpg@v5.2.0 + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.PASSPHRASE }} + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2.8.1 with: version: latest args: release --rm-dist env: GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} - # GitHub sets this automatically - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a0411fd835c5ca68cea1bc49c7fad180ad4e7774 Mon Sep 17 00:00:00 2001 From: Manases Leal Date: Wed, 16 Nov 2022 14:16:30 -0600 Subject: [PATCH 6/6] Updated crazy-max from v5.2.0 to v5 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fee3ae3..1445669 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: with: go-version: 1.15.x - name: Import GPG - uses: crazy-max/ghaction-import-gpg@v5.2.0 + uses: crazy-max/ghaction-import-gpg@v5 env: GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} PASSPHRASE: ${{ secrets.PASSPHRASE }}