Merge pull request #130352 from natasha41575/kubelet-pod-observedgen

[FG:PodObservedGenerationTracking] Kubelet sets pod `status.observedGeneration` when updating the pod status

Kubernetes-commit: 2effa5e3cf92af7dbcff87822b3293354823f567
This commit is contained in:
Kubernetes Publisher 2025-03-07 13:33:45 -08:00
commit d42a6bba80
5 changed files with 27 additions and 3 deletions

View File

@ -27,6 +27,7 @@ import (
// with apply.
type PodConditionApplyConfiguration struct {
Type *corev1.PodConditionType `json:"type,omitempty"`
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
Status *corev1.ConditionStatus `json:"status,omitempty"`
LastProbeTime *metav1.Time `json:"lastProbeTime,omitempty"`
LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"`
@ -48,6 +49,14 @@ func (b *PodConditionApplyConfiguration) WithType(value corev1.PodConditionType)
return b
}
// WithObservedGeneration sets the ObservedGeneration field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ObservedGeneration field is set to the value of the last call.
func (b *PodConditionApplyConfiguration) WithObservedGeneration(value int64) *PodConditionApplyConfiguration {
b.ObservedGeneration = &value
return b
}
// WithStatus sets the Status field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Status field is set to the value of the last call.

View File

@ -26,6 +26,7 @@ import (
// PodStatusApplyConfiguration represents a declarative configuration of the PodStatus type for use
// with apply.
type PodStatusApplyConfiguration struct {
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
Phase *corev1.PodPhase `json:"phase,omitempty"`
Conditions []PodConditionApplyConfiguration `json:"conditions,omitempty"`
Message *string `json:"message,omitempty"`
@ -50,6 +51,14 @@ func PodStatus() *PodStatusApplyConfiguration {
return &PodStatusApplyConfiguration{}
}
// WithObservedGeneration sets the ObservedGeneration field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ObservedGeneration field is set to the value of the last call.
func (b *PodStatusApplyConfiguration) WithObservedGeneration(value int64) *PodStatusApplyConfiguration {
b.ObservedGeneration = &value
return b
}
// WithPhase sets the Phase field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Phase field is set to the value of the last call.

View File

@ -6926,6 +6926,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: message
type:
scalar: string
- name: observedGeneration
type:
scalar: numeric
- name: reason
type:
scalar: string
@ -7290,6 +7293,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: nominatedNodeName
type:
scalar: string
- name: observedGeneration
type:
scalar: numeric
- name: phase
type:
scalar: string

2
go.mod
View File

@ -26,7 +26,7 @@ require (
golang.org/x/time v0.7.0
google.golang.org/protobuf v1.35.2
gopkg.in/evanphx/json-patch.v4 v4.12.0
k8s.io/api v0.0.0-20250307053018-84fcd81bee60
k8s.io/api v0.0.0-20250308012953-aaba1486ac7a
k8s.io/apimachinery v0.0.0-20250306085752-a3f7d4eded06
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7

4
go.sum
View File

@ -148,8 +148,8 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.0.0-20250307053018-84fcd81bee60 h1:5w11QoDvikZvD0aqRSNq5Oq69zco5d2A/b/qt6/XqV8=
k8s.io/api v0.0.0-20250307053018-84fcd81bee60/go.mod h1:G18UCv44PFPN4QtOrDTocD/18UTFN7LHvSxz0SmxMvI=
k8s.io/api v0.0.0-20250308012953-aaba1486ac7a h1:CVg1KaTJxBY1ioWoyE5YJ3nk4MWuYR0l3YNh1OhHYn4=
k8s.io/api v0.0.0-20250308012953-aaba1486ac7a/go.mod h1:G18UCv44PFPN4QtOrDTocD/18UTFN7LHvSxz0SmxMvI=
k8s.io/apimachinery v0.0.0-20250306085752-a3f7d4eded06 h1:Q+BA4tyKlrCyXCHNHhiDIxMYz7JWeybRTlXmJeGvofY=
k8s.io/apimachinery v0.0.0-20250306085752-a3f7d4eded06/go.mod h1:0rVRgdlgja0MQ+SYCognm5pRNteQOvhHAsDpKOs48GU=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=