Skip to content

Commit

Permalink
daemon: Use nice/ionice when extracting oscontainer too
Browse files Browse the repository at this point in the history
We switched rpm-ostree to do this when applying updates, but
it also makes sense to do when extracting the oscontainer.

Part of: openshift#1897
Which is about staging OS updates more nicely when etcd is running.
  • Loading branch information
cgwalters committed Aug 25, 2020
1 parent 06aa20e commit 45b599e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
13 changes: 13 additions & 0 deletions pkg/daemon/pivot/utils/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
6 changes: 6 additions & 0 deletions pkg/daemon/pivot/utils/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
6 changes: 3 additions & 3 deletions pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 45b599e

Please sign in to comment.