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

[CCE] Resource flexibleengine_cce_pvc import always returns OK #892

Closed
azrod opened this issue Jan 8, 2023 · 1 comment · Fixed by #902
Closed

[CCE] Resource flexibleengine_cce_pvc import always returns OK #892

azrod opened this issue Jan 8, 2023 · 1 comment · Fixed by #902
Assignees
Milestone

Comments

@azrod
Copy link
Contributor

azrod commented Jan 8, 2023

In resource flexibleengine_cce_pvc import always returns OK

This bug is in HuaweiCloud Importer function for cce_vpc (Ref). This function call GetCcePvcInfoById func (Ref).

func GetCcePvcInfoById(c *golangsdk.ServiceClient, clusterId, namespace,
	id string) (*persistentvolumeclaims.PersistentVolumeClaim, error) {
	pages, err := persistentvolumeclaims.List(c, clusterId, namespace).AllPages()
	if err != nil {
		return nil, err
	}
	responses, err := persistentvolumeclaims.ExtractPersistentVolumeClaims(pages)
	if err != nil {
		return nil, err
	}
	for _, v := range responses {
		if v.Metadata.UID == id {
			return &v, nil
		}
	}
	// PVC has not exist.
	return nil, nil
}

This function always return nil,nil if PVC has not exist. And in func resourceCcePvcResourceImportState if GetCcePvcInfoById return nil,nil no error is returned

	resp, err := GetCcePvcInfoById(c, clsuterId, namespace, parts[2])
	if err != nil {
		return []*schema.ResourceData{d}, err
	}
	d.SetId(resp.Metadata.UID)
	d.Set("cluster_id", parts[0])
	d.Set("namespace", parts[1])

	return []*schema.ResourceData{d}, nil

Result the resource is always imported even if it does not exist

References

@ShiChangkuo ShiChangkuo self-assigned this Jan 9, 2023
@azrod
Copy link
Contributor Author

azrod commented Jan 11, 2023

Track PR in terraform-huaweicloud-provider

@azrod azrod changed the title Resource flexibleengine_cce_pvc import always returns OK [CCE] Resource flexibleengine_cce_pvc import always returns OK Jan 11, 2023
@ShiChangkuo ShiChangkuo added this to the v1.36.0 milestone Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants