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

Fix deleting instances with replicant attribute set #5176

Merged
merged 15 commits into from
Apr 15, 2024

Conversation

ismirlia
Copy link
Collaborator

@ismirlia ismirlia commented Mar 6, 2024

When the pi_replicant field is set in terraform it creates a bunch of vms as expected, but terraform destroy does not delete these.

This fixes: #5168

--- PASS: TestAccIBMPIInstanceBasic (680.22s)
PASS

--- PASS: TestAccIBMPIInstanceNetwork (1123.39s)
PASS

--- PASS: TestAccIBMPIInstanceReplicant (1914.63s)
PASS

@ismirlia ismirlia changed the title Replicant delete Fix deleting instances with replicant attribute set Mar 6, 2024
@ismirlia ismirlia added the service/Power Systems Issues related to Power Systems label Mar 7, 2024
@michaelkad
Copy link
Collaborator

@ismirlia could you add the acceptance test for this?

@yussufsh
Copy link
Collaborator

yussufsh commented Mar 8, 2024

@ismirlia could you add the acceptance test for this?

Even I would like to see the interesting results :) This has been the way since how many years I don't know.
@ismirlia Also you will need to handle update flow for every replicant. Good work btw!

@ismirlia
Copy link
Collaborator Author

ismirlia commented Mar 8, 2024

@yussufsh @michaelkad so right now, update only updates the original instance and not the replicants. Should the goal be to update the replicants as well when any update is made? So this could work for some types of updates potentially, but it couldn't work for others. Like for example you couldn't update the name to match for all of them.

I'm still working on running the tests, got delayed by the reapply quesion @surajsbharadwaj had.

@ismirlia
Copy link
Collaborator Author

@yussufsh updating all of them in one go is also not currently how the API/CLI work in that regard either.

@ismirlia
Copy link
Collaborator Author

Are there any more comments on this? @yussufsh @hkantare ? Updating every replicant at once is not supported, and is not supported by the API. This PR updates just deletion, when including a replicant, and fixes up some of the instance terraform acceptance tests.

Comment on lines 858 to 863
err = client.Delete(instanceID)
if err != nil {
return diag.FromErr(err)
}

_, err = isWaitForPIInstanceDeleted(ctx, client, instanceID)
if err != nil {
return diag.FromErr(err)
_, err = isWaitForPIInstanceDeleted(ctx, client, instanceID)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If instead of delete-wait and loop again, can we have two loops? One loop will delete all the instances and the other loop will check the deletion status. This will save lots of time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes.

@ismirlia ismirlia requested a review from yussufsh April 1, 2024 17:03
Copy link
Collaborator

@yussufsh yussufsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@yussufsh
Copy link
Collaborator

yussufsh commented Apr 8, 2024

lgtm

@ismirlia if an update is not supported can we add a statement in the doc? I am not sure why updating the replicants is not supported. Should be using the same logic as create/delete.

@ismirlia
Copy link
Collaborator Author

ismirlia commented Apr 8, 2024

lgtm

@ismirlia if an update is not supported can we add a statement in the doc? I am not sure why updating the replicants is not supported. Should be using the same logic as create/delete.

Updating the replicants is not really supported by the semantics of the API. This multi-delete approach is already stretching the supported capabilities of what this resource should do.

The markdown file needs to be updated? pi_instance.html.markdown?

@yussufsh
Copy link
Collaborator

yussufsh commented Apr 8, 2024

I understand but then it is always a possibility that user updates the instance details and expect every replicant is getting updated. Imagine if user changes the memory to reduce cost over 50 instances for example, getting to know after some days that changes did not happen and incurred avoidable expenses.
Anyways I'm also fine adding a warning in instance markdown against replicants, so user understands the risks before using the variable.

@ismirlia
Copy link
Collaborator Author

ismirlia commented Apr 9, 2024

I made the changes and added the warning:

Screenshot 2024-04-09 at 8 15 39 AM

@ismirlia ismirlia requested a review from yussufsh April 9, 2024 13:16
Copy link
Collaborator

@yussufsh yussufsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@hkantare hkantare merged commit 74ae14c into IBM-Cloud:master Apr 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/Power Systems Issues related to Power Systems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PowerVS: ibm_pi_instance: pi_replicants parameter , on destroy fails to clean up., on reapply config changes
4 participants