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 d7208f642..b52dbd223 100644 --- a/chaoslib/litmus/azure-instance-stop/lib/azure-instance-stop.go +++ b/chaoslib/litmus/azure-instance-stop/lib/azure-instance-stop.go @@ -46,7 +46,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.AzureInstanceNames, ",") + instanceNameList := strings.Split(strings.TrimSpace(experimentsDetails.AzureInstanceNames), ",") // 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 9342e1355..ab5e0bd6f 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.Zones == "" { 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.Zones, ",") + instanceZonesList := strings.Split(strings.TrimSpace(experimentsDetails.Zones), ",") 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 ae3b76f15..1961e70cc 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.Zones == "" { return errors.Errorf("no zone provided, please provide the zone of the disk") } - zonesList := strings.Split(experimentsDetails.Zones, ",") + zonesList := strings.Split(strings.TrimSpace(experimentsDetails.Zones), ",") 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 74da86697..5975ead96 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 {