Skip to content

Commit 3c32012

Browse files
committed
Don't try to unregister an instance that failed validation
There may be nil pointers in the instance data that will cause a panic. Signed-off-by: Jan Dubois <[email protected]>
1 parent b85a356 commit 3c32012

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/instance/delete.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ func Delete(ctx context.Context, inst *store.Instance, force bool) error {
2121

2222
StopForcibly(inst)
2323

24-
if err := unregister(ctx, inst); err != nil {
25-
return fmt.Errorf("failed to unregister %q: %w", inst.Dir, err)
24+
if len(inst.Errors) == 0 {
25+
if err := unregister(ctx, inst); err != nil {
26+
return fmt.Errorf("failed to unregister %q: %w", inst.Dir, err)
27+
}
2628
}
27-
2829
if err := os.RemoveAll(inst.Dir); err != nil {
2930
return fmt.Errorf("failed to remove %q: %w", inst.Dir, err)
3031
}

0 commit comments

Comments
 (0)