osbuild-worker-executor: fix tar warning and log unexpected output
This commit fixes a warning from tar that the archive cannot contain itself. It also makes any tar output a warning (maybe even an error?) as we do not expect anything from the tar command. The test is updated to also check this.
This commit is contained in:
parent
1f52150ff1
commit
22769305d8
2 changed files with 11 additions and 2 deletions
|
|
@ -85,6 +85,7 @@ func runOsbuild(logger *logrus.Logger, buildDir string, control *controlJSON, ou
|
|||
// #nosec G204
|
||||
cmd = exec.Command(
|
||||
"tar",
|
||||
"--exclude=output/output.tar",
|
||||
"-Scf",
|
||||
filepath.Join(outputDir, "output.tar"),
|
||||
"output",
|
||||
|
|
@ -97,7 +98,10 @@ func runOsbuild(logger *logrus.Logger, buildDir string, control *controlJSON, ou
|
|||
_, _ = mw.Write([]byte(err.Error()))
|
||||
return "", err
|
||||
}
|
||||
logger.Infof("tar output:\n%s", out)
|
||||
if len(out) > 0 {
|
||||
logger.Warnf("unexpected tar output:\n%s", out)
|
||||
}
|
||||
|
||||
return outputDir, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func makeTestPost(t *testing.T, controlJSON, manifestJSON string) *bytes.Buffer
|
|||
}
|
||||
|
||||
func TestBuildIntegration(t *testing.T) {
|
||||
baseURL, baseBuildDir, _ := runTestServer(t)
|
||||
baseURL, baseBuildDir, loggerHook := runTestServer(t)
|
||||
endpoint := baseURL + "api/v1/build"
|
||||
|
||||
// osbuild is called with --export tree and then the manifest.json
|
||||
|
|
@ -124,6 +124,11 @@ echo "fake-build-result" > %[1]s/build/output/image/disk.img
|
|||
assert.NoError(t, err)
|
||||
assert.True(t, stat.IsDir())
|
||||
|
||||
// ensure tar is not generating any warnings
|
||||
for _, entry := range loggerHook.Entries {
|
||||
assert.NotContains(t, entry.Message, "unexpected tar output")
|
||||
}
|
||||
|
||||
// now get the result
|
||||
endpoint = baseURL + "api/v1/result/image/disk.img"
|
||||
rsp, err = http.Get(endpoint)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue