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

KEP-3762: PersistentVolume last phase transition time #3796

Merged

Conversation

RomanBednar
Copy link
Contributor

  • One-line PR description:
    PersistentVolume last phase transition time
  • Other comments:

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 30, 2023
@k8s-ci-robot k8s-ci-robot added kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 30, 2023
@jsafrane
Copy link
Member

From verify CI job: Table of content not up to date. Did you run 'make update-toc' ?

@jsafrane
Copy link
Member

Looks good enough for alpha otherwise.

@xing-yang
Copy link
Contributor

Can you run update-toc.sh to fix the toc syntax error?

@xing-yang
Copy link
Contributor

Please add a file in the following directory for PRR approver:
https://github.com/kubernetes/enhancements/tree/master/keps/prod-readiness/sig-storage

last used, which is when the volume transitioned to `Released` phase.

We can approach the solution in a more generic way and record a timestamp of when the volume transitioned to any phase,
not just to `Released` phase. This allows anyone, incl. our perf tests, to measure time e.g. between a PV `Pending` and `Bound`
Copy link
Member

Choose a reason for hiding this comment

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

also for providing metrics/SLO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

Changes required for this KEP:

* kube-apiserver
* extend PersistentVolumeStatus type with `LastPhaseTransitionTime` field
Copy link
Member

Choose a reason for hiding this comment

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

Can you add the proposed type changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@RomanBednar RomanBednar force-pushed the pv-phase-transition-time branch from d56fd5c to 2491dff Compare February 1, 2023 14:04
@wojtek-t wojtek-t self-assigned this Feb 1, 2023

1) Introduce a new status field in PersistentVolumes.
2) Update the new field with a timestamp every time a volume transitions to a different phase (`pv.Status.Phase`).
3) Improve general observability and allow SLO definitions for Attach/Detach volume operations.
Copy link
Member

Choose a reason for hiding this comment

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

I'm going to take back the use case for a SLO. I think a SLO may be better served by metrics improvements rather than adding timestamps to API objects, especially if we want to consider deletion cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, removing this from goals.

@RomanBednar RomanBednar force-pushed the pv-phase-transition-time branch from 37fd7d7 to adee430 Compare February 3, 2023 08:27
#### Beta

- Allowing time for feedback (at least 2 releases between beta and GA).
- Add unit tests covering feature enablement/disablement.
Copy link
Member

Choose a reason for hiding this comment

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

Can you move it to Alpha? If we want anyone to enable it in alpha (if not then it's not particularly useful), this one seems important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, moved.

No change in cluster upgrade / downgrade process.

When downgrading from a version that added the new timestamp field PVs we need to make sure that after downgrade the
values of the disabled field are removed.
Copy link
Member

Choose a reason for hiding this comment

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

How exactly you're going to achieve it?

I'm assuming you're talking about "eventual removal" here, really, right?
[the controller will unset it on the next processing of that object if it realized FG is disabled and field is set]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but the term "next processing" is still quite broad, it would help to specify it more. The field presence check and resetting could be done:

  1. While updating volume status (updateVolumePhase()) - the downside is that disabling FG will have no effect util volume status changes phase again. This does not seem optimal.
  2. At any PV update - some PRs (e.g. this one) implement this by resetting value of the new field to nil during validation. This approach seems ok, is this a viable option for this enhancement as well? Also this presents a similar caveat as when the FG is enabled - the effect won't be immediate.
  3. Make PV controller actively (on each sync) search for PVs with the new field and reset it if FG is disabled. This seems like an overkill. If the value is correct and reflects real last phase change there's no risk of persisting it in the PV objects even if FG is disabled.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that option (3) is probably an overkill - this is what I meant above as "eventual removal".

I'm not sure if (1) isn't good enough - but no matter what decision you will make, it should be explicitly mentioned in the KEP.

Also - @msau42 - for her thoughts on it.

Copy link
Member

@msau42 msau42 Feb 6, 2023

Choose a reason for hiding this comment

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

When a feature is disabled, the api server strategy implementation should drop disabled fields on write, so approach 2) should cover it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @wojtek-t and @msau42 for the feedback - KEP has been updated.

automations, so be extremely careful here.
-->

No. It only adds a new informative field to PV status.
Copy link
Member

Choose a reason for hiding this comment

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

So technically the answer is yes.

You're not changing anything in your cluster, and your PVs will start to contain a new field set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


###### What happens if we reenable the feature if it was previously rolled back?

No issues expected, after rollback the field can be `nil` and validation should allow updates from `nil`.
Copy link
Member

