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
Volume resource requirements #118653
Volume resource requirements #118653
Conversation
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
7f58541
to
150bbe9
Compare
pkg/apis/core/types.go
Outdated
// field. It got added by accident, has no meaning here and gets ignored | ||
// silently. | ||
// +optional | ||
Claims []ResourceClaim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark it as deprecated? And throw a warning when user set it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark as deprecated how? A free-form comment?
Do Go linters recognize // Deprecated:
for fields? That's worth checking.
For the warning, that would be a server-side warning, right? I know those exist, but don't know how they are implemented. Do you have a pointer for me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do Go linters recognize // Deprecated: for fields?
No, staticcheck only detects usage of deprecated structs. It still makes sense to use the Deprecated
comment because it makes the intent clearer.
For the warning, that would be a server-side warning, right?
https://kubernetes.io/blog/2020/09/03/warnings/#future-possibilities mentions "warnings about fields" as a future extension. I've asked on #sig-api-machinery whether it is possible today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pohly a server-side warning example
kubernetes/pkg/registry/core/persistentvolume/strategy.go
Lines 79 to 82 in c984d53
// WarningsOnCreate returns warnings for the creation of the given object. | |
func (persistentvolumeStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { | |
return pvutil.GetWarningsForPersistentVolume(obj.(*api.PersistentVolume)) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was already wired up for PersistentVolumeClaimSpec
, so all I had to do was add a new if check there - done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think we should drop the field (with an appropriate tombstone comment recording the json field name and protobuf tag used)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Drop the field" as in "not have it in the struct at all" (except for the comments)?
So breaking client-side validation (= YAML file has it, kubectl complains about unknown field) would be acceptable?
If we can do that, then let's remove the field. It would be cleaner. I just didn't dare... 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was added in 1.27 documented as alpha, right? I'd drop the field in 1.28 and backport a change to 1.27 to clear the field on write from PVCs as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearing on write was already implemented in 1.27: #115928.
Sounds like dropping the field is acceptable. I'll change this PR accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New version pushed which no longer has the field, only a comment about it in core/v1/types.go
.
150bbe9
to
016db7f
Compare
/label api-review |
8517761
to
fd79a15
Compare
needs rebase/regen now that the 1.28.0 API fixtures have been captured and 1.26.0 fixtures dropped |
I had already rebased? Should be okay right now. |
PVC and containers shared the same ResourceRequirements struct to define their API. When resource claims were added, that struct got extended, which accidentally also changed the PVC API. To avoid such a mistake from happening again, PVC now uses its own VolumeResourceRequirements struct. The `Claims` field gets removed because risk of breaking someone is low: theoretically, YAML files which have a claims field for volumes now get rejected when validating against the OpenAPI. Such files have never made sense and should be fixed. Code that uses the struct definitions needs to be updated.
fd79a15
to
b8b9e53
Compare
Ah, I see - there was no merge conflict anymore, but |
b8b9e53
to
f20fc24
Compare
@@ -0,0 +1,77 @@ | |||
apiVersion: v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop all the v1.26.0 files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
f20fc24
to
c1eb18c
Compare
/lgtm |
LGTM label has been added. Git tree hash: b7eda65dfb9fbd07d1c874788a80f6578f0dfd83
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, pohly 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 |
/retest |
ResourceRequirements struct was replaced with VolumeResourceRequirements for use with volumes. kubernetes/kubernetes#118653
ResourceRequirements struct was replaced with VolumeResourceRequirements for use with volumes. kubernetes/kubernetes#118653
@@ -486,7 +486,7 @@ type PersistentVolumeClaimSpec struct { | |||
// status field of the claim. | |||
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources | |||
// +optional | |||
Resources ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,2,opt,name=resources"` | |||
Resources VolumeResourceRequirements `json:"resources,omitempty" protobuf:"bytes,2,opt,name=resources"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a breaking change for consumers of the Go struct.
while we care more to not break the serializable API, the change should have had an action-required in the release note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have documentation on when to use "action-required"? Would it have helped you in this case?
I keep hearing all kinds of opinions about whether Go API changes need to be mentioned at all. I added a release note, but not the "action required" because I assumed that this is reserved for changes that otherwise might silently break users on upgrades. This PR is breaking compilation in an obvious way, so developers will notice that they need to take some action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a release note is sufficient. People who happen to be using this alpha field in their go structs (who I expect will be vanishingly small) will know they need to take action when they update and their code needs a change before it will compile.
I think action required should be reserved for changes which will surprise or break people if they don't read the release notes, or which they can prepare their cluster or workloads for in advance. This is not such a change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, the label is documented as "Denotes a PR that introduces potentially breaking changes that require user action.".
as far as my interpretation goes, it should be added to breaking changes of any kind that require user action.
i was pinged downstream about this, not on a urgent note, and while a go build will catch the problem of the go struct that did not change for 7 years, similar would apply to a client trying to reach a REST API that changed, the user can find right away.
might be worthwhile for us to document some of these aspects in API docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be added to breaking changes of any kind that require user action
If we expand that section of the release notes to include every signature change of every go function in a staging library, that section of the release notes will be so noisy it will be useless. I think it should be reserved for things which require configuration or API changes, would cause problems if they were missed, and could be missed in a cluster upgrade. This is not a change like that.
Upgrading a cluster to the release that included this change does not require people to update their client-go libraries, so I really don't think action is required here.
while a go build will catch the problem of the go struct that did not change for 7 years
to be fair, this was a brand new alpha field, not one that had existed for years, so I sincerely doubt anyone was using it in a way that would require action on a cluster upgrade
edit: my mistake, I mixed this up with a different fixup to a recent alpha field. This field was not alpha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As much as I'd like to believe that the impact was low, unfortunately that's not the case here: this is a change in PersistentVolumeClaimSpec, which is a GA API. I can understand that consumers of our Go API are upset because this causes them work, but I still think it was the right thing to do because accidentally changing the Kubernetes API by sharing the same struct is worse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on my end it was more of a short discussion in the lines of - "is it OK to change the Go structs of a GA API like that?". i responded that for k8s and some other REST APIs projects out there it's not considered an issue. EOD, it depends on what rules a project has.
What type of PR is this?
/kind cleanup
/kind api-change
/sig storage
What this PR does / why we need it:
PVC and containers shared the same ResourceRequirements struct to define their
API. When resource claims were added, that struct got extended, which
accidentally also changed the PVC API. To avoid such a mistake from happening
again, PVC now uses its own VolumeResourceRequirements struct.
Which issue(s) this PR fixes:
Fixes #115845
Special notes for your reviewer:
The struct has to have a
Claims
field because someone might have added it tosome YAML file for use with Kubernetes 1.28 even though it didn't do
anything. Removing the field in Kubernetes 1.29 would cause OpenAPI-based
validation in kubectl to reject such a YAML file.
Does this PR introduce a user-facing change?