Skip to content

Commit

Permalink
Rename env to EC2_INSTANCE_TAG
Browse files Browse the repository at this point in the history
Signed-off-by: Jongwoo Han <[email protected]>
  • Loading branch information
jongwooo committed Aug 14, 2024
1 parent 10e9b77 commit acaeac9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ func injectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
// SetTargetInstance will select the target instance which are in running state and filtered from the given instance tag
func SetTargetInstance(experimentsDetails *experimentTypes.ExperimentDetails) error {

instanceIDList, err := awslib.GetInstanceList(experimentsDetails.InstanceTag, experimentsDetails.Region)
instanceIDList, err := awslib.GetInstanceList(experimentsDetails.Ec2InstanceTag, experimentsDetails.Region)
if err != nil {
return stacktrace.Propagate(err, "failed to get the instance id list")
}
if len(instanceIDList) == 0 {
return cerrors.Error{
ErrorCode: cerrors.ErrorTypeTargetSelection,
Reason: fmt.Sprintf("no instance found with the given tag %v, in region %v", experimentsDetails.InstanceTag, experimentsDetails.Region),
Reason: fmt.Sprintf("no instance found with the given tag %v, in region %v", experimentsDetails.Ec2InstanceTag, experimentsDetails.Region),
}
}

Expand All @@ -246,7 +246,7 @@ func SetTargetInstance(experimentsDetails *experimentTypes.ExperimentDetails) er
return cerrors.Error{
ErrorCode: cerrors.ErrorTypeChaosInject,
Reason: "failed to get any running instance",
Target: fmt.Sprintf("EC2 Instance Tag: %v", experimentsDetails.InstanceTag)}
Target: fmt.Sprintf("EC2 Instance Tag: %v", experimentsDetails.Ec2InstanceTag)}
}

log.InfoWithValues("[Info]: Targeting the running instances filtered from instance tag", logrus.Fields{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func EC2TerminateByTag(clients clients.ClientSets) {
log.InfoWithValues("The instance information is as follows", logrus.Fields{
"Chaos Duration": experimentsDetails.ChaosDuration,
"Chaos Namespace": experimentsDetails.ChaosNamespace,
"Instance Tag": experimentsDetails.InstanceTag,
"Instance Tag": experimentsDetails.Ec2InstanceTag,
"Instance Affected Percentage": experimentsDetails.InstanceAffectedPerc,
"Sequence": experimentsDetails.Sequence,
})
Expand Down
2 changes: 1 addition & 1 deletion experiments/kube-aws/ec2-terminate-by-tag/test/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
- "3600"
env:
# value: key:value ex: team:devops
- name: INSTANCE_TAG
- name: EC2_INSTANCE_TAG
value: ''

- name: CHAOS_NAMESPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails) {
experimentDetails.Timeout, _ = strconv.Atoi(types.Getenv("STATUS_CHECK_TIMEOUT", "180"))
experimentDetails.Region = types.Getenv("REGION", "")
experimentDetails.ManagedNodegroup = types.Getenv("MANAGED_NODEGROUP", "disable")
experimentDetails.InstanceTag = strings.TrimSpace(types.Getenv("INSTANCE_TAG", ""))
experimentDetails.Ec2InstanceTag = strings.TrimSpace(types.Getenv("EC2_INSTANCE_TAG", ""))
experimentDetails.InstanceAffectedPerc, _ = strconv.Atoi(types.Getenv("INSTANCE_AFFECTED_PERC", "0"))
experimentDetails.Sequence = types.Getenv("SEQUENCE", "parallel")
}
2 changes: 1 addition & 1 deletion pkg/kube-aws/ec2-terminate-by-tag/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ExperimentDetails struct {
ChaosPodName string
Timeout int
Delay int
InstanceTag string
Ec2InstanceTag string
Region string
InstanceAffectedPerc int
ManagedNodegroup string
Expand Down

0 comments on commit acaeac9

Please sign in to comment.