debian-forge-composer/internal
Tomas Hozza 5e591ccc3d GCP: Fix panic while parsing a specific build job log
The `cloudbuildResourcesFromBuildLog()` function from the internal GCP
package could cause panic while parsing Build job log which failed early
and didn't create any Compute Engine resources. The function relied on
the `Regexp.FindStringSubmatch()` method to always return a match
while being used on the build log. Accessing a member of a nil slice
would cause a panic in `osbuild-worker`, such as:

Stack trace of thread 185316:
 #0  0x0000564e5393b5e1 runtime.raise (osbuild-worker)
 #1  0x0000564e5391fa1e runtime.sigfwdgo (osbuild-worker)
 #2  0x0000564e5391e354 runtime.sigtrampgo (osbuild-worker)
 #3  0x0000564e5393b953 runtime.sigtramp (osbuild-worker)
 #4  0x00007f37e98e3b20 __restore_rt (libpthread.so.0)
 #5  0x0000564e5393b5e1 runtime.raise (osbuild-worker)
 #6  0x0000564e5391f5ea runtime.crash (osbuild-worker)
 #7  0x0000564e53909306 runtime.fatalpanic (osbuild-worker)
 #8  0x0000564e53908ca1 runtime.gopanic (osbuild-worker)
 #9  0x0000564e53906b65 runtime.goPanicIndex (osbuild-worker)
 #10 0x0000564e5420b36e github.com/osbuild/osbuild-composer/internal/cloud/gcp.cloudbuildResourcesFromBuildLog (osbuild-worker)
 #11 0x0000564e54209ebb github.com/osbuild/osbuild-composer/internal/cloud/gcp.(*GCP).CloudbuildBuildCleanup (osbuild-worker)
 #12 0x0000564e54b05a9b main.(*OSBuildJobImpl).Run (osbuild-worker)
 #13 0x0000564e54b08854 main.main (osbuild-worker)
 #14 0x0000564e5390b722 runtime.main (osbuild-worker)
 #15 0x0000564e53939a11 runtime.goexit (osbuild-worker)

Add a unit test testing this scenario.

Make the `cloudbuildResourcesFromBuildLog()` function more robust and
not blindly expect to find matches in the build log. As a result the
`cloudbuildBuildResources` struct instance returned from the function
may be empty. Subsequently make sure that the `CloudbuildBuildCleanup()`
method handles an empty `cloudbuildBuildResources` instance correctly.
Specifically the `storageCacheDir.bucket` may be an empty string and
thus won't exist. Ensure that this does not result in infinite loop by
checking for `storage.ErrBucketNotExist` while iterating the bucket
objects.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-04-29 14:48:50 +02:00
..
blueprint rhel84/grub2: set saved_entry 2021-02-20 20:01:15 +01:00
boot test: replace genisoimage with mkisofs 2021-04-02 14:21:29 +02:00
client test: Add tests for trying to override a system source repo 2021-01-29 08:25:23 -08:00
cloud/gcp GCP: Fix panic while parsing a specific build job log 2021-04-29 14:48:50 +02:00
cloudapi Rename all occurrences of "Compute Node" to "Compute Engine" 2021-04-01 20:12:39 +02:00
common weldr: move common.ComposeState to weldr 2020-11-09 14:17:19 +01:00
crypt crypt: add automatic darwin support 2020-07-17 07:48:22 +02:00
disk osbuild: rename package to osbuild1 2021-03-17 18:12:17 +00:00
distro distro: remove unused field from distribution struct 2021-04-10 19:53:07 +01:00
distroregistry distro/rhel90: add RHEL9 support 2021-03-26 14:05:20 +00:00
jobqueue jobqueue: Replace JobArgs() with Job() 2021-01-19 10:37:51 +01:00
jsondb jsondb: Allow passing nil as document to Read() 2020-05-13 16:45:09 +02:00
kojiapi osbuild: rename package to osbuild1 2021-03-17 18:12:17 +00:00
mocks distro: move Registry to its own distroregistry package 2021-03-12 08:29:30 +01:00
osbuild1 distro/rhel84: build qcow2 images with compat=0.10 2021-04-10 19:18:13 +01:00
osbuild2 osbuild1/result: fix conversion of success field from v2 2021-03-19 18:50:31 +01:00
rpmmd distro: introduce PackageSets 2021-03-10 11:52:05 +00:00
store tests: Use nicer test strings for json_test.go 2021-03-30 00:19:30 +01:00
target target/azure: document what it does 2021-03-06 15:40:48 +00:00
test test: add arch to the generate test artifact names 2020-12-01 08:27:44 +01:00
upload internal: Move GCP library to internal/cloud 2021-03-15 16:48:40 +00:00
weldr weldr: validate external ostree ref 2021-03-30 00:22:04 +01:00
worker osbuld-worker: call osbuild with --export flag 2021-03-17 18:12:17 +00:00
tools.go go: vendor the oapi-codegen cmd 2021-02-01 15:32:58 +01:00