mirror of
https://github.com/kubernetes/sample-controller.git
synced 2026-05-01 00:00:03 +08:00
Merge pull request #53944 from gregory-m/sample-controller-tests
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Sample controller tests **What this PR does / why we need it**: This PR adds unit tests to sample-controller. **Special notes for your reviewer**: This is currently based on the munnerz:sample-controller branch. Please don't merged it until #52753 is merged. Kubernetes-commit: dc20badcd49e5fd2ab41d4320c9c70a50d30343c
This commit is contained in:
+1589
-1266
File diff suppressed because it is too large
Load Diff
+54
@@ -1847,6 +1847,56 @@ message NodeConfigSource {
|
||||
optional ConfigMapNodeConfigSource configMap = 2;
|
||||
}
|
||||
|
||||
// NodeConfigStatus describes the status of the config assigned by Node.Spec.ConfigSource.
|
||||
message NodeConfigStatus {
|
||||
// Assigned reports the checkpointed config the node will try to use.
|
||||
// When Node.Spec.ConfigSource is updated, the node checkpoints the associated
|
||||
// config payload to local disk, along with a record indicating intended
|
||||
// config. The node refers to this record to choose its config checkpoint, and
|
||||
// reports this record in Assigned. Assigned only updates in the status after
|
||||
// the record has been checkpointed to disk. When the Kubelet is restarted,
|
||||
// it tries to make the Assigned config the Active config by loading and
|
||||
// validating the checkpointed payload identified by Assigned.
|
||||
// +optional
|
||||
optional NodeConfigSource assigned = 1;
|
||||
|
||||
// Active reports the checkpointed config the node is actively using.
|
||||
// Active will represent either the current version of the Assigned config,
|
||||
// or the current LastKnownGood config, depending on whether attempting to use the
|
||||
// Assigned config results in an error.
|
||||
// +optional
|
||||
optional NodeConfigSource active = 2;
|
||||
|
||||
// LastKnownGood reports the checkpointed config the node will fall back to
|
||||
// when it encounters an error attempting to use the Assigned config.
|
||||
// The Assigned config becomes the LastKnownGood config when the node determines
|
||||
// that the Assigned config is stable and correct.
|
||||
// This is currently implemented as a 10-minute soak period starting when the local
|
||||
// record of Assigned config is updated. If the Assigned config is Active at the end
|
||||
// of this period, it becomes the LastKnownGood. Note that if Spec.ConfigSource is
|
||||
// reset to nil (use local defaults), the LastKnownGood is also immediately reset to nil,
|
||||
// because the local default config is always assumed good.
|
||||
// You should not make assumptions about the node's method of determining config stability
|
||||
// and correctness, as this may change or become configurable in the future.
|
||||
// +optional
|
||||
optional NodeConfigSource lastKnownGood = 3;
|
||||
|
||||
// Error describes any problems reconciling the Spec.ConfigSource to the Active config.
|
||||
// Errors may occur, for example, attempting to checkpoint Spec.ConfigSource to the local Assigned
|
||||
// record, attempting to checkpoint the payload associated with Spec.ConfigSource, attempting
|
||||
// to load or validate the Assigned config, etc.
|
||||
// Errors may occur at different points while syncing config. Earlier errors (e.g. download or
|
||||
// checkpointing errors) will not result in a rollback to LastKnownGood, and may resolve across
|
||||
// Kubelet retries. Later errors (e.g. loading or validating a checkpointed config) will result in
|
||||
// a rollback to LastKnownGood. In the latter case, it is usually possible to resolve the error
|
||||
// by fixing the config assigned in Spec.ConfigSource.
|
||||
// You can find additional information for debugging by searching the error message in the Kubelet log.
|
||||
// Error is a human-readable description of the error state; machines can check whether or not Error
|
||||
// is empty, but should not rely on the stability of the Error text across Kubelet versions.
|
||||
// +optional
|
||||
optional string error = 4;
|
||||
}
|
||||
|
||||
// NodeDaemonEndpoints lists ports opened by daemons running on the Node.
|
||||
message NodeDaemonEndpoints {
|
||||
// Endpoint on which Kubelet is listening.
|
||||
@@ -2001,6 +2051,10 @@ message NodeStatus {
|
||||
// List of volumes that are attached to the node.
|
||||
// +optional
|
||||
repeated AttachedVolume volumesAttached = 10;
|
||||
|
||||
// Status of the config assigned to the node via the dynamic Kubelet config feature.
|
||||
// +optional
|
||||
optional NodeConfigStatus config = 11;
|
||||
}
|
||||
|
||||
// NodeSystemInfo is a set of ids/uuids to uniquely identify the node.
|
||||
|
||||
+52
-2
@@ -3407,6 +3407,7 @@ type ServicePort struct {
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:skipVerbs=deleteCollection
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// Service is a named abstraction of software service (for example, mysql) consisting of local port
|
||||
@@ -3729,6 +3730,53 @@ type NodeSystemInfo struct {
|
||||
Architecture string `json:"architecture" protobuf:"bytes,10,opt,name=architecture"`
|
||||
}
|
||||
|
||||
// NodeConfigStatus describes the status of the config assigned by Node.Spec.ConfigSource.
|
||||
type NodeConfigStatus struct {
|
||||
// Assigned reports the checkpointed config the node will try to use.
|
||||
// When Node.Spec.ConfigSource is updated, the node checkpoints the associated
|
||||
// config payload to local disk, along with a record indicating intended
|
||||
// config. The node refers to this record to choose its config checkpoint, and
|
||||
// reports this record in Assigned. Assigned only updates in the status after
|
||||
// the record has been checkpointed to disk. When the Kubelet is restarted,
|
||||
// it tries to make the Assigned config the Active config by loading and
|
||||
// validating the checkpointed payload identified by Assigned.
|
||||
// +optional
|
||||
Assigned *NodeConfigSource `json:"assigned,omitempty" protobuf:"bytes,1,opt,name=assigned"`
|
||||
// Active reports the checkpointed config the node is actively using.
|
||||
// Active will represent either the current version of the Assigned config,
|
||||
// or the current LastKnownGood config, depending on whether attempting to use the
|
||||
// Assigned config results in an error.
|
||||
// +optional
|
||||
Active *NodeConfigSource `json:"active,omitempty" protobuf:"bytes,2,opt,name=active"`
|
||||
// LastKnownGood reports the checkpointed config the node will fall back to
|
||||
// when it encounters an error attempting to use the Assigned config.
|
||||
// The Assigned config becomes the LastKnownGood config when the node determines
|
||||
// that the Assigned config is stable and correct.
|
||||
// This is currently implemented as a 10-minute soak period starting when the local
|
||||
// record of Assigned config is updated. If the Assigned config is Active at the end
|
||||
// of this period, it becomes the LastKnownGood. Note that if Spec.ConfigSource is
|
||||
// reset to nil (use local defaults), the LastKnownGood is also immediately reset to nil,
|
||||
// because the local default config is always assumed good.
|
||||
// You should not make assumptions about the node's method of determining config stability
|
||||
// and correctness, as this may change or become configurable in the future.
|
||||
// +optional
|
||||
LastKnownGood *NodeConfigSource `json:"lastKnownGood,omitempty" protobuf:"bytes,3,opt,name=lastKnownGood"`
|
||||
// Error describes any problems reconciling the Spec.ConfigSource to the Active config.
|
||||
// Errors may occur, for example, attempting to checkpoint Spec.ConfigSource to the local Assigned
|
||||
// record, attempting to checkpoint the payload associated with Spec.ConfigSource, attempting
|
||||
// to load or validate the Assigned config, etc.
|
||||
// Errors may occur at different points while syncing config. Earlier errors (e.g. download or
|
||||
// checkpointing errors) will not result in a rollback to LastKnownGood, and may resolve across
|
||||
// Kubelet retries. Later errors (e.g. loading or validating a checkpointed config) will result in
|
||||
// a rollback to LastKnownGood. In the latter case, it is usually possible to resolve the error
|
||||
// by fixing the config assigned in Spec.ConfigSource.
|
||||
// You can find additional information for debugging by searching the error message in the Kubelet log.
|
||||
// Error is a human-readable description of the error state; machines can check whether or not Error
|
||||
// is empty, but should not rely on the stability of the Error text across Kubelet versions.
|
||||
// +optional
|
||||
Error string `json:"error,omitempty" protobuf:"bytes,4,opt,name=error"`
|
||||
}
|
||||
|
||||
// NodeStatus is information about the current status of a node.
|
||||
type NodeStatus struct {
|
||||
// Capacity represents the total resources of a node.
|
||||
@@ -3773,6 +3821,9 @@ type NodeStatus struct {
|
||||
// List of volumes that are attached to the node.
|
||||
// +optional
|
||||
VolumesAttached []AttachedVolume `json:"volumesAttached,omitempty" protobuf:"bytes,10,rep,name=volumesAttached"`
|
||||
// Status of the config assigned to the node via the dynamic Kubelet config feature.
|
||||
// +optional
|
||||
Config *NodeConfigStatus `json:"config,omitempty" protobuf:"bytes,11,opt,name=config"`
|
||||
}
|
||||
|
||||
type UniqueVolumeName string
|
||||
@@ -3860,8 +3911,6 @@ const (
|
||||
NodePIDPressure NodeConditionType = "PIDPressure"
|
||||
// NodeNetworkUnavailable means that network for the node is not correctly configured.
|
||||
NodeNetworkUnavailable NodeConditionType = "NetworkUnavailable"
|
||||
// NodeKubeletConfigOk indicates whether the kubelet is correctly configured
|
||||
NodeKubeletConfigOk NodeConditionType = "KubeletConfigOk"
|
||||
)
|
||||
|
||||
// NodeCondition contains condition information for a node.
|
||||
@@ -4010,6 +4059,7 @@ const (
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +genclient:skipVerbs=deleteCollection
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// Namespace provides a scope for Names.
|
||||
|
||||
+13
@@ -990,6 +990,18 @@ func (NodeConfigSource) SwaggerDoc() map[string]string {
|
||||
return map_NodeConfigSource
|
||||
}
|
||||
|
||||
var map_NodeConfigStatus = map[string]string{
|
||||
"": "NodeConfigStatus describes the status of the config assigned by Node.Spec.ConfigSource.",
|
||||
"assigned": "Assigned reports the checkpointed config the node will try to use. When Node.Spec.ConfigSource is updated, the node checkpoints the associated config payload to local disk, along with a record indicating intended config. The node refers to this record to choose its config checkpoint, and reports this record in Assigned. Assigned only updates in the status after the record has been checkpointed to disk. When the Kubelet is restarted, it tries to make the Assigned config the Active config by loading and validating the checkpointed payload identified by Assigned.",
|
||||
"active": "Active reports the checkpointed config the node is actively using. Active will represent either the current version of the Assigned config, or the current LastKnownGood config, depending on whether attempting to use the Assigned config results in an error.",
|
||||
"lastKnownGood": "LastKnownGood reports the checkpointed config the node will fall back to when it encounters an error attempting to use the Assigned config. The Assigned config becomes the LastKnownGood config when the node determines that the Assigned config is stable and correct. This is currently implemented as a 10-minute soak period starting when the local record of Assigned config is updated. If the Assigned config is Active at the end of this period, it becomes the LastKnownGood. Note that if Spec.ConfigSource is reset to nil (use local defaults), the LastKnownGood is also immediately reset to nil, because the local default config is always assumed good. You should not make assumptions about the node's method of determining config stability and correctness, as this may change or become configurable in the future.",
|
||||
"error": "Error describes any problems reconciling the Spec.ConfigSource to the Active config. Errors may occur, for example, attempting to checkpoint Spec.ConfigSource to the local Assigned record, attempting to checkpoint the payload associated with Spec.ConfigSource, attempting to load or validate the Assigned config, etc. Errors may occur at different points while syncing config. Earlier errors (e.g. download or checkpointing errors) will not result in a rollback to LastKnownGood, and may resolve across Kubelet retries. Later errors (e.g. loading or validating a checkpointed config) will result in a rollback to LastKnownGood. In the latter case, it is usually possible to resolve the error by fixing the config assigned in Spec.ConfigSource. You can find additional information for debugging by searching the error message in the Kubelet log. Error is a human-readable description of the error state; machines can check whether or not Error is empty, but should not rely on the stability of the Error text across Kubelet versions.",
|
||||
}
|
||||
|
||||
func (NodeConfigStatus) SwaggerDoc() map[string]string {
|
||||
return map_NodeConfigStatus
|
||||
}
|
||||
|
||||
var map_NodeDaemonEndpoints = map[string]string{
|
||||
"": "NodeDaemonEndpoints lists ports opened by daemons running on the Node.",
|
||||
"kubeletEndpoint": "Endpoint on which Kubelet is listening.",
|
||||
@@ -1083,6 +1095,7 @@ var map_NodeStatus = map[string]string{
|
||||
"images": "List of container images on this node",
|
||||
"volumesInUse": "List of attachable volumes in use (mounted) by the node.",
|
||||
"volumesAttached": "List of volumes that are attached to the node.",
|
||||
"config": "Status of the config assigned to the node via the dynamic Kubelet config feature.",
|
||||
}
|
||||
|
||||
func (NodeStatus) SwaggerDoc() map[string]string {
|
||||
|
||||
+52
@@ -2398,6 +2398,49 @@ func (in *NodeConfigSource) DeepCopy() *NodeConfigSource {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NodeConfigStatus) DeepCopyInto(out *NodeConfigStatus) {
|
||||
*out = *in
|
||||
if in.Assigned != nil {
|
||||
in, out := &in.Assigned, &out.Assigned
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(NodeConfigSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
if in.Active != nil {
|
||||
in, out := &in.Active, &out.Active
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(NodeConfigSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
if in.LastKnownGood != nil {
|
||||
in, out := &in.LastKnownGood, &out.LastKnownGood
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(NodeConfigSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeConfigStatus.
|
||||
func (in *NodeConfigStatus) DeepCopy() *NodeConfigStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NodeConfigStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NodeDaemonEndpoints) DeepCopyInto(out *NodeDaemonEndpoints) {
|
||||
*out = *in
|
||||
@@ -2650,6 +2693,15 @@ func (in *NodeStatus) DeepCopyInto(out *NodeStatus) {
|
||||
*out = make([]AttachedVolume, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Config != nil {
|
||||
in, out := &in.Config, &out.Config
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(NodeConfigStatus)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user