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

libimage: implement retry logic for manifest push #1666

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

flouthoc
Copy link
Collaborator

manifest push API must implement and leverage retry logic similar to image push with similar defaults.

Closes: #1664

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -28,6 +30,11 @@ import (
"github.com/sirupsen/logrus"
)

const (
defaultMaxRetries = 3
defaultRetryDelay = time.Second
Copy link
Member

Choose a reason for hiding this comment

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

retry.IfNecessary() has a default for this, so it's better to not insert our own.

Copy link
Collaborator Author

@flouthoc flouthoc Sep 27, 2023

Choose a reason for hiding this comment

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

image push retries for 3 times with a delay of 1 second which is hardcoded in libimage/copier but I was unable to find these defaults in retry package https://github.com/containers/common/blob/main/pkg/retry/retry.go

Copy link
Member

Choose a reason for hiding this comment

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

There's a default delay (the godoc for retry.Options.Delay hints at it), but not a default on the number of retries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

libimage/manifests/manifests.go Show resolved Hide resolved
libimage/manifests/manifests.go Outdated Show resolved Hide resolved
libimage/manifests/manifests.go Outdated Show resolved Hide resolved
libimage/manifests/manifests.go Outdated Show resolved Hide resolved

options.RetryDelay = 3 * time.Second
_, _, err = list.Push(ctx, destRef, options)
assert.NoError(t, err, "list.Push(with RetryDelay)")
Copy link
Member

Choose a reason for hiding this comment

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

Is this expected to be testing the new fields in options in combination with the other settings that were already set above? Is it verifying that the new options cause any changes in behavior?

Copy link
Collaborator Author

@flouthoc flouthoc Sep 27, 2023

Choose a reason for hiding this comment

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

@nalind Yes this is only testing field, I expect to do integration test where retry is happening on podman side where it throws warning on every failed retry attempt and success on push to registry.

Copy link
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

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

TestPush() really needs to be expanded, but otherwise LGTM, give or take a non-blocking stylistic nit.

@flouthoc
Copy link
Collaborator Author

Let me extend the test, I think this can be tested here as well.

@flouthoc flouthoc force-pushed the manifest-retry branch 2 times, most recently from 699fa23 to 6d13884 Compare September 28, 2023 08:04
@flouthoc
Copy link
Collaborator Author

Expanded PushTest to actually cover retry attempts by checking warning logs.

@flouthoc
Copy link
Collaborator Author

@nalind PTAL again.

@@ -335,6 +338,30 @@ func TestPushManifest(t *testing.T) {
_, _, err = list.Push(ctx, destRef, options)
assert.Nilf(t, err, "list.Push(four specified)")

bogusDestRef, err := alltransports.ParseImageName("docker://localhost/bogus/dest:latest")
assert.Nilf(t, err, "ParseImageName()")
Copy link
Member

Choose a reason for hiding this comment

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

Probably want to use assert.NoErrorf() here, since we know that err is an error if it isn't nil.

Copy link
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

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

LGTM with one minor change to the TestPushManifest() test.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 28, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, giuseppe, nalind, vrothberg

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

manifest push API must implement and leverage `retry` logic similar to
`image push` with similar defaults.

Closes: containers#1664

Signed-off-by: Aditya R <arajan@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Sep 28, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Sep 28, 2023
@openshift-merge-robot openshift-merge-robot merged commit 31e800a into containers:main Sep 28, 2023
7 checks passed
flouthoc added a commit to flouthoc/podman that referenced this pull request Oct 3, 2023
Test: containers/common#1666

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Oct 3, 2023
Test: containers/common#1666

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Oct 3, 2023
Test: containers/common#1666

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Oct 3, 2023
Test: containers/common#1666

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Oct 3, 2023
Test: containers/common#1666

Signed-off-by: Aditya R <arajan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman manifest push missing retry logic that is present in podman push
6 participants