-
Notifications
You must be signed in to change notification settings - Fork 174
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
libimage: implement retry
logic for manifest push
#1666
Conversation
9391ce7
to
b28613f
Compare
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.
LGTM
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.
LGTM
libimage/manifests/manifests.go
Outdated
@@ -28,6 +30,11 @@ import ( | |||
"github.com/sirupsen/logrus" | |||
) | |||
|
|||
const ( | |||
defaultMaxRetries = 3 | |||
defaultRetryDelay = time.Second |
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.
retry.IfNecessary()
has a default for this, so it's better to not insert our own.
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.
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
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.
There's a default delay (the godoc for retry.Options.Delay hints at it), but not a default on the number of retries.
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.
Done.
b28613f
to
f6455a2
Compare
f6455a2
to
ab58b4f
Compare
ab58b4f
to
061f2b0
Compare
061f2b0
to
48a8fa2
Compare
libimage/manifests/manifests_test.go
Outdated
|
||
options.RetryDelay = 3 * time.Second | ||
_, _, err = list.Push(ctx, destRef, options) | ||
assert.NoError(t, err, "list.Push(with RetryDelay)") |
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.
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?
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.
@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.
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.
TestPush() really needs to be expanded, but otherwise LGTM, give or take a non-blocking stylistic nit.
Let me extend the test, I think this can be tested here as well. |
699fa23
to
6d13884
Compare
Expanded PushTest to actually cover retry attempts by checking |
6d13884
to
0dffc5f
Compare
@nalind PTAL again. |
libimage/manifests/manifests_test.go
Outdated
@@ -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()") |
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.
Probably want to use assert.NoErrorf()
here, since we know that err
is an error if it isn't nil
.
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.
LGTM with one minor change to the TestPushManifest()
test.
[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 |
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>
0dffc5f
to
c044f8d
Compare
/lgtm |
Test: containers/common#1666 Signed-off-by: Aditya R <arajan@redhat.com>
Test: containers/common#1666 Signed-off-by: Aditya R <arajan@redhat.com>
Test: containers/common#1666 Signed-off-by: Aditya R <arajan@redhat.com>
Test: containers/common#1666 Signed-off-by: Aditya R <arajan@redhat.com>
Test: containers/common#1666 Signed-off-by: Aditya R <arajan@redhat.com>
manifest push API must implement and leverage
retry
logic similar toimage push
with similar defaults.Closes: #1664