Cray-HPE / loftsman

Define, organize, and ship your Kubernetes workloads with Helm charts easily
MIT License
9 stars 5 forks source link

Panic when configmap already exists in the loftsman namespace named like the one used for record keeping for a manifest #35

Open rockholla opened 3 years ago

rockholla commented 3 years ago

What happened?

Loftsman uses internal-use configmaps in the loftsman namespace to keep records for ship operations, named like loftsman-[manifest name]. If some alternative configmap already exists in the loftsman namespace, it can produce a runtime panic like:

2021-05-21T00:39:07Z INF Running a release for the provided manifest at /etc/manifests/manifest.yaml command=ship
E0521 00:39:07.921889       1 runtime.go:78] Observed a panic: "assignment to entry in nil map" (assignment to entry in nil map)
goroutine 1 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic(0x16d5940, 0x1a693a0)
    /home/runner/go/pkg/mod/k8s.io/apimachinery@v0.21.0/pkg/util/runtime/runtime.go:74 +0x95
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
    /home/runner/go/pkg/mod/k8s.io/apimachinery@v0.21.0/pkg/util/runtime/runtime.go:48 +0x86
panic(0x16d5940, 0x1a693a0)
    /opt/hostedtoolcache/go/1.16.3/x64/src/runtime/panic.go:965 +0x1b9
github.com/Cray-HPE/loftsman/internal/kubernetes.(*Kubernetes).InitializeConfigMap.func1(0xc00058f950, 0x4662c0)
    /home/runner/work/loftsman/loftsman/internal/kubernetes/kubernetes.go:165 +0x270
k8s.io/client-go/util/retry.OnError.func1(0x1964ec0, 0xc000310300, 0xc00058fa30)
    /home/runner/go/pkg/mod/k8s.io/client-go@v0.21.0/util/retry/util.go:51 +0x3c
k8s.io/apimachinery/pkg/util/wait.runConditionWithCrashProtection(0xc00058fa70, 0xc000423600, 0x0, 0x0)
    /home/runner/go/pkg/mod/k8s.io/apimachinery@v0.21.0/pkg/util/wait/wait.go:211 +0x69
k8s.io/apimachinery/pkg/util/wait.ExponentialBackoff(0x989680, 0x4014000000000000, 0x3fb999999999999a, 0x4, 0x0, 0xc00058fa70, 0xc000092300, 0x0)
    /home/runner/go/pkg/mod/k8s.io/apimachinery@v0.21.0/pkg/util/wait/wait.go:399 +0x55
k8s.io/client-go/util/retry.OnError(0x989680, 0x4014000000000000, 0x3fb999999999999a, 0x4, 0x0, 0xc00058fb00, 0xc00058fb10, 0x50a388, 0x3)
    /home/runner/go/pkg/mod/k8s.io/client-go@v0.21.0/util/retry/util.go:50 +0xa6
github.com/Cray-HPE/loftsman/internal/kubernetes.(*Kubernetes).InitializeConfigMap(0xc000318e70, 0xc0003f5800, 0xd, 0x18a8eb2, 0x8, 0xc0005237d0, 0xc0005237d0, 0x18a75b5, 0x6)
    /home/runner/work/loftsman/loftsman/internal/kubernetes/kubernetes.go:142 +0x165
github.com/Cray-HPE/loftsman/internal.(*Loftsman).Ship(0xc0003158b0, 0x0, 0x0)
    /home/runner/work/loftsman/loftsman/internal/loftsman.go:158 +0x703
github.com/Cray-HPE/loftsman/cmd.runShip(0x2498840, 0xc00035d720, 0x0, 0x2)
    /home/runner/work/loftsman/loftsman/cmd/root.go:220 +0x2d
github.com/spf13/cobra.(*Command).execute(0x2498840, 0xc00035d700, 0x2, 0x2, 0x2498840, 0xc00035d700)
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x2497e40, 0x407f25, 0xc000092058, 0x401230)
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/Cray-HPE/loftsman/cmd.Execute()
    /home/runner/work/loftsman/loftsman/cmd/root.go:160 +0x53
main.main()
    /home/runner/work/loftsman/loftsman/main.go:7 +0x25
panic: assignment to entry in nil map [recovered]
    panic: assignment to entry in nil map

What did you expect to happen?

For loftsman to react in some non-panic way to this case, likely reporting back to the user that an unexpected conflicting configmap was found.

How to reproduce the issue (as minimally and precisely as possible):

Add a configmap in the loftsman namespace that would conflict

Anything else worth sharing:

N/A