@@ -13,7 +13,7 @@ import (
13
13
"github.com/litmuschaos/litmus-go/pkg/probe"
14
14
"github.com/litmuschaos/litmus-go/pkg/types"
15
15
"github.com/litmuschaos/litmus-go/pkg/utils/common"
16
- "github.com/pkg/errors "
16
+ "github.com/palantir/stacktrace "
17
17
)
18
18
19
19
// InjectChaosInSerialMode will inject the aws ssm chaos in serial mode that is one after other
@@ -46,29 +46,29 @@ func InjectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai
46
46
ec2IDList := strings .Fields (ec2ID )
47
47
commandId , err := ssm .SendSSMCommand (experimentsDetails , ec2IDList )
48
48
if err != nil {
49
- return errors . Errorf ( "fail to send ssm command, err: %v" , err )
49
+ return stacktrace . Propagate ( err , "failed to send ssm command" )
50
50
}
51
51
//prepare commands for abort recovery
52
52
experimentsDetails .CommandIDs = append (experimentsDetails .CommandIDs , commandId )
53
53
54
54
//wait for the ssm command to get in running state
55
55
log .Info ("[Wait]: Waiting for the ssm command to get in InProgress state" )
56
56
if err := ssm .WaitForCommandStatus ("InProgress" , commandId , ec2ID , experimentsDetails .Region , experimentsDetails .ChaosDuration + experimentsDetails .Timeout , experimentsDetails .Delay ); err != nil {
57
- return errors . Errorf ( "fail to start ssm command, err: %v" , err )
57
+ return stacktrace . Propagate ( err , "failed to start ssm command" )
58
58
}
59
59
common .SetTargets (ec2ID , "injected" , "EC2" , chaosDetails )
60
60
61
61
// run the probes during chaos
62
62
if len (resultDetails .ProbeDetails ) != 0 && i == 0 {
63
63
if err = probe .RunProbes (chaosDetails , clients , resultDetails , "DuringChaos" , eventsDetails ); err != nil {
64
- return err
64
+ return stacktrace . Propagate ( err , "failed to run probes" )
65
65
}
66
66
}
67
67
68
68
//wait for the ssm command to get succeeded in the given chaos duration
69
69
log .Info ("[Wait]: Waiting for the ssm command to get completed" )
70
70
if err := ssm .WaitForCommandStatus ("Success" , commandId , ec2ID , experimentsDetails .Region , experimentsDetails .ChaosDuration + experimentsDetails .Timeout , experimentsDetails .Delay ); err != nil {
71
- return errors . Errorf ( "fail to send ssm command, err: %v" , err )
71
+ return stacktrace . Propagate ( err , "failed to send ssm command" )
72
72
}
73
73
common .SetTargets (ec2ID , "reverted" , "EC2" , chaosDetails )
74
74
@@ -110,7 +110,7 @@ func InjectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
110
110
log .Info ("[Chaos]: Starting the ssm command" )
111
111
commandId , err := ssm .SendSSMCommand (experimentsDetails , instanceIDList )
112
112
if err != nil {
113
- return errors . Errorf ( "fail to send ssm command, err: %v" , err )
113
+ return stacktrace . Propagate ( err , "failed to send ssm command" )
114
114
}
115
115
//prepare commands for abort recovery
116
116
experimentsDetails .CommandIDs = append (experimentsDetails .CommandIDs , commandId )
@@ -119,22 +119,22 @@ func InjectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
119
119
//wait for the ssm command to get in running state
120
120
log .Info ("[Wait]: Waiting for the ssm command to get in InProgress state" )
121
121
if err := ssm .WaitForCommandStatus ("InProgress" , commandId , ec2ID , experimentsDetails .Region , experimentsDetails .ChaosDuration + experimentsDetails .Timeout , experimentsDetails .Delay ); err != nil {
122
- return errors . Errorf ( "fail to start ssm command, err: %v" , err )
122
+ return stacktrace . Propagate ( err , "failed to start ssm command" )
123
123
}
124
124
}
125
125
126
126
// run the probes during chaos
127
127
if len (resultDetails .ProbeDetails ) != 0 {
128
128
if err = probe .RunProbes (chaosDetails , clients , resultDetails , "DuringChaos" , eventsDetails ); err != nil {
129
- return err
129
+ return stacktrace . Propagate ( err , "failed to run probes" )
130
130
}
131
131
}
132
132
133
133
for _ , ec2ID := range instanceIDList {
134
134
//wait for the ssm command to get succeeded in the given chaos duration
135
135
log .Info ("[Wait]: Waiting for the ssm command to get completed" )
136
136
if err := ssm .WaitForCommandStatus ("Success" , commandId , ec2ID , experimentsDetails .Region , experimentsDetails .ChaosDuration + experimentsDetails .Timeout , experimentsDetails .Delay ); err != nil {
137
- return errors . Errorf ( "fail to send ssm command, err: %v" , err )
137
+ return stacktrace . Propagate ( err , "failed to send ssm command" )
138
138
}
139
139
}
140
140
@@ -159,14 +159,14 @@ func AbortWatcher(experimentsDetails *experimentTypes.ExperimentDetails, abort c
159
159
case len (experimentsDetails .CommandIDs ) != 0 :
160
160
for _ , commandId := range experimentsDetails .CommandIDs {
161
161
if err := ssm .CancelCommand (commandId , experimentsDetails .Region ); err != nil {
162
- log .Errorf ("[Abort]: fail to cancle command, recovery failed, err : %v" , err )
162
+ log .Errorf ("[Abort]: Failed to cancel command, recovery failed: %v" , err )
163
163
}
164
164
}
165
165
default :
166
- log .Info ("[Abort]: No command found to cancle " )
166
+ log .Info ("[Abort]: No SSM Command found to cancel " )
167
167
}
168
168
if err := ssm .SSMDeleteDocument (experimentsDetails .DocumentName , experimentsDetails .Region ); err != nil {
169
- log .Errorf ("fail to delete ssm doc, err : %v" , err )
169
+ log .Errorf ("Failed to delete ssm document : %v" , err )
170
170
}
171
171
log .Info ("[Abort]: Chaos Revert Completed" )
172
172
os .Exit (1 )
0 commit comments