From acaeac9590912db0bb208bf6d4877d60a17a75ee Mon Sep 17 00:00:00 2001 From: Jongwoo Han Date: Wed, 7 Aug 2024 15:49:32 +0900 Subject: [PATCH] Rename env to EC2_INSTANCE_TAG Signed-off-by: Jongwoo Han --- .../litmus/ec2-terminate-by-tag/lib/ec2-terminate-by-tag.go | 6 +++--- .../ec2-terminate-by-tag/experiment/ec2-terminate-tag.go | 2 +- experiments/kube-aws/ec2-terminate-by-tag/test/test.yml | 2 +- .../ec2-terminate-by-tag/environment/environment.go | 2 +- pkg/kube-aws/ec2-terminate-by-tag/types/types.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/chaoslib/litmus/ec2-terminate-by-tag/lib/ec2-terminate-by-tag.go b/chaoslib/litmus/ec2-terminate-by-tag/lib/ec2-terminate-by-tag.go index 25e1b3a00..7534cc1d9 100644 --- a/chaoslib/litmus/ec2-terminate-by-tag/lib/ec2-terminate-by-tag.go +++ b/chaoslib/litmus/ec2-terminate-by-tag/lib/ec2-terminate-by-tag.go @@ -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), } } @@ -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{ diff --git a/experiments/kube-aws/ec2-terminate-by-tag/experiment/ec2-terminate-tag.go b/experiments/kube-aws/ec2-terminate-by-tag/experiment/ec2-terminate-tag.go index 378bb1573..9fa3b9ff5 100644 --- a/experiments/kube-aws/ec2-terminate-by-tag/experiment/ec2-terminate-tag.go +++ b/experiments/kube-aws/ec2-terminate-by-tag/experiment/ec2-terminate-tag.go @@ -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, }) diff --git a/experiments/kube-aws/ec2-terminate-by-tag/test/test.yml b/experiments/kube-aws/ec2-terminate-by-tag/test/test.yml index a646b993a..6e91191c3 100644 --- a/experiments/kube-aws/ec2-terminate-by-tag/test/test.yml +++ b/experiments/kube-aws/ec2-terminate-by-tag/test/test.yml @@ -22,7 +22,7 @@ spec: - "3600" env: # value: key:value ex: team:devops - - name: INSTANCE_TAG + - name: EC2_INSTANCE_TAG value: '' - name: CHAOS_NAMESPACE diff --git a/pkg/kube-aws/ec2-terminate-by-tag/environment/environment.go b/pkg/kube-aws/ec2-terminate-by-tag/environment/environment.go index 3c40d710b..3fd69b97f 100644 --- a/pkg/kube-aws/ec2-terminate-by-tag/environment/environment.go +++ b/pkg/kube-aws/ec2-terminate-by-tag/environment/environment.go @@ -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") } diff --git a/pkg/kube-aws/ec2-terminate-by-tag/types/types.go b/pkg/kube-aws/ec2-terminate-by-tag/types/types.go index 972aa4b4e..e6d7d45e7 100644 --- a/pkg/kube-aws/ec2-terminate-by-tag/types/types.go +++ b/pkg/kube-aws/ec2-terminate-by-tag/types/types.go @@ -17,7 +17,7 @@ type ExperimentDetails struct { ChaosPodName string Timeout int Delay int - InstanceTag string + Ec2InstanceTag string Region string InstanceAffectedPerc int ManagedNodegroup string