diff --git a/pkg/daemon/pivot/utils/run.go b/pkg/daemon/pivot/utils/run.go index 34193809e8..569ab39f59 100644 --- a/pkg/daemon/pivot/utils/run.go +++ b/pkg/daemon/pivot/utils/run.go @@ -65,3 +65,16 @@ func RunExt(retries int, command string, args ...string) (string, error) { }, command, args...) } + +// RunExtBackground is like RunExt, but queues the command for "nice" CPU and +// I/O scheduling. +func RunExtBackground(retries int, command string, args ...string) (string, error) { + args = append([]string{"--", "ionice", "-c", "3", command}, args...) + command = "nice" + return runExtBackoff(wait.Backoff{ + Steps: retries + 1, // times to try + Duration: 5 * time.Second, // sleep between tries + Factor: 2, // factor by which to increase sleep + }, + command, args...) +} diff --git a/pkg/daemon/pivot/utils/run_test.go b/pkg/daemon/pivot/utils/run_test.go index 0fc714a702..27dacd1614 100644 --- a/pkg/daemon/pivot/utils/run_test.go +++ b/pkg/daemon/pivot/utils/run_test.go @@ -27,3 +27,9 @@ func TestRunExt(t *testing.T) { assert.Nil(t, err) assert.Equal(t, int64(3), s.Size()) } + +func TestRunExtBackground(t *testing.T) { + o, err := RunExtBackground(0, "echo", "echo", "from", "TestRunExtBackground") + assert.Nil(t, err) + assert.Equal(t, o, "echo from TestRunExtBackground") +} diff --git a/pkg/daemon/update.go b/pkg/daemon/update.go index 6a585682e0..988e750da2 100644 --- a/pkg/daemon/update.go +++ b/pkg/daemon/update.go @@ -238,7 +238,7 @@ func podmanCopy(imgURL, osImageContentDir string) (err error) { args := []string{"pull", "-q"} args = append(args, authArgs...) args = append(args, imgURL) - _, err = pivotutils.RunExt(numRetriesNetCommands, "podman", args...) + _, err = pivotutils.RunExtBackground(numRetriesNetCommands, "podman", args...) if err != nil { return } @@ -257,7 +257,7 @@ func podmanCopy(imgURL, osImageContentDir string) (err error) { // copy the content from create container locally into a temp directory under /run/machine-os-content/ cid := strings.TrimSpace(string(cidBuf)) args = []string{"cp", fmt.Sprintf("%s:/", cid), osImageContentDir} - _, err = pivotutils.RunExt(numRetriesNetCommands, "podman", args...) + _, err = pivotutils.RunExtBackground(numRetriesNetCommands, "podman", args...) // Set selinux context to var_run_t to avoid selinux denial args = []string{"-R", "-t", "var_run_t", osImageContentDir} @@ -294,7 +294,7 @@ func ExtractOSImage(imgURL string) (osImageContentDir string, err error) { args := []string{"image", "extract", "--path", "/:" + osImageContentDir} args = append(args, registryConfig...) args = append(args, imgURL) - if _, err = pivotutils.RunExt(cmdRetriesCount, "oc", args...); err != nil { + if _, err = pivotutils.RunExtBackground(cmdRetriesCount, "oc", args...); err != nil { // Workaround fixes for the environment where oc image extract fails. // See https://bugzilla.redhat.com/show_bug.cgi?id=1862979 glog.Infof("Falling back to using podman cp to fetch OS image content")