Skip to content

Commit

Permalink
CHAOS-181: Try to recover better from stuck nodeFailure disruptions (#…
Browse files Browse the repository at this point in the history
…453)

* CHAOS-181: If running a nodefailure, check for missing nodes when clenaing

* Log the targetNodeName in the injector

* make deps
  • Loading branch information
ptnapoleon authored Dec 10, 2021
1 parent 1a7229c commit 3a2db43
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 724 deletions.
2 changes: 0 additions & 2 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ github.com/markbates/pkger,github.com/markbates/pkger,MIT
github.com/markbates/pkger,github.com/markbates/pkger/here,MIT
github.com/markbates/pkger,github.com/markbates/pkger/internal/maps,MIT
github.com/markbates/pkger,github.com/markbates/pkger/pkging,MIT
github.com/markbates/pkger,github.com/markbates/pkger/pkging/embed,MIT
github.com/markbates/pkger,github.com/markbates/pkger/pkging/mem,MIT
github.com/markbates/pkger,github.com/markbates/pkger/pkging/stdos,MIT
github.com/mattn/go-colorable,github.com/mattn/go-colorable,MIT
github.com/mattn/go-isatty,github.com/mattn/go-isatty,MIT
Expand Down
2 changes: 2 additions & 0 deletions api/disruption_kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type DisruptionArgs struct {
DisruptionName string
DisruptionNamespace string
TargetName string
TargetNodeName string
DNSServer string
KubeDNS string
InjectorServiceAccountNamespace string
Expand All @@ -51,6 +52,7 @@ func AppendArgs(args []string, xargs DisruptionArgs) []string {
"--log-context-disruption-name", xargs.DisruptionName,
"--log-context-disruption-namespace", xargs.DisruptionNamespace,
"--log-context-target-name", xargs.TargetName,
"--log-context-target-node-name", xargs.TargetNodeName,
)

// enable dry-run mode
Expand Down
4 changes: 4 additions & 0 deletions cli/injector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var (
disruptionNamespace string
chaosNamespace string
targetName string
targetNodeName string
onInit bool
handlerPID uint32
configs []injector.Config
Expand Down Expand Up @@ -91,6 +92,7 @@ func init() {
rootCmd.PersistentFlags().StringVar(&disruptionName, "log-context-disruption-name", "", "Log value: current disruption name")
rootCmd.PersistentFlags().StringVar(&disruptionNamespace, "log-context-disruption-namespace", "", "Log value: current disruption namespace")
rootCmd.PersistentFlags().StringVar(&targetName, "log-context-target-name", "", "Log value: current target name")
rootCmd.PersistentFlags().StringVar(&targetNodeName, "log-context-target-node-name", "", "Log value: node hosting the current target pod")

_ = cobra.MarkFlagRequired(rootCmd.PersistentFlags(), "level")
cobra.OnInitialize(initLogger)
Expand Down Expand Up @@ -130,6 +132,7 @@ func initLogger() {
"disruptionName", disruptionName,
"disruptionNamespace", disruptionNamespace,
"targetName", targetName,
"targetNodeName", targetNodeName,
)
}

Expand Down Expand Up @@ -245,6 +248,7 @@ func initConfig() {
Level: chaostypes.DisruptionLevel(level),
TargetContainer: ctns[i],
TargetPodIP: targetPodIP,
TargetNodeName: targetNodeName,
Cgroup: cgroupMgr,
Netns: netnsMgr,
K8sClient: clientset,
Expand Down
1 change: 1 addition & 0 deletions controllers/disruption_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ func (r *DisruptionReconciler) generateChaosPods(instance *chaosv1beta1.Disrupti
Kind: kind,
TargetContainerIDs: targetContainerIDs,
TargetName: targetName,
TargetNodeName: targetNodeName,
TargetPodIP: targetPodIP,
DryRun: instance.Spec.DryRun,
DisruptionName: instance.Name,
Expand Down
1 change: 1 addition & 0 deletions injector/injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Config struct {
Level types.DisruptionLevel
TargetContainer container.Container
TargetPodIP string
TargetNodeName string
Cgroup cgroup.Manager
Netns netns.Manager
K8sClient kubernetes.Interface
Expand Down
8 changes: 8 additions & 0 deletions targetselector/running_target_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ func (r runningTargetSelector) TargetIsHealthy(target string, c client.Client, i
if p.Status.Phase != corev1.PodRunning {
return errors.New("pod is not Running")
}

// check if pod's node is gone in the case that this was a node failure
if instance.Spec.NodeFailure != nil {
var n corev1.Node
if err := c.Get(context.Background(), client.ObjectKey{Name: p.Spec.NodeName}, &n); err != nil {
return err
}
}
case chaostypes.DisruptionLevelNode:
var n corev1.Node
if err := c.Get(context.Background(), client.ObjectKey{Name: target}, &n); err != nil {
Expand Down
55 changes: 0 additions & 55 deletions vendor/github.com/markbates/pkger/pkging/embed/embed.go

This file was deleted.

14 changes: 0 additions & 14 deletions vendor/github.com/markbates/pkger/pkging/embed/file.go

This file was deleted.

104 changes: 0 additions & 104 deletions vendor/github.com/markbates/pkger/pkging/mem/add.go

This file was deleted.

92 changes: 0 additions & 92 deletions vendor/github.com/markbates/pkger/pkging/mem/embed.go

This file was deleted.

Loading

0 comments on commit 3a2db43

Please sign in to comment.