Merge pull request #70031 from nrfox/requeue-on-error

Sample Controller: requeue work item on syncHandler error

Kubernetes-commit: b7b0aae4358065b98a3db04411bec65a11eb166e
This commit is contained in:
Kubernetes Publisher
2018-10-27 03:19:59 -07:00
39 changed files with 969 additions and 1637 deletions
+10 -10
View File
@@ -25,11 +25,11 @@ package k8s.io.apimachinery.pkg.runtime;
option go_package = "runtime";
// RawExtension is used to hold extensions in external versions.
//
//
// To use this, make a field which has RawExtension as its type in your external, versioned
// struct, and Object in your internal struct. You also need to register your
// various plugin types.
//
//
// // Internal package:
// type MyAPIObject struct {
// runtime.TypeMeta `json:",inline"`
@@ -38,7 +38,7 @@ option go_package = "runtime";
// type PluginA struct {
// AOption string `json:"aOption"`
// }
//
//
// // External package:
// type MyAPIObject struct {
// runtime.TypeMeta `json:",inline"`
@@ -47,7 +47,7 @@ option go_package = "runtime";
// type PluginA struct {
// AOption string `json:"aOption"`
// }
//
//
// // On the wire, the JSON will look something like this:
// {
// "kind":"MyAPIObject",
@@ -57,7 +57,7 @@ option go_package = "runtime";
// "aOption":"foo",
// },
// }
//
//
// So what happens? Decode first uses json or yaml to unmarshal the serialized data into
// your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked.
// The next step is to copy (using pkg/conversion) into the internal struct. The runtime
@@ -65,13 +65,13 @@ option go_package = "runtime";
// JSON stored in RawExtension, turning it into the correct object type, and storing it
// in the Object. (TODO: In the case where the object is of an unknown type, a
// runtime.Unknown object will be created and stored.)
//
//
// +k8s:deepcopy-gen=true
// +protobuf=true
// +k8s:openapi-gen=true
message RawExtension {
// Raw is the underlying serialization of this object.
//
//
// TODO: Determine how to detect ContentType and ContentEncoding of 'Raw' data.
optional bytes raw = 1;
}
@@ -83,10 +83,10 @@ message RawExtension {
// ... // other fields
// }
// func (obj *MyAwesomeAPIObject) SetGroupVersionKind(gvk *metav1.GroupVersionKind) { metav1.UpdateTypeMeta(obj,gvk) }; GroupVersionKind() *GroupVersionKind
//
//
// TypeMeta is provided here for convenience. You may use it directly from this package or define
// your own with the same fields.
//
//
// +k8s:deepcopy-gen=false
// +protobuf=true
// +k8s:openapi-gen=true
@@ -103,7 +103,7 @@ message TypeMeta {
// TypeMeta features-- kind, version, etc.
// TODO: Make this object have easy access to field based accessors and settors for
// metadata and field mutatation.
//
//
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +protobuf=true
+11 -1
View File
@@ -18,6 +18,7 @@ package versioning
import (
"io"
"reflect"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
@@ -90,7 +91,16 @@ func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into ru
into = versioned.Last()
}
obj, gvk, err := c.decoder.Decode(data, defaultGVK, into)
// If the into object is unstructured and expresses an opinion about its group/version,
// create a new instance of the type so we always exercise the conversion path (skips short-circuiting on `into == obj`)
decodeInto := into
if into != nil {
if _, ok := into.(runtime.Unstructured); ok && !into.GetObjectKind().GroupVersionKind().GroupVersion().Empty() {
decodeInto = reflect.New(reflect.TypeOf(into).Elem()).Interface().(runtime.Object)
}
}
obj, gvk, err := c.decoder.Decode(data, defaultGVK, decodeInto)
if err != nil {
return nil, gvk, err
}