Choose a reason for hiding this comment

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

I guess I missed that in the proposal, but when exactly this field will be set?

I'm assuming that we the status computed in the controller will be different and we will be patching the object.
If so, what happens after enabling the feature for the first time?
We have no idea when the last transition happened, so what we're going to do:

  • will the field remain to be unset?
  • are we going to (somewhat misleadingly) set it to now

Copy link
Member

Choose a reason for hiding this comment

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

[I guess the former, but then let's also add to Caveats section that the field will remain unset until the first change in PV status even after enabling the feature.]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If so, what happens after enabling the feature for the first time?

If feature is enabled for the first time there are two sub-cases where phase is modified that we need to think of:

  1. While provisioner creates a PV it's phase is set to Bound - at this point I'd rather not set the field because it would be misleading, as you said. This field is meant for "last phase change" so it does not make sense to insert something else (like current time) just for the sake of having some value.
  2. Updating volume status (updateVolumePhase()) - this is when the new LastPhaseTransitionTime field and its value appears in PV object for the first time. So it's good idea to write down the caveeats since enabling FG won't have an immediate effect.

Copy link
Member

Choose a reason for hiding this comment

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

OK - so please put that explicitly into your KEP so it's clear what exactly we can expect from this field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this section. Also adding one more design detail to explicitly state that we want to allow timestamp updates, not just from nil.

@msau42
Copy link
Member

msau42 commented Feb 6, 2023

The KEP lgtm once the comments are addressed

@RomanBednar RomanBednar force-pushed the pv-phase-transition-time branch from adee430 to 2d16991 Compare February 7, 2023 12:02
Copy link
Member

@wojtek-t wojtek-t left a comment

Choose a reason for hiding this comment

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

Just one minor nit - other than that LGTM.

NOTE: Also set `disable-supported` to `true` or `false` in `kep.yaml`.
-->

Yes. This will result in the timestamp value being set to `nil`. Mentioned in "Upgrade / Downgrade Strategy" section.
Copy link
Member

Choose a reason for hiding this comment

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

... timestamp value being eventually set to nil. More details in ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


When downgrading from a version that added the new timestamp field PVs we need to make sure that after downgrade the
values of the disabled field are removed. We intend to use API server strategy implementation, more specifically PV
validation, to remove the values - each time a PV gets validated we will set the value to `nil` if feature gate is disabled.
Copy link
Member

Choose a reason for hiding this comment

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

Actually one more thing - k8s validation isn't generally supposed to change anything.

I think what you really want is effectively add that to PrepareForCreate/PrepareForUpdate methods:
https://github.com/kubernetes/kubernetes/blob/master/pkg/registry/core/persistentvolume/strategy.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, this is where I was aiming but shouldn't have used the term "validation" this way. I changed this to be specific about the strategy and the concrete methods.

Comment on lines +414 to +415
Based on exploratory testing we will define an appropriate time tolerance which will represent maximum time limit for
the volume to transition phase.
Copy link
Member

Choose a reason for hiding this comment

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

Won't this result in a flaky test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically yes but this kind of polling is widely used in tests already. For example here. So this will not flake more than any other test that has timeout for some specific action to happen.

- Feature implemented behind a feature flag
- Unit tests completed and enabled
- Add unit tests covering feature enablement/disablement.
- Initial e2e tests completed and enabled
Copy link
Member

Choose a reason for hiding this comment

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

How do you add e2e tests for an alpha feature when the feature is behind a feature gate?

Copy link
Member

Choose a reason for hiding this comment

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

There are dedicated alpha suites for this purpose.

Comment on lines +757 to +762
- [ ] Metrics
- Metric name:
- [Optional] Aggregation method:
- Components exposing the metric:
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth measuring the time it takes to transition phases.

Copy link
Member

Choose a reason for hiding this comment

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

But that depends on what exactly is happening (e.g. type of volume, etc.)
I wouldn't bundle it together with this KEP, at least at this point.

@RomanBednar RomanBednar force-pushed the pv-phase-transition-time branch from 2d16991 to eb33be8 Compare February 8, 2023 13:43
@xing-yang
Copy link
Contributor

Comments are addressed.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 8, 2023
@wojtek-t
Copy link
Member

wojtek-t commented Feb 8, 2023

/lgtm
/approve PRR

Thanks!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RomanBednar, wojtek-t, xing-yang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 8, 2023
@k8s-ci-robot k8s-ci-robot merged commit 561aef2 into kubernetes:master Feb 8, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.27 milestone Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants