Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename env to EC2_INSTANCE_TAG #708

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading