[v5.4-rhel] wire up --retry-delay for artifact pull

fixed a bug in the artifact code where --retry-delay was being
discarded.

Fixes: https://issues.redhat.com/browse/RUN-2511
Fixes: https://issues.redhat.com/browse/RHEL-80259, https://issues.redhat.com/browse/RHEL-80260

Signed-off-by: Brent Baude <bbaude@redhat.com>
Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
This commit is contained in:
Brent Baude 2025-02-18 08:40:52 -06:00 committed by tomsweeneyredhat
parent 67d3d0788c
commit 56bfad1b0d
3 changed files with 14 additions and 23 deletions

View File

@ -116,28 +116,6 @@ func artifactPull(cmd *cobra.Command, args []string) error {
} }
} }
// TODO Once we have a decision about the flag removal above, this should be safe to delete
/*
platform, err := cmd.Flags().GetString("platform")
if err != nil {
return err
}
if platform != "" {
if pullOptions.Arch != "" || pullOptions.OS != "" {
return errors.New("--platform option can not be specified with --arch or --os")
}
specs := strings.Split(platform, "/")
pullOptions.OS = specs[0] // may be empty
if len(specs) > 1 {
pullOptions.Arch = specs[1]
if len(specs) > 2 {
pullOptions.Variant = specs[2]
}
}
}
*/
if pullOptions.CredentialsCLI != "" { if pullOptions.CredentialsCLI != "" {
creds, err := util.ParseRegistryCreds(pullOptions.CredentialsCLI) creds, err := util.ParseRegistryCreds(pullOptions.CredentialsCLI)
if err != nil { if err != nil {

View File

@ -63,12 +63,18 @@ func (ir *ImageEngine) ArtifactPull(ctx context.Context, name string, opts entit
pullOptions.CertDirPath = opts.CertDirPath pullOptions.CertDirPath = opts.CertDirPath
pullOptions.Username = opts.Username pullOptions.Username = opts.Username
pullOptions.Password = opts.Password pullOptions.Password = opts.Password
// pullOptions.Architecture = opts.Arch
pullOptions.SignaturePolicyPath = opts.SignaturePolicyPath pullOptions.SignaturePolicyPath = opts.SignaturePolicyPath
pullOptions.InsecureSkipTLSVerify = opts.InsecureSkipTLSVerify pullOptions.InsecureSkipTLSVerify = opts.InsecureSkipTLSVerify
pullOptions.Writer = opts.Writer pullOptions.Writer = opts.Writer
pullOptions.OciDecryptConfig = opts.OciDecryptConfig pullOptions.OciDecryptConfig = opts.OciDecryptConfig
pullOptions.MaxRetries = opts.MaxRetries pullOptions.MaxRetries = opts.MaxRetries
if opts.RetryDelay != "" {
duration, err := time.ParseDuration(opts.RetryDelay)
if err != nil {
return nil, err
}
pullOptions.RetryDelay = &duration
}
if !opts.Quiet && pullOptions.Writer == nil { if !opts.Quiet && pullOptions.Writer == nil {
pullOptions.Writer = os.Stderr pullOptions.Writer = os.Stderr

View File

@ -132,6 +132,13 @@ var _ = Describe("Podman artifact", func() {
}) })
It("podman artifact push and pull", func() { It("podman artifact push and pull", func() {
// Before starting a registry, try to pull a bogus image from a bogus registry
// using retry-delay
retrySession := podmanTest.Podman([]string{"artifact", "pull", "--retry", "1", "--retry-delay", "100ms", "127.0.0.1/mybadimagename"})
retrySession.WaitWithDefaultTimeout()
Expect(retrySession).Should(ExitWithError(125, "connect: connection refused"))
Expect(retrySession.ErrorToString()).To(ContainSubstring("retrying in 100ms ..."))
artifact1File, err := createArtifactFile(1024) artifact1File, err := createArtifactFile(1024)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())