mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
replica: serialize created-by reference
Fixes #7322 Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
This commit is contained in:
parent
b9ea2c33f4
commit
37038c4877
@ -64,6 +64,7 @@ func init() {
|
|||||||
&PodProxyOptions{},
|
&PodProxyOptions{},
|
||||||
&ComponentStatus{},
|
&ComponentStatus{},
|
||||||
&ComponentStatusList{},
|
&ComponentStatusList{},
|
||||||
|
&SerializedReference{},
|
||||||
)
|
)
|
||||||
// Legacy names are supported
|
// Legacy names are supported
|
||||||
Scheme.AddKnownTypeWithName("", "Minion", &Node{})
|
Scheme.AddKnownTypeWithName("", "Minion", &Node{})
|
||||||
@ -109,3 +110,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
|||||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||||
func (*ComponentStatus) IsAnAPIObject() {}
|
func (*ComponentStatus) IsAnAPIObject() {}
|
||||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||||
|
func (*SerializedReference) IsAnAPIObject() {}
|
||||||
|
@ -1593,6 +1593,11 @@ type ObjectReference struct {
|
|||||||
FieldPath string `json:"fieldPath,omitempty"`
|
FieldPath string `json:"fieldPath,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SerializedReference struct {
|
||||||
|
TypeMeta `json:",inline"`
|
||||||
|
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||||
|
}
|
||||||
|
|
||||||
type EventSource struct {
|
type EventSource struct {
|
||||||
// Component from which the event is generated.
|
// Component from which the event is generated.
|
||||||
Component string `json:"component,omitempty"`
|
Component string `json:"component,omitempty"`
|
||||||
|
@ -63,6 +63,7 @@ func init() {
|
|||||||
&PodProxyOptions{},
|
&PodProxyOptions{},
|
||||||
&ComponentStatus{},
|
&ComponentStatus{},
|
||||||
&ComponentStatusList{},
|
&ComponentStatusList{},
|
||||||
|
&SerializedReference{},
|
||||||
)
|
)
|
||||||
// Legacy names are supported
|
// Legacy names are supported
|
||||||
api.Scheme.AddKnownTypeWithName("v1", "Minion", &Node{})
|
api.Scheme.AddKnownTypeWithName("v1", "Minion", &Node{})
|
||||||
@ -106,3 +107,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
|||||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||||
func (*ComponentStatus) IsAnAPIObject() {}
|
func (*ComponentStatus) IsAnAPIObject() {}
|
||||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||||
|
func (*SerializedReference) IsAnAPIObject() {}
|
||||||
|
@ -1525,6 +1525,11 @@ type ObjectReference struct {
|
|||||||
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SerializedReference struct {
|
||||||
|
TypeMeta `json:",inline"`
|
||||||
|
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||||
|
}
|
||||||
|
|
||||||
type EventSource struct {
|
type EventSource struct {
|
||||||
// Component from which the event is generated.
|
// Component from which the event is generated.
|
||||||
Component string `json:"component,omitempty" description:"component that generated the event"`
|
Component string `json:"component,omitempty" description:"component that generated the event"`
|
||||||
|
@ -70,6 +70,7 @@ func init() {
|
|||||||
&PodProxyOptions{},
|
&PodProxyOptions{},
|
||||||
&ComponentStatus{},
|
&ComponentStatus{},
|
||||||
&ComponentStatusList{},
|
&ComponentStatusList{},
|
||||||
|
&SerializedReference{},
|
||||||
)
|
)
|
||||||
// Future names are supported
|
// Future names are supported
|
||||||
api.Scheme.AddKnownTypeWithName("v1beta1", "Node", &Minion{})
|
api.Scheme.AddKnownTypeWithName("v1beta1", "Node", &Minion{})
|
||||||
@ -114,3 +115,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
|||||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||||
func (*ComponentStatus) IsAnAPIObject() {}
|
func (*ComponentStatus) IsAnAPIObject() {}
|
||||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||||
|
func (*SerializedReference) IsAnAPIObject() {}
|
||||||
|
@ -1380,6 +1380,11 @@ type ObjectReference struct {
|
|||||||
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SerializedReference struct {
|
||||||
|
TypeMeta `json:",inline"`
|
||||||
|
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||||
|
}
|
||||||
|
|
||||||
// Event is a report of an event somewhere in the cluster.
|
// Event is a report of an event somewhere in the cluster.
|
||||||
// TODO: Decide whether to store these separately or with the object they apply to.
|
// TODO: Decide whether to store these separately or with the object they apply to.
|
||||||
type Event struct {
|
type Event struct {
|
||||||
|
@ -70,6 +70,7 @@ func init() {
|
|||||||
&PodProxyOptions{},
|
&PodProxyOptions{},
|
||||||
&ComponentStatus{},
|
&ComponentStatus{},
|
||||||
&ComponentStatusList{},
|
&ComponentStatusList{},
|
||||||
|
&SerializedReference{},
|
||||||
)
|
)
|
||||||
// Future names are supported
|
// Future names are supported
|
||||||
api.Scheme.AddKnownTypeWithName("v1beta2", "Node", &Minion{})
|
api.Scheme.AddKnownTypeWithName("v1beta2", "Node", &Minion{})
|
||||||
@ -114,3 +115,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
|||||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||||
func (*ComponentStatus) IsAnAPIObject() {}
|
func (*ComponentStatus) IsAnAPIObject() {}
|
||||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||||
|
func (*SerializedReference) IsAnAPIObject() {}
|
||||||
|
@ -1413,6 +1413,11 @@ type ObjectReference struct {
|
|||||||
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SerializedReference struct {
|
||||||
|
TypeMeta `json:",inline"`
|
||||||
|
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||||
|
}
|
||||||
|
|
||||||
// Event is a report of an event somewhere in the cluster.
|
// Event is a report of an event somewhere in the cluster.
|
||||||
// TODO: Decide whether to store these separately or with the object they apply to.
|
// TODO: Decide whether to store these separately or with the object they apply to.
|
||||||
//
|
//
|
||||||
|
@ -2581,6 +2581,26 @@ func convert_api_SecretVolumeSource_To_v1beta3_SecretVolumeSource(in *newer.Secr
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convert_v1beta3_SerializedReference_To_api_SerializedReference(in *SerializedReference, out *newer.SerializedReference, s conversion.Scope) error {
|
||||||
|
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := s.Convert(&in.Reference, &out.Reference, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func convert_api_SerializedReference_To_v1beta3_SerializedReference(in *newer.SerializedReference, out *SerializedReference, s conversion.Scope) error {
|
||||||
|
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := s.Convert(&in.Reference, &out.Reference, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func convert_v1beta3_Service_To_api_Service(in *Service, out *newer.Service, s conversion.Scope) error {
|
func convert_v1beta3_Service_To_api_Service(in *Service, out *newer.Service, s conversion.Scope) error {
|
||||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -3026,6 +3046,7 @@ func init() {
|
|||||||
convert_api_SecretList_To_v1beta3_SecretList,
|
convert_api_SecretList_To_v1beta3_SecretList,
|
||||||
convert_api_SecretVolumeSource_To_v1beta3_SecretVolumeSource,
|
convert_api_SecretVolumeSource_To_v1beta3_SecretVolumeSource,
|
||||||
convert_api_Secret_To_v1beta3_Secret,
|
convert_api_Secret_To_v1beta3_Secret,
|
||||||
|
convert_api_SerializedReference_To_v1beta3_SerializedReference,
|
||||||
convert_api_ServiceList_To_v1beta3_ServiceList,
|
convert_api_ServiceList_To_v1beta3_ServiceList,
|
||||||
convert_api_ServicePort_To_v1beta3_ServicePort,
|
convert_api_ServicePort_To_v1beta3_ServicePort,
|
||||||
convert_api_ServiceSpec_To_v1beta3_ServiceSpec,
|
convert_api_ServiceSpec_To_v1beta3_ServiceSpec,
|
||||||
@ -3128,6 +3149,7 @@ func init() {
|
|||||||
convert_v1beta3_SecretList_To_api_SecretList,
|
convert_v1beta3_SecretList_To_api_SecretList,
|
||||||
convert_v1beta3_SecretVolumeSource_To_api_SecretVolumeSource,
|
convert_v1beta3_SecretVolumeSource_To_api_SecretVolumeSource,
|
||||||
convert_v1beta3_Secret_To_api_Secret,
|
convert_v1beta3_Secret_To_api_Secret,
|
||||||
|
convert_v1beta3_SerializedReference_To_api_SerializedReference,
|
||||||
convert_v1beta3_ServiceList_To_api_ServiceList,
|
convert_v1beta3_ServiceList_To_api_ServiceList,
|
||||||
convert_v1beta3_ServicePort_To_api_ServicePort,
|
convert_v1beta3_ServicePort_To_api_ServicePort,
|
||||||
convert_v1beta3_ServiceSpec_To_api_ServiceSpec,
|
convert_v1beta3_ServiceSpec_To_api_ServiceSpec,
|
||||||
|
@ -63,6 +63,7 @@ func init() {
|
|||||||
&PodProxyOptions{},
|
&PodProxyOptions{},
|
||||||
&ComponentStatus{},
|
&ComponentStatus{},
|
||||||
&ComponentStatusList{},
|
&ComponentStatusList{},
|
||||||
|
&SerializedReference{},
|
||||||
)
|
)
|
||||||
// Legacy names are supported
|
// Legacy names are supported
|
||||||
api.Scheme.AddKnownTypeWithName("v1beta3", "Minion", &Node{})
|
api.Scheme.AddKnownTypeWithName("v1beta3", "Minion", &Node{})
|
||||||
@ -106,3 +107,4 @@ func (*PodExecOptions) IsAnAPIObject() {}
|
|||||||
func (*PodProxyOptions) IsAnAPIObject() {}
|
func (*PodProxyOptions) IsAnAPIObject() {}
|
||||||
func (*ComponentStatus) IsAnAPIObject() {}
|
func (*ComponentStatus) IsAnAPIObject() {}
|
||||||
func (*ComponentStatusList) IsAnAPIObject() {}
|
func (*ComponentStatusList) IsAnAPIObject() {}
|
||||||
|
func (*SerializedReference) IsAnAPIObject() {}
|
||||||
|
@ -1525,6 +1525,11 @@ type ObjectReference struct {
|
|||||||
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
FieldPath string `json:"fieldPath,omitempty" description:"if referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SerializedReference struct {
|
||||||
|
TypeMeta `json:",inline"`
|
||||||
|
Reference ObjectReference `json:"reference,omitempty" description:"the reference to an object in the system"`
|
||||||
|
}
|
||||||
|
|
||||||
type EventSource struct {
|
type EventSource struct {
|
||||||
// Component from which the event is generated.
|
// Component from which the event is generated.
|
||||||
Component string `json:"component,omitempty" description:"component that generated the event"`
|
Component string `json:"component,omitempty" description:"component that generated the event"`
|
||||||
|
@ -17,10 +17,10 @@ limitations under the License.
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
|
||||||
@ -201,8 +201,9 @@ func (r RealPodControl) createReplica(namespace string, controller *api.Replicat
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get controller reference: %v", err)
|
return fmt.Errorf("unable to get controller reference: %v", err)
|
||||||
}
|
}
|
||||||
// TODO: Version this serialization per #7322
|
createdByRefJson, err := latest.Codec.Encode(&api.SerializedReference{
|
||||||
createdByRefJson, err := json.Marshal(createdByRef)
|
Reference: *createdByRef,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to serialize controller reference: %v", err)
|
return fmt.Errorf("unable to serialize controller reference: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user