Fixes for vendoring Buildah

This commit was automatically cherry-picked
by buildah-vendor-treadmill v0.3
from the buildah vendor treadmill PR, #13808

  * Fix conflict caused by Ed's local-registry PR in buildah
  * Wire in "new" --retry and --retry-delay, these existed for longer
    but where non functional.

Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Ed Santiago 2024-05-21 05:02:49 -06:00 committed by Paul Holzinger
parent 83a0299309
commit 043b82ef59
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
6 changed files with 60 additions and 13 deletions

View File

@ -506,6 +506,14 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil
} }
} }
retryDelay := 2 * time.Second
if flags.RetryDelay != "" {
retryDelay, err = time.ParseDuration(flags.RetryDelay)
if err != nil {
return nil, fmt.Errorf("unable to parse value provided %q as --retry-delay: %w", flags.RetryDelay, err)
}
}
opts := buildahDefine.BuildOptions{ opts := buildahDefine.BuildOptions{
AddCapabilities: flags.CapAdd, AddCapabilities: flags.CapAdd,
AdditionalTags: tags, AdditionalTags: tags,
@ -544,7 +552,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil
LogFile: flags.Logfile, LogFile: flags.Logfile,
LogSplitByPlatform: flags.LogSplitByPlatform, LogSplitByPlatform: flags.LogSplitByPlatform,
Manifest: flags.Manifest, Manifest: flags.Manifest,
MaxPullPushRetries: 3, MaxPullPushRetries: flags.Retry,
NamespaceOptions: nsValues, NamespaceOptions: nsValues,
NoCache: flags.NoCache, NoCache: flags.NoCache,
OSFeatures: flags.OSFeatures, OSFeatures: flags.OSFeatures,
@ -555,7 +563,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil
OutputFormat: format, OutputFormat: format,
Platforms: platforms, Platforms: platforms,
PullPolicy: pullPolicy, PullPolicy: pullPolicy,
PullPushRetryDelay: 2 * time.Second, PullPushRetryDelay: retryDelay,
Quiet: flags.Quiet, Quiet: flags.Quiet,
RemoveIntermediateCtrs: flags.Rm, RemoveIntermediateCtrs: flags.Rm,
ReportWriter: reporter, ReportWriter: reporter,

View File

@ -87,6 +87,13 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
return return
} }
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
conf, err := runtime.GetConfigNoCopy()
if err != nil {
utils.InternalServerError(w, err)
return
}
query := struct { query := struct {
AddHosts string `schema:"extrahosts"` AddHosts string `schema:"extrahosts"`
AdditionalCapabilities string `schema:"addcaps"` AdditionalCapabilities string `schema:"addcaps"`
@ -147,6 +154,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Rm bool `schema:"rm"` Rm bool `schema:"rm"`
RusageLogFile string `schema:"rusagelogfile"` RusageLogFile string `schema:"rusagelogfile"`
Remote string `schema:"remote"` Remote string `schema:"remote"`
Retry int `schema:"retry"`
RetryDelay string `schema:"retry-delay"`
Seccomp string `schema:"seccomp"` Seccomp string `schema:"seccomp"`
Secrets string `schema:"secrets"` Secrets string `schema:"secrets"`
SecurityOpt string `schema:"securityopt"` SecurityOpt string `schema:"securityopt"`
@ -169,6 +178,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
ShmSize: 64 * 1024 * 1024, ShmSize: 64 * 1024 * 1024,
TLSVerify: true, TLSVerify: true,
SkipUnusedStages: true, SkipUnusedStages: true,
Retry: int(conf.Engine.Retry),
RetryDelay: conf.Engine.RetryDelay,
} }
decoder := utils.GetDecoder(r) decoder := utils.GetDecoder(r)
@ -672,7 +683,15 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
return return
} }
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) retryDelay := 2 * time.Second
if query.RetryDelay != "" {
retryDelay, err = time.ParseDuration(query.RetryDelay)
if err != nil {
utils.BadRequest(w, "retry-delay", query.RetryDelay, err)
return
}
}
buildOptions := buildahDefine.BuildOptions{ buildOptions := buildahDefine.BuildOptions{
AddCapabilities: addCaps, AddCapabilities: addCaps,
AdditionalBuildContexts: additionalBuildContexts, AdditionalBuildContexts: additionalBuildContexts,
@ -730,7 +749,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Layers: query.Layers, Layers: query.Layers,
LogRusage: query.LogRusage, LogRusage: query.LogRusage,
Manifest: query.Manifest, Manifest: query.Manifest,
MaxPullPushRetries: 3, MaxPullPushRetries: query.Retry,
NamespaceOptions: nsoptions, NamespaceOptions: nsoptions,
NoCache: query.NoCache, NoCache: query.NoCache,
OSFeatures: query.OSFeatures, OSFeatures: query.OSFeatures,
@ -739,7 +758,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Output: output, Output: output,
OutputFormat: format, OutputFormat: format,
PullPolicy: pullPolicy, PullPolicy: pullPolicy,
PullPushRetryDelay: 2 * time.Second, PullPushRetryDelay: retryDelay,
Quiet: query.Quiet, Quiet: query.Quiet,
Registry: registry, Registry: registry,
RemoveIntermediateCtrs: query.Rm, RemoveIntermediateCtrs: query.Rm,

View File

@ -536,6 +536,18 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
// with the corresponding path inside the tarball. // with the corresponding path inside the tarball.
// (As of version 1.xx) // (As of version 1.xx)
// - in: query // - in: query
// name: retry
// type: integer
// default: 3
// description: |
// Number of times to retry in case of failure when performing push/pull.
// - in: query
// name: retry-delay
// type: string
// default: 2s
// description: |
// Delay between retries in case of push/pull failures.
// - in: query
// name: q // name: q
// type: boolean // type: boolean
// default: false // default: false

View File

@ -280,6 +280,10 @@ func Build(ctx context.Context, containerFiles []string, options types.BuildOpti
if len(options.RusageLogFile) > 0 { if len(options.RusageLogFile) > 0 {
params.Set("rusagelogfile", options.RusageLogFile) params.Set("rusagelogfile", options.RusageLogFile)
} }
params.Set("retry", strconv.Itoa(options.MaxPullPushRetries))
params.Set("retry-delay", options.PullPushRetryDelay.String())
if len(options.Manifest) > 0 { if len(options.Manifest) > 0 {
params.Set("manifest", options.Manifest) params.Set("manifest", options.Manifest)
} }

View File

@ -257,6 +257,9 @@ skip_if_rootless "Flakes when run rootless, too. See Buildah PR 4190" \
skip_if_remote "--events-backend does not work with podman-remote" \ skip_if_remote "--events-backend does not work with podman-remote" \
"build test default ulimits" "build test default ulimits"
skip_if_remote "--cert-dir option not working via remote and retry warnings are printed on the server" \
"build add https retry ca"
############################################################################### ###############################################################################
# BEGIN tests which are skipped due to actual podman or podman-remote bugs. # BEGIN tests which are skipped due to actual podman or podman-remote bugs.

View File

@ -1,4 +1,4 @@
From 6f7a27f4787ec91ecf7bd7c4de048b23c3cdb74f Mon Sep 17 00:00:00 2001 From e39e00a6d92acb83283705ea66c26261ca6a0170 Mon Sep 17 00:00:00 2001
From: Ed Santiago <santiago@redhat.com> From: Ed Santiago <santiago@redhat.com>
Date: Thu, 6 Oct 2022 17:32:59 -0600 Date: Thu, 6 Oct 2022 17:32:59 -0600
Subject: [PATCH] tweaks for running buildah tests under podman Subject: [PATCH] tweaks for running buildah tests under podman
@ -9,7 +9,7 @@ Signed-off-by: Ed Santiago <santiago@redhat.com>
1 file changed, 115 insertions(+), 4 deletions(-) 1 file changed, 115 insertions(+), 4 deletions(-)
diff --git a/tests/helpers.bash b/tests/helpers.bash diff --git a/tests/helpers.bash b/tests/helpers.bash
index b47939284..ce6dde76e 100644 index 20f0787ff..c356500ae 100644
--- a/tests/helpers.bash --- a/tests/helpers.bash
+++ b/tests/helpers.bash +++ b/tests/helpers.bash
@@ -79,6 +79,38 @@ EOF @@ -79,6 +79,38 @@ EOF
@ -50,8 +50,8 @@ index b47939284..ce6dde76e 100644
+ fi + fi
} }
function starthttpd() { function starthttpd() { # directory [working-directory-or-"" [certfile, keyfile]]
@@ -122,6 +154,32 @@ function teardown_tests() { @@ -143,6 +175,32 @@ function teardown_tests() {
stop_git_daemon stop_git_daemon
stop_registry stop_registry
@ -84,7 +84,7 @@ index b47939284..ce6dde76e 100644
# Workaround for #1991 - buildah + overlayfs leaks mount points. # Workaround for #1991 - buildah + overlayfs leaks mount points.
# Many tests leave behind /var/tmp/.../root/overlay and sub-mounts; # Many tests leave behind /var/tmp/.../root/overlay and sub-mounts;
# let's find those and clean them up, otherwise 'rm -rf' fails. # let's find those and clean them up, otherwise 'rm -rf' fails.
@@ -211,7 +269,12 @@ function copy() { @@ -232,7 +290,12 @@ function copy() {
} }
function podman() { function podman() {
@ -98,7 +98,7 @@ index b47939284..ce6dde76e 100644
} }
# There are various scenarios where we would like to execute `tests` as rootless user, however certain commands like `buildah mount` # There are various scenarios where we would like to execute `tests` as rootless user, however certain commands like `buildah mount`
@@ -275,8 +338,36 @@ function run_buildah() { @@ -296,8 +359,36 @@ function run_buildah() {
--retry) retry=3; shift;; # retry network flakes --retry) retry=3; shift;; # retry network flakes
esac esac
@ -136,7 +136,7 @@ index b47939284..ce6dde76e 100644
# If session is rootless and `buildah mount` is invoked, perform unshare, # If session is rootless and `buildah mount` is invoked, perform unshare,
# since normal user cannot mount a filesystem unless they're in a user namespace along with its own mount namespace. # since normal user cannot mount a filesystem unless they're in a user namespace along with its own mount namespace.
@@ -290,8 +381,8 @@ function run_buildah() { @@ -311,8 +402,8 @@ function run_buildah() {
retry=$(( retry - 1 )) retry=$(( retry - 1 ))
# stdout is only emitted upon error; this echo is to help a debugger # stdout is only emitted upon error; this echo is to help a debugger
@ -147,7 +147,7 @@ index b47939284..ce6dde76e 100644
# without "quotes", multiple lines are glommed together into one # without "quotes", multiple lines are glommed together into one
if [ -n "$output" ]; then if [ -n "$output" ]; then
echo "$output" echo "$output"
@@ -652,6 +743,26 @@ function skip_if_no_unshare() { @@ -673,6 +764,26 @@ function skip_if_no_unshare() {
fi fi
} }
@ -176,3 +176,4 @@ index b47939284..ce6dde76e 100644
mkdir -p ${daemondir}/repo mkdir -p ${daemondir}/repo
-- --
2.45.2 2.45.2