Skip to content

Commit 080a239

Browse files
Merge pull request #25352 from baude/artifactpullretrydelay
wire up --retry-delay for artifact pull
2 parents 61e88e4 + 6ad2dc0 commit 080a239

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

cmd/podman/artifact/pull.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,28 +116,6 @@ func artifactPull(cmd *cobra.Command, args []string) error {
116116
}
117117
}
118118

119-
// TODO Once we have a decision about the flag removal above, this should be safe to delete
120-
/*
121-
platform, err := cmd.Flags().GetString("platform")
122-
if err != nil {
123-
return err
124-
}
125-
if platform != "" {
126-
if pullOptions.Arch != "" || pullOptions.OS != "" {
127-
return errors.New("--platform option can not be specified with --arch or --os")
128-
}
129-
130-
specs := strings.Split(platform, "/")
131-
pullOptions.OS = specs[0] // may be empty
132-
if len(specs) > 1 {
133-
pullOptions.Arch = specs[1]
134-
if len(specs) > 2 {
135-
pullOptions.Variant = specs[2]
136-
}
137-
}
138-
}
139-
*/
140-
141119
if pullOptions.CredentialsCLI != "" {
142120
creds, err := util.ParseRegistryCreds(pullOptions.CredentialsCLI)
143121
if err != nil {

pkg/domain/infra/abi/artifact.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ func (ir *ImageEngine) ArtifactPull(ctx context.Context, name string, opts entit
6363
pullOptions.CertDirPath = opts.CertDirPath
6464
pullOptions.Username = opts.Username
6565
pullOptions.Password = opts.Password
66-
// pullOptions.Architecture = opts.Arch
6766
pullOptions.SignaturePolicyPath = opts.SignaturePolicyPath
6867
pullOptions.InsecureSkipTLSVerify = opts.InsecureSkipTLSVerify
6968
pullOptions.Writer = opts.Writer
7069
pullOptions.OciDecryptConfig = opts.OciDecryptConfig
7170
pullOptions.MaxRetries = opts.MaxRetries
71+
if opts.RetryDelay != "" {
72+
duration, err := time.ParseDuration(opts.RetryDelay)
73+
if err != nil {
74+
return nil, err
75+
}
76+
pullOptions.RetryDelay = &duration
77+
}
7278

7379
if !opts.Quiet && pullOptions.Writer == nil {
7480
pullOptions.Writer = os.Stderr

test/e2e/artifact_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ var _ = Describe("Podman artifact", func() {
130130
})
131131

132132
It("podman artifact push and pull", func() {
133+
// Before starting a registry, try to pull a bogus image from a bogus registry
134+
// using retry-delay
135+
retrySession := podmanTest.Podman([]string{"artifact", "pull", "--retry", "1", "--retry-delay", "100ms", "127.0.0.1/mybadimagename"})
136+
retrySession.WaitWithDefaultTimeout()
137+
Expect(retrySession).Should(ExitWithError(125, "connect: connection refused"))
138+
Expect(retrySession.ErrorToString()).To(ContainSubstring("retrying in 100ms ..."))
139+
133140
artifact1File, err := createArtifactFile(1024)
134141
Expect(err).ToNot(HaveOccurred())
135142

0 commit comments

Comments
 (0)