@@ -2,6 +2,7 @@ package experiment
2
2
3
3
import (
4
4
"os"
5
+ "strings"
5
6
6
7
"github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1"
7
8
litmusLIB "github.com/litmuschaos/litmus-go/chaoslib/litmus/node-drain/lib"
@@ -68,6 +69,14 @@ func NodeDrain(clients clients.ClientSets) {
68
69
"Chaos Duration" : experimentsDetails .ChaosDuration ,
69
70
})
70
71
72
+ targetNodes := strings .Split (experimentsDetails .TargetNodes , "," )
73
+ if len (targetNodes ) == 0 {
74
+ log .Errorf ("No target nodes provided, expected the comma-separated names of one or more nodes" )
75
+ failStep := "[pre-chaos]: No target nodes provided, expected the comma-separated names of one or more nodes"
76
+ result .RecordAfterFailure (& chaosDetails , & resultDetails , failStep , clients , & eventsDetails )
77
+ return
78
+ }
79
+
71
80
// Calling AbortWatcher go routine, it will continuously watch for the abort signal and generate the required events and result
72
81
go common .AbortWatcherWithoutExit (experimentsDetails .ExperimentName , clients , & resultDetails , & chaosDetails , & eventsDetails )
73
82
@@ -93,13 +102,15 @@ func NodeDrain(clients clients.ClientSets) {
93
102
94
103
// Checking the status of target nodes
95
104
log .Info ("[Status]: Getting the status of target nodes" )
96
- if err := status .CheckNodeStatus (experimentsDetails .TargetNodes , experimentsDetails .Timeout , experimentsDetails .Delay , clients ); err != nil {
97
- log .Errorf ("Target nodes are not in the ready state, err: %v" , err )
98
- failStep := "[pre-chaos]: Failed to verify the status of nodes, err: " + err .Error ()
99
- types .SetEngineEventAttributes (& eventsDetails , types .PreChaosCheck , "NUT: Not Ready" , "Warning" , & chaosDetails )
100
- events .GenerateEvents (& eventsDetails , clients , & chaosDetails , "ChaosEngine" )
101
- result .RecordAfterFailure (& chaosDetails , & resultDetails , failStep , clients , & eventsDetails )
102
- return
105
+ for _ , targetNode := range targetNodes {
106
+ if err := status .CheckNodeStatus (targetNode , experimentsDetails .Timeout , experimentsDetails .Delay , clients ); err != nil {
107
+ log .Errorf ("Target nodes are not in the ready state, err: %v" , err )
108
+ failStep := "[pre-chaos]: Failed to verify the status of nodes, err: " + err .Error ()
109
+ types .SetEngineEventAttributes (& eventsDetails , types .PreChaosCheck , "NUT: Not Ready" , "Warning" , & chaosDetails )
110
+ events .GenerateEvents (& eventsDetails , clients , & chaosDetails , "ChaosEngine" )
111
+ result .RecordAfterFailure (& chaosDetails , & resultDetails , failStep , clients , & eventsDetails )
112
+ return
113
+ }
103
114
}
104
115
105
116
if experimentsDetails .EngineName != "" {
@@ -166,10 +177,12 @@ func NodeDrain(clients clients.ClientSets) {
166
177
167
178
// Checking the status of target nodes
168
179
log .Info ("[Status]: Getting the status of target nodes" )
169
- if err := status .CheckNodeStatus (experimentsDetails .TargetNodes , experimentsDetails .Timeout , experimentsDetails .Delay , clients ); err != nil {
170
- log .Warnf ("Target nodes are not in the ready state, you may need to manually recover the node, err: %v" , err )
171
- types .SetEngineEventAttributes (& eventsDetails , types .PostChaosCheck , "NUT: Not Ready" , "Warning" , & chaosDetails )
172
- events .GenerateEvents (& eventsDetails , clients , & chaosDetails , "ChaosEngine" )
180
+ for _ , targetNode := range targetNodes {
181
+ if err := status .CheckNodeStatus (targetNode , experimentsDetails .Timeout , experimentsDetails .Delay , clients ); err != nil {
182
+ log .Warnf ("Target nodes are not in the ready state, you may need to manually recover the node, err: %v" , err )
183
+ types .SetEngineEventAttributes (& eventsDetails , types .PostChaosCheck , "NUT: Not Ready" , "Warning" , & chaosDetails )
184
+ events .GenerateEvents (& eventsDetails , clients , & chaosDetails , "ChaosEngine" )
185
+ }
173
186
}
174
187
175
188
if experimentsDetails .EngineName != "" {
0 commit comments