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

Support persistent volume last phase transition time feature gate field last phase transition time in persistent volume status #2417

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

theloneexplorerquest
Copy link

@theloneexplorerquest theloneexplorerquest commented Feb 6, 2024

Description

resolve #2399

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

Release Note

Release note for CHANGELOG:

Support PersistentVolumeLastPhaseTransitionTime feature gate in persistent volume status. 

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

@hashicorp-cla
Copy link

hashicorp-cla commented Feb 6, 2024

CLA assistant check
All committers have signed the CLA.

@theloneexplorerquest theloneexplorerquest marked this pull request as ready for review February 9, 2024 22:50
@theloneexplorerquest theloneexplorerquest requested a review from a team as a code owner February 9, 2024 22:50
…ime-feature-gate-field-lastPhaseTransitionTime-in-PersistentVolumeStatus
statusMessage := fmt.Sprintf("%v", out.Status.Message)
if statusMessage == "" {
log.Printf("[DEBUG] Persistent volume %s status received: %#v", out.Name, statusPhase)
} else {

Choose a reason for hiding this comment

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

if message is not None add it to log.
out.Status.Reason is a CamelCase string so does not make sense to display in log

return out, statusPhase, nil
},
}
_, err = stateConf.WaitForStateContext(ctx)
if err != nil {
return diag.FromErr(err)
}
if out.Status.LastPhaseTransitionTime != nil {

Choose a reason for hiding this comment

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

this was added for create, read and delete

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking over this it seems like the use of out.Status.LastPhaseTransitionTime would make sense to have in retry.StateChangeConf since that's where the Phase is being updated. What was the reason to include this outside of retry?

Choose a reason for hiding this comment

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

I put it here because I thought it will report the transition time between pending and available/bound.
During my test I have difficulty of trick pv into pending status (so the retry never happened), so my test is not comprehensive. I will dig a bit more and get back with an updated PR!

Copy link
Contributor

Choose a reason for hiding this comment

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

Having a cluster with only 1 node makes it difficult to have that Pending status show up. I was able to get it to show by setting up a 3 node cluster using minikube by running minikube start --nodes 3 multinode-cluster

Choose a reason for hiding this comment

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

Hi @BBBmau ,

I've been caught up with personal commitments lately. Appreciate your recommendation on minikube; it worked wonders! Here are the logs I managed to generate:

2024-03-07T18:37:59.947+1100 [DEBUG] provider.terraform-provider-kubernetes: 2024/03/07 18:37:59 [DEBUG] Persistent volume example-pv status received: "Pending"
2024-03-07T18:37:59.947+1100 [DEBUG] provider.terraform-provider-kubernetes: 2024/03/07 18:37:59 [DEBUG] Persistent volume last phrase transition time: 2024-03-07 18:37:59 +1100 AEDT
... 
2024-03-07T18:57:04.439+1100 [DEBUG] provider.terraform-provider-kubernetes: 2024/03/07 18:57:04 [DEBUG] Persistent volume example-pv status received: "Available"
2024-03-07T18:57:04.439+1100 [DEBUG] provider.terraform-provider-kubernetes: 2024/03/07 18:57:04 [DEBUG] Persistent volume last phrase transition time: 2024-03-07 18:57:04 +1100 AEDT

I foresee a potential issue where if the refresh code block triggers the sequence PENDING->PENDING->PENDING->AVAILABLE, it might record the same last phrase transition time thrice during the PENDING state. Could this pose a problem? Otherwise, I hope the PR is working as expected 😃

@github-actions github-actions bot added size/S and removed size/XS labels Feb 10, 2024
@github-actions github-actions bot added size/XS and removed size/S labels Feb 10, 2024
@theloneexplorerquest
Copy link
Author

Hi @BBBmau I have updated the PR, please take a look 😊

…ime-feature-gate-field-lastPhaseTransitionTime-in-PersistentVolumeStatus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants