Skip to content

Fix race when object is deleted

Francois Eleouet requested to merge fe/handle-deleted-obj into main

When an object is being deleted, if may be removed from objectMap before watch command has finished to process the previous event.

Log event and continue in that case. A log has also been added on delete events as we were not logging anything in that case.

The issue has been observed in https://gitlab.com/sylva-projects/sylva-core/-/jobs/7004903539

We observed the following traceback:

2024/06/03 16:06:07.536314 Error: no treeNode found for object Kustomization/sylva-system/root-dependency-2 panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x108 pc=0x15c1b18] goroutine 1 [running]: main.logResources({0x1b8af20, 0xc0001522a0}, {0x1b92a58, 0xc0000e0640}, 0xc000048480, {0x7ffcfe844378, 0x24}, {0xc0000654d0, 0x2, 0x2}) /builds/sylva-projects/sylva-elements/sylvactl/watch.go:310 +0x878 main.watchCmdRun(0xc00018e900?, {0xc0000beb40?, 0x4?, 0x18edc55?}) /builds/sylva-projects/sylva-elements/sylvactl/watch.go:142 +0x310 github.com/spf13/cobra.(*Command).execute(0x28367c0, {0xc0000beae0, 0x6, 0x6}) /go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca github.com/spf13/cobra.(*Command).ExecuteC(0x2835f20) /go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff github.com/spf13/cobra.(*Command).Execute(...) /go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 main.main() /builds/sylva-projects/sylva-elements/sylvactl/main.go:51 +0x1a

We can see a kustomisation root-dependency-3 in debug artifact, proving that root-dependency-2 was being deleted.

Merge request reports