diff --git a/chaoslib/litmus/aws-ssm-chaos/lib/ssm/aws-ssm-chaos-by-id.go b/chaoslib/litmus/aws-ssm-chaos/lib/ssm/aws-ssm-chaos-by-id.go index 29f5c00d6..5a84ec8fa 100644 --- a/chaoslib/litmus/aws-ssm-chaos/lib/ssm/aws-ssm-chaos-by-id.go +++ b/chaoslib/litmus/aws-ssm-chaos/lib/ssm/aws-ssm-chaos-by-id.go @@ -54,7 +54,7 @@ func PrepareAWSSSMChaosByID(experimentsDetails *experimentTypes.ExperimentDetail return errors.Errorf("no instance id found for chaos injection") } //get the instance id or list of instance ids - instanceIDList := strings.Split(experimentsDetails.EC2InstanceID, ",") + instanceIDList := strings.Split(strings.TrimSpace(experimentsDetails.EC2InstanceID), ",") switch strings.ToLower(experimentsDetails.Sequence) { case "serial": diff --git a/chaoslib/litmus/azure-disk-loss/lib/azure-disk-loss.go b/chaoslib/litmus/azure-disk-loss/lib/azure-disk-loss.go index c76ce5abd..8ea5f1576 100644 --- a/chaoslib/litmus/azure-disk-loss/lib/azure-disk-loss.go +++ b/chaoslib/litmus/azure-disk-loss/lib/azure-disk-loss.go @@ -48,7 +48,7 @@ func PrepareChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients return errors.Errorf("no volume names found to detach") } //get the disk name or list of disk names - diskNameList := strings.Split(experimentsDetails.VirtualDiskNames, ",") + diskNameList := strings.Split(strings.TrimSpace(experimentsDetails.VirtualDiskNames), ",") instanceNamesWithDiskNames, err := diskStatus.GetInstanceNameForDisks(diskNameList, experimentsDetails.SubscriptionID, experimentsDetails.ResourceGroup) if err != nil { diff --git a/chaoslib/litmus/azure-instance-stop/lib/azure-instance-stop.go b/chaoslib/litmus/azure-instance-stop/lib/azure-instance-stop.go index 64594d3ef..f0ea7fca0 100644 --- a/chaoslib/litmus/azure-instance-stop/lib/azure-instance-stop.go +++ b/chaoslib/litmus/azure-instance-stop/lib/azure-instance-stop.go @@ -45,7 +45,7 @@ func PrepareAzureStop(experimentsDetails *experimentTypes.ExperimentDetails, cli return errors.Errorf("no instance name found to stop") } // get the instance name or list of instance names - instanceNameList := strings.Split(experimentsDetails.AzureInstanceName, ",") + instanceNameList := strings.Split(strings.TrimSpace(experimentsDetails.AzureInstanceName), ",") // watching for the abort signal and revert the chaos go abortWatcher(experimentsDetails, instanceNameList) diff --git a/chaoslib/litmus/ebs-loss/lib/ebs-loss-by-id/lib/ebs-loss-by-id.go b/chaoslib/litmus/ebs-loss/lib/ebs-loss-by-id/lib/ebs-loss-by-id.go index 81658dcff..df2d38644 100644 --- a/chaoslib/litmus/ebs-loss/lib/ebs-loss-by-id/lib/ebs-loss-by-id.go +++ b/chaoslib/litmus/ebs-loss/lib/ebs-loss-by-id/lib/ebs-loss-by-id.go @@ -48,7 +48,7 @@ func PrepareEBSLossByID(experimentsDetails *experimentTypes.ExperimentDetails, c return errors.Errorf("no volume id found to detach") } //get the volume id or list of instance ids - volumeIDList := strings.Split(experimentsDetails.EBSVolumeID, ",") + volumeIDList := strings.Split(strings.TrimSpace(experimentsDetails.EBSVolumeID), ",") // watching for the abort signal and revert the chaos go ebsloss.AbortWatcher(experimentsDetails, volumeIDList, abort, chaosDetails) diff --git a/chaoslib/litmus/ec2-terminate-by-id/lib/ec2-terminate-by-id.go b/chaoslib/litmus/ec2-terminate-by-id/lib/ec2-terminate-by-id.go index 51bbea715..bfc7344c5 100644 --- a/chaoslib/litmus/ec2-terminate-by-id/lib/ec2-terminate-by-id.go +++ b/chaoslib/litmus/ec2-terminate-by-id/lib/ec2-terminate-by-id.go @@ -45,7 +45,7 @@ func PrepareEC2TerminateByID(experimentsDetails *experimentTypes.ExperimentDetai return errors.Errorf("no instance id found to terminate") } //get the instance id or list of instance ids - instanceIDList := strings.Split(experimentsDetails.Ec2InstanceID, ",") + instanceIDList := strings.Split(strings.TrimSpace(experimentsDetails.Ec2InstanceID), ",") // watching for the abort signal and revert the chaos go abortWatcher(experimentsDetails, instanceIDList, chaosDetails) diff --git a/chaoslib/litmus/gcp-vm-instance-stop/lib/gcp-vm-instance-stop.go b/chaoslib/litmus/gcp-vm-instance-stop/lib/gcp-vm-instance-stop.go index 8fc2e5e3c..20a9459fa 100644 --- a/chaoslib/litmus/gcp-vm-instance-stop/lib/gcp-vm-instance-stop.go +++ b/chaoslib/litmus/gcp-vm-instance-stop/lib/gcp-vm-instance-stop.go @@ -47,12 +47,12 @@ func PrepareVMStop(computeService *compute.Service, experimentsDetails *experime return errors.Errorf("no instance name found to stop") } // get the instance name or list of instance names - instanceNamesList := strings.Split(experimentsDetails.VMInstanceName, ",") + instanceNamesList := strings.Split(strings.TrimSpace(experimentsDetails.VMInstanceName), ",") if experimentsDetails.InstanceZone == "" { return errors.Errorf("no corresponding zones found for the instances") } // get the zone name or list of corresponding zones for the instances - instanceZonesList := strings.Split(experimentsDetails.InstanceZone, ",") + instanceZonesList := strings.Split(strings.TrimSpace(experimentsDetails.InstanceZone), ",") if len(instanceNamesList) != len(instanceZonesList) { return errors.Errorf("number of instances is not equal to the number of zones") diff --git a/pkg/cloud/aws/ebs/ebs-volume-state.go b/pkg/cloud/aws/ebs/ebs-volume-state.go index 8cc00dc03..124eb6500 100644 --- a/pkg/cloud/aws/ebs/ebs-volume-state.go +++ b/pkg/cloud/aws/ebs/ebs-volume-state.go @@ -104,7 +104,7 @@ func EBSStateCheckByID(volumeIDs, region string) error { if volumeIDs == "" { return errors.Errorf("no volumeID provided, please provide a volume to detach") } - volumeIDList := strings.Split(volumeIDs, ",") + volumeIDList := strings.Split(strings.TrimSpace(volumeIDs), ",") for _, id := range volumeIDList { instanceID, _, err := GetVolumeAttachmentDetails(id, "", region) if err != nil { diff --git a/pkg/cloud/aws/ec2/ec2-instance-status.go b/pkg/cloud/aws/ec2/ec2-instance-status.go index 3daf88409..d35e1e403 100644 --- a/pkg/cloud/aws/ec2/ec2-instance-status.go +++ b/pkg/cloud/aws/ec2/ec2-instance-status.go @@ -44,7 +44,7 @@ func InstanceStatusCheckByID(instanceID, region string) error { if instanceID == "" { return errors.Errorf("no instance id found to terminate") } - instanceIDList := strings.Split(instanceID, ",") + instanceIDList := strings.Split(strings.TrimSpace(instanceID), ",") log.Infof("[Info]: The instances under chaos(IUC) are: %v", instanceIDList) return InstanceStatusCheck(instanceIDList, region) } diff --git a/pkg/cloud/azure/instance/instance-status.go b/pkg/cloud/azure/instance/instance-status.go index e6a568854..d04946e61 100644 --- a/pkg/cloud/azure/instance/instance-status.go +++ b/pkg/cloud/azure/instance/instance-status.go @@ -74,7 +74,7 @@ func InstanceStatusCheckByName(azureInstanceNames, scaleSet, subscriptionID, res if azureInstanceNames == "" { return errors.Errorf("no instance found to check the status") } - instanceNameList := strings.Split(azureInstanceNames, ",") + instanceNameList := strings.Split(strings.TrimSpace(azureInstanceNames), ",") log.Infof("[Info]: The instance under chaos(IUC) are: %v", instanceNameList) switch scaleSet { case "enable": diff --git a/pkg/cloud/gcp/disk-volume-status.go b/pkg/cloud/gcp/disk-volume-status.go index 4529a5b05..7f69a503e 100644 --- a/pkg/cloud/gcp/disk-volume-status.go +++ b/pkg/cloud/gcp/disk-volume-status.go @@ -107,12 +107,12 @@ func DiskVolumeStateCheck(computeService *compute.Service, experimentsDetails *e return errors.Errorf("no disk name provided, please provide the name of the disk") } - diskNamesList := strings.Split(experimentsDetails.DiskVolumeNames, ",") + diskNamesList := strings.Split(strings.TrimSpace(experimentsDetails.DiskVolumeNames), ",") if experimentsDetails.DiskZones == "" { return errors.Errorf("no zone provided, please provide the zone of the disk") } - zonesList := strings.Split(experimentsDetails.DiskZones, ",") + zonesList := strings.Split(strings.TrimSpace(experimentsDetails.DiskZones), ",") if len(diskNamesList) != len(zonesList) { return errors.Errorf("unequal number of disk names and zones found, please verify the input details") diff --git a/pkg/cloud/gcp/vm-instance-status.go b/pkg/cloud/gcp/vm-instance-status.go index 04319dbe4..7326f0d5e 100644 --- a/pkg/cloud/gcp/vm-instance-status.go +++ b/pkg/cloud/gcp/vm-instance-status.go @@ -29,12 +29,12 @@ func InstanceStatusCheckByName(computeService *compute.Service, managedInstanceG if instanceNames == "" { return errors.Errorf("no vm instance name found to stop") } - instanceNamesList := strings.Split(instanceNames, ",") + instanceNamesList := strings.Split(strings.TrimSpace(instanceNames), ",") if instanceZones == "" { return errors.Errorf("no corresponding zones found for the instances") } - instanceZonesList := strings.Split(instanceZones, ",") + instanceZonesList := strings.Split(strings.TrimSpace(instanceZones), ",") if managedInstanceGroup != "enable" && managedInstanceGroup != "disable" { return errors.Errorf("invalid value for MANAGED_INSTANCE_GROUP: %v", managedInstanceGroup) diff --git a/pkg/cloud/vmware/vm-status.go b/pkg/cloud/vmware/vm-status.go index b461ddf95..46683804b 100644 --- a/pkg/cloud/vmware/vm-status.go +++ b/pkg/cloud/vmware/vm-status.go @@ -61,7 +61,7 @@ func VMStatusCheck(vcenterServer, vmIds, cookie string) error { if vmIds == "" { return errors.Errorf("no vm received, please input the target VMMoids") } - vmIdList := strings.Split(vmIds, ",") + vmIdList := strings.Split(strings.TrimSpace(vmIds), ",") for _, vmId := range vmIdList {