1
0
mirror of https://github.com/ko-build/ko.git synced 2025-07-06 23:36:54 +02:00

Deterministically fail ko {apply, create} (#133)

When resolving files, we would just log.Fatal if we encountered an
error. This seems to be racy and causes ko to exit with a 0 error code
when it shouldn't. To fix this, we synchronize the builder goroutines
with the kubectl go routine and exit with an error if either of them
failed.

This fix also happened to fix a goroutine leak. If the kubectl goroutine
failed, we never properly cancelled the builds, which would happily
conitnue compiling packages and consuming resources.
This commit is contained in:
jonjohnsonjr
2020-02-11 10:44:25 -08:00
committed by GitHub
parent c3a657a04b
commit cfd680de28
4 changed files with 71 additions and 29 deletions

View File

@ -67,7 +67,9 @@ func addResolve(topLevel *cobra.Command) {
log.Fatalf("error creating publisher: %v", err)
}
ctx := createCancellableContext()
resolveFilesToWriter(ctx, builder, publisher, fo, so, sto, os.Stdout)
if err := resolveFilesToWriter(ctx, builder, publisher, fo, so, sto, os.Stdout); err != nil {
log.Fatal(err)
}
},
}
options.AddLocalArg(resolve, lo)