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

VCMP Guest deleteVirtualDisk only checks first disk name #1014

Closed
ThomasBartnicki opened this issue Oct 1, 2024 · 2 comments · Fixed by #1026
Closed

VCMP Guest deleteVirtualDisk only checks first disk name #1014

ThomasBartnicki opened this issue Oct 1, 2024 · 2 comments · Fixed by #1026
Labels
Backlog issue will be tracked by JIRA in backlog bug waiting-response

Comments

@ThomasBartnicki
Copy link

Environment

  • TMOS/Bigip Version: 15.1.6.1
  • Terraform Version: 1.9.6
  • Terraform bigip provider Version: 1.22.3

Summary

When performing a terraform destroy on a vcmp guest, an error is thrown if the first virtual disk result doesn't match the one being deleted.

When looping through the virtual disks, we should move to the next one if the current one isn't the one we're trying to delete, not throw an error.

func deleteVirtualDisk(d *schema.ResourceData, meta interface{}) error {
	diskName, _ := d.Get("virtual_disk").(string)
	client := meta.(*bigip.BigIP)
	virtualDisks, err := client.GetVcmpDisks()
	if err != nil {
		return fmt.Errorf("error retrieving vCMP virtual disks: %v", err)
	}

	for _, disk := range virtualDisks.Disks {
		if strings.HasPrefix(disk.Name, diskName) {
			name := strings.Replace(disk.Name, "/", "~", 1)
			err := client.DeleteVcmpDisk(name)
			if err != nil {
				return fmt.Errorf("error deleting vCMP virtual disk: %v %v", diskName, err)
			}
		} else {
			return fmt.Errorf("cannot find vCMP virtual disk: %v ", diskName)
		}

	}
	return nil
}

Steps To Reproduce

Steps to reproduce the behavior:

Run a terraform destroy after having created a VCMP guest on a BigIP host with multiple virtual-disks on it.

  1. Provide terraform resource config which you are facing trouble along with the output of it.
    N/A
  2. To get to know more about the issue, provide terraform debug logs
    N/A
  3. To capture debug logs, export TF_LOG variable with debug ( export TF_LOG= DEBUG ) before
    runnning terraform apply/plan
    N/A
  4. As3/DO json along with the resource config( for AS3/DO resource issues )
    N/A

Expected Behavior

Delete the virtual disk belonging to the current VCMP guest.

Actual Behavior

Throws an error if the first virtual disk in the list isn't the one belonging to the current VCMP guest.

Error thrown: Couldn't find disk: %s", disk.Name

ThomasBartnicki added a commit to ThomasBartnicki/terraform-provider-bigip that referenced this issue Oct 1, 2024
Loop through all virtual disks before failing with "cannot find vCMP virtual disk" error.
@pgouband
Copy link
Collaborator

pgouband commented Oct 3, 2024

Hi @ThomasBartnicki,

In order to review and accept your commit, you need to sign a Customer License Agreement and send it to [email protected]

https://clouddocs.f5.com/products/orchestration/ansible/devel/_downloads/b35c2904c64e94ec52f5e300bfbebfc4/F5-Contributor-License-Agreement.pdf

@pgouband pgouband added Backlog issue will be tracked by JIRA in backlog waiting-response labels Oct 3, 2024
@pgouband
Copy link
Collaborator

pgouband commented Oct 3, 2024

Hi,

Thanks for reporting. Added to the backlog and internal tracking ID for this request is: INFRAANO-1671.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backlog issue will be tracked by JIRA in backlog bug waiting-response
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants