Skip to content

Commit 927969b

Browse files
committed
cilium-dbg: Don't fatal on XFRM rule deletion errors
This commit slightly changes the behavior of the "encrypt flush" command in case of errors when trying to delete XFRM rules. The tool currently lists rules, filters them based on user-given arguments, and then deletes them. If an XFRM rule is deleted by the agent or the user while we're filtering, the deletion will fail. The current behavior in that case is to fatal. On busy clusters, that might mean that we always fatal because XFRM states and policies are constently added and removed. This commit changes the behavior to proceed with subsequent deletions in case one fails. Signed-off-by: Paul Chaignon <[email protected]>
1 parent d43ace6 commit 927969b

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

cilium-dbg/cmd/encrypt_flush.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package cmd
55

66
import (
77
"fmt"
8+
"os"
89
"strconv"
910
"strings"
1011

@@ -82,18 +83,22 @@ func runXFRMFlush() {
8283
}
8384
}
8485

86+
nbDeleted := len(states)
8587
for _, state := range states {
8688
if err := netlink.XfrmStateDel(&state); err != nil {
87-
Fatalf("Stopped XFRM states deletion due to error: %s", err)
89+
fmt.Fprintf(os.Stderr, "Failed to delete XFRM state: %s", err)
90+
nbDeleted--
8891
}
8992
}
90-
fmt.Printf("Deleted %d XFRM states.\n", len(states))
93+
fmt.Printf("Deleted %d XFRM states.\n", nbDeleted)
94+
nbDeleted = len(policies)
9195
for _, pol := range policies {
9296
if err := netlink.XfrmPolicyDel(&pol); err != nil {
93-
Fatalf("Stopped XFRM policies deletion due to error: %s", err)
97+
fmt.Fprintf(os.Stderr, "Failed to delete XFRM policy: %s", err)
98+
nbDeleted--
9499
}
95100
}
96-
fmt.Printf("Deleted %d XFRM policies.\n", len(policies))
101+
fmt.Printf("Deleted %d XFRM policies.\n", nbDeleted)
97102
}
98103

99104
func parseNodeID(nodeID string) (uint16, error) {

0 commit comments

Comments
 (0)