Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci-kal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ linters:
text: "optionalfields: field AddressRef is optional and should (be a pointer|have the omitempty tag)"
linters:
- kubeapilinter
- path: "api/core/v1beta2/*|api/controlplane/kubeadm/v1beta2/*"
text: "optionalfields: field Deletion is optional and should (be a pointer|have the omitempty tag)"
linters:
- kubeapilinter

issues:
max-same-issues: 0
Expand Down
46 changes: 32 additions & 14 deletions api/controlplane/kubeadm/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error {
if err != nil {
return err
}
dst.Spec.MachineTemplate.InfrastructureRef = *infraRef
dst.Spec.MachineTemplate.Spec.InfrastructureRef = *infraRef

// Manually restore data.
restored := &controlplanev1.KubeadmControlPlane{}
Expand Down Expand Up @@ -102,7 +102,7 @@ func (dst *KubeadmControlPlane) ConvertFrom(srcRaw conversion.Hub) error {
return err
}

infraRef, err := convertToObjectReference(&src.Spec.MachineTemplate.InfrastructureRef, src.Namespace)
infraRef, err := convertToObjectReference(&src.Spec.MachineTemplate.Spec.InfrastructureRef, src.Namespace)
if err != nil {
return err
}
Expand Down Expand Up @@ -258,38 +258,56 @@ func Convert_v1beta1_KubeadmControlPlaneMachineTemplate_To_v1beta2_KubeadmContro
if err := autoConvert_v1beta1_KubeadmControlPlaneMachineTemplate_To_v1beta2_KubeadmControlPlaneMachineTemplate(in, out, s); err != nil {
return err
}
out.NodeDrainTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeDrainTimeout)
out.NodeVolumeDetachTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeVolumeDetachTimeout)
out.NodeDeletionTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeDeletionTimeout)
if in.ReadinessGates != nil {
in, out := &in.ReadinessGates, &out.Spec.ReadinessGates
*out = make([]clusterv1.MachineReadinessGate, len(*in))
for i := range *in {
if err := clusterv1beta1.Convert_v1beta1_MachineReadinessGate_To_v1beta2_MachineReadinessGate(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
}
out.Spec.Deletion.NodeDrainTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeDrainTimeout)
out.Spec.Deletion.NodeVolumeDetachTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeVolumeDetachTimeout)
out.Spec.Deletion.NodeDeletionTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeDeletionTimeout)
return nil
}
func Convert_v1beta2_KubeadmControlPlaneMachineTemplate_To_v1beta1_KubeadmControlPlaneMachineTemplate(in *controlplanev1.KubeadmControlPlaneMachineTemplate, out *KubeadmControlPlaneMachineTemplate, s apimachineryconversion.Scope) error {
if err := autoConvert_v1beta2_KubeadmControlPlaneMachineTemplate_To_v1beta1_KubeadmControlPlaneMachineTemplate(in, out, s); err != nil {
return err
}
out.NodeDrainTimeout = clusterv1.ConvertFromSeconds(in.NodeDrainTimeoutSeconds)
out.NodeVolumeDetachTimeout = clusterv1.ConvertFromSeconds(in.NodeVolumeDetachTimeoutSeconds)
out.NodeDeletionTimeout = clusterv1.ConvertFromSeconds(in.NodeDeletionTimeoutSeconds)
if in.Spec.ReadinessGates != nil {
in, out := &in.Spec.ReadinessGates, &out.ReadinessGates
*out = make([]clusterv1beta1.MachineReadinessGate, len(*in))
for i := range *in {
if err := clusterv1beta1.Convert_v1beta2_MachineReadinessGate_To_v1beta1_MachineReadinessGate(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
}
out.NodeDrainTimeout = clusterv1.ConvertFromSeconds(in.Spec.Deletion.NodeDrainTimeoutSeconds)
out.NodeVolumeDetachTimeout = clusterv1.ConvertFromSeconds(in.Spec.Deletion.NodeVolumeDetachTimeoutSeconds)
out.NodeDeletionTimeout = clusterv1.ConvertFromSeconds(in.Spec.Deletion.NodeDeletionTimeoutSeconds)
return nil
}

func Convert_v1beta1_KubeadmControlPlaneTemplateMachineTemplate_To_v1beta2_KubeadmControlPlaneTemplateMachineTemplate(in *KubeadmControlPlaneTemplateMachineTemplate, out *controlplanev1.KubeadmControlPlaneTemplateMachineTemplate, s apimachineryconversion.Scope) error {
if err := autoConvert_v1beta1_KubeadmControlPlaneTemplateMachineTemplate_To_v1beta2_KubeadmControlPlaneTemplateMachineTemplate(in, out, s); err != nil {
return err
}
out.NodeDrainTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeDrainTimeout)
out.NodeVolumeDetachTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeVolumeDetachTimeout)
out.NodeDeletionTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeDeletionTimeout)
out.Spec.Deletion.NodeDrainTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeDrainTimeout)
out.Spec.Deletion.NodeVolumeDetachTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeVolumeDetachTimeout)
out.Spec.Deletion.NodeDeletionTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeDeletionTimeout)
return nil
}

func Convert_v1beta2_KubeadmControlPlaneTemplateMachineTemplate_To_v1beta1_KubeadmControlPlaneTemplateMachineTemplate(in *controlplanev1.KubeadmControlPlaneTemplateMachineTemplate, out *KubeadmControlPlaneTemplateMachineTemplate, s apimachineryconversion.Scope) error {
if err := autoConvert_v1beta2_KubeadmControlPlaneTemplateMachineTemplate_To_v1beta1_KubeadmControlPlaneTemplateMachineTemplate(in, out, s); err != nil {
return err
}
out.NodeDrainTimeout = clusterv1.ConvertFromSeconds(in.NodeDrainTimeoutSeconds)
out.NodeVolumeDetachTimeout = clusterv1.ConvertFromSeconds(in.NodeVolumeDetachTimeoutSeconds)
out.NodeDeletionTimeout = clusterv1.ConvertFromSeconds(in.NodeDeletionTimeoutSeconds)
out.NodeDrainTimeout = clusterv1.ConvertFromSeconds(in.Spec.Deletion.NodeDrainTimeoutSeconds)
out.NodeVolumeDetachTimeout = clusterv1.ConvertFromSeconds(in.Spec.Deletion.NodeVolumeDetachTimeoutSeconds)
out.NodeDeletionTimeout = clusterv1.ConvertFromSeconds(in.Spec.Deletion.NodeDeletionTimeoutSeconds)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions api/controlplane/kubeadm/v1beta1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func hubMachineTemplateSpec(in *controlplanev1.KubeadmControlPlaneMachineTemplat

// Ensure ref field is always set to realistic values.
gvk := testGVKs[c.Int31n(4)]
in.InfrastructureRef.APIGroup = gvk.Group
in.InfrastructureRef.Kind = gvk.Kind
in.Spec.InfrastructureRef.APIGroup = gvk.Group
in.Spec.InfrastructureRef.Kind = gvk.Kind
}

func spokeKubeadmControlPlane(in *KubeadmControlPlane, c randfill.Continue) {
Expand Down
18 changes: 4 additions & 14 deletions api/controlplane/kubeadm/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions api/controlplane/kubeadm/v1beta2/kubeadm_control_plane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,15 @@ type KubeadmControlPlaneMachineTemplate struct {
// +optional
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty,omitzero"`

// spec defines the spec for Machines
// in a KubeadmControlPlane object.
// +required
Spec KubeadmControlPlaneMachineTemplateSpec `json:"spec,omitempty,omitzero"`
}

// KubeadmControlPlaneMachineTemplateSpec defines the spec for Machines
// in a KubeadmControlPlane object.
type KubeadmControlPlaneMachineTemplateSpec struct {
// infrastructureRef is a required reference to a custom resource
// offered by an infrastructure provider.
// +required
Expand All @@ -502,6 +511,14 @@ type KubeadmControlPlaneMachineTemplate struct {
// +kubebuilder:validation:MaxItems=32
ReadinessGates []clusterv1.MachineReadinessGate `json:"readinessGates,omitempty"`

// deletion contains configuration options for Machine deletion.
// +optional
Deletion KubeadmControlPlaneMachineTemplateDeletionSpec `json:"deletion,omitempty,omitzero"`
}

// KubeadmControlPlaneMachineTemplateDeletionSpec contains configuration options for Machine deletion.
// +kubebuilder:validation:MinProperties=1
type KubeadmControlPlaneMachineTemplateDeletionSpec struct {
// nodeDrainTimeoutSeconds is the total amount of time that the controller will spend on draining a controlplane node
// The default value is 0, meaning that the node can be drained without any time limitations.
// NOTE: nodeDrainTimeoutSeconds is different from `kubectl drain --timeout`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,31 @@ type KubeadmControlPlaneTemplateResourceSpec struct {
// omits ObjectMeta and InfrastructureRef fields. These fields do not make sense on the KubeadmControlPlaneTemplate,
// because they are calculated by the Cluster topology reconciler during reconciliation and thus cannot
// be configured on the KubeadmControlPlaneTemplate.
// +kubebuilder:validation:MinProperties=1
type KubeadmControlPlaneTemplateMachineTemplate struct {
// metadata is the standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty,omitzero"`

// spec defines the spec for Machines
// in a KubeadmControlPlane object.
// +optional
Spec KubeadmControlPlaneTemplateMachineTemplateSpec `json:"spec,omitempty,omitzero"`
}

// KubeadmControlPlaneTemplateMachineTemplateSpec defines the spec for Machines
// in a KubeadmControlPlane object.
// +kubebuilder:validation:MinProperties=1
type KubeadmControlPlaneTemplateMachineTemplateSpec struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: should we add minProperties?

// deletion contains configuration options for Machine deletion.
// +optional
Deletion KubeadmControlPlaneTemplateMachineTemplateDeletionSpec `json:"deletion,omitempty,omitzero"`
}

// KubeadmControlPlaneTemplateMachineTemplateDeletionSpec contains configuration options for Machine deletion.
// +kubebuilder:validation:MinProperties=1
type KubeadmControlPlaneTemplateMachineTemplateDeletionSpec struct {
// nodeDrainTimeoutSeconds is the total amount of time that the controller will spend on draining a controlplane node
// The default value is 0, meaning that the node can be drained without any time limitations.
// NOTE: nodeDrainTimeoutSeconds is different from `kubectl drain --timeout`
Expand Down
86 changes: 75 additions & 11 deletions api/controlplane/kubeadm/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading