Don't Panic in getComposeStatus and skip invalid jobs in fsjobqueue New
This handles corrupt job json files by skipping them. They still exist, and errors are logged, but the system keeps working. If one or more of the json files in /var/lib/osbuild-composer/jobs/ becomes corrupt they can stop the osbuild-composer service from starting, or stop commands like 'composer-cli compose status' from working because they quit on the first error and miss any job that aren't broken.
This commit is contained in:
parent
e969a9dc3c
commit
aca748bc14
6 changed files with 291 additions and 18 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package rpmmd_mock
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/jobqueue/fsjobqueue"
|
||||
dnfjson_mock "github.com/osbuild/osbuild-composer/internal/mocks/dnfjson"
|
||||
"github.com/osbuild/osbuild-composer/internal/store"
|
||||
|
|
@ -64,3 +67,20 @@ func OldChangesFixture(tmpdir string) Fixture {
|
|||
dnfjson_mock.Base,
|
||||
}
|
||||
}
|
||||
|
||||
func BadJobJSONFixture(tmpdir string) Fixture {
|
||||
err := os.Mkdir(path.Join(tmpdir, "/jobs"), 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = os.WriteFile(path.Join(tmpdir, "/jobs/30000000-0000-0000-0000-000000000005.json"), []byte("{invalid json content"), 0600)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return Fixture{
|
||||
store.FixtureJobs(),
|
||||
createBaseWorkersFixture(path.Join(tmpdir, "/jobs")),
|
||||
dnfjson_mock.Base,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue