Skip to content

Commit

Permalink
⚠️ Remove deprecated Bootstrap Data
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecile Robert-Michon committed Dec 8, 2020
1 parent 8437691 commit cbc3401
Show file tree
Hide file tree
Showing 26 changed files with 134 additions and 166 deletions.
14 changes: 10 additions & 4 deletions api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ limitations under the License.
package v1alpha3

import (
apiconversion "k8s.io/apimachinery/pkg/conversion"
"sigs.k8s.io/cluster-api/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1alpha4.Cluster)

return Convert_v1alpha3_Cluster_To_v1alpha4_Cluster(src, dst, nil)
return Convert_v1alpha3_Cluster_To_v1alpha4_Cluster(src, dst, nil)
}

func (dst *Cluster) ConvertFrom(srcRaw conversion.Hub) error {
Expand Down Expand Up @@ -96,7 +97,7 @@ func (dst *MachineSetList) ConvertFrom(srcRaw conversion.Hub) error {
func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1alpha4.MachineDeployment)

return Convert_v1alpha3_MachineDeployment_To_v1alpha4_MachineDeployment(src, dst, nil)
return Convert_v1alpha3_MachineDeployment_To_v1alpha4_MachineDeployment(src, dst, nil)
}

func (dst *MachineDeployment) ConvertFrom(srcRaw conversion.Hub) error {
Expand All @@ -120,7 +121,7 @@ func (dst *MachineDeploymentList) ConvertFrom(srcRaw conversion.Hub) error {
func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1alpha4.MachineHealthCheck)

return Convert_v1alpha3_MachineHealthCheck_To_v1alpha4_MachineHealthCheck(src, dst, nil)
return Convert_v1alpha3_MachineHealthCheck_To_v1alpha4_MachineHealthCheck(src, dst, nil)
}

func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error {
Expand All @@ -132,11 +133,16 @@ func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error {
func (src *MachineHealthCheckList) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1alpha4.MachineHealthCheckList)

return Convert_v1alpha3_MachineHealthCheckList_To_v1alpha4_MachineHealthCheckList(src, dst, nil)
return Convert_v1alpha3_MachineHealthCheckList_To_v1alpha4_MachineHealthCheckList(src, dst, nil)
}

func (dst *MachineHealthCheckList) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v1alpha4.MachineHealthCheckList)

return Convert_v1alpha4_MachineHealthCheckList_To_v1alpha3_MachineHealthCheckList(src, dst, nil)
}

// Convert_v1alpha3_Bootstrap_To_v1alpha4_Bootstrap is an autogenerated conversion function.
func Convert_v1alpha3_Bootstrap_To_v1alpha4_Bootstrap(in *Bootstrap, out *v1alpha4.Bootstrap, s apiconversion.Scope) error { //nolint
return autoConvert_v1alpha3_Bootstrap_To_v1alpha4_Bootstrap(in, out, s)
}
90 changes: 72 additions & 18 deletions api/v1alpha3/zz_generated.conversion.go

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

11 changes: 1 addition & 10 deletions api/v1alpha4/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,11 @@ func (m *MachineStatus) GetTypedPhase() MachinePhase {
type Bootstrap struct {
// ConfigRef is a reference to a bootstrap provider-specific resource
// that holds configuration details. The reference is optional to
// allow users/operators to specify Bootstrap.Data without
// allow users/operators to specify Bootstrap.DataSecretName without
// the need of a controller.
// +optional
ConfigRef *corev1.ObjectReference `json:"configRef,omitempty"`

// Data contains the bootstrap data, such as cloud-init details scripts.
// If nil, the Machine should remain in the Pending state.
//
// Deprecated: This field has been deprecated in v1alpha4 and
// will be removed in a future version. Switch to DataSecretName.
//
// +optional
Data *string `json:"data,omitempty"`

// DataSecretName is the name of the secret that stores the bootstrap data script.
// If nil, the Machine should remain in the Pending state.
// +optional
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha4/machine_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestMachineBootstrapValidation(t *testing.T) {
},
{
name: "should not return error if config ref is set",
bootstrap: Bootstrap{ConfigRef: &corev1.ObjectReference{}, Data: nil},
bootstrap: Bootstrap{ConfigRef: &corev1.ObjectReference{}, DataSecretName: nil},
expectErr: false,
},
}
Expand Down
5 changes: 0 additions & 5 deletions api/v1alpha4/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions bootstrap/kubeadm/api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha3

import (
apiconversion "k8s.io/apimachinery/pkg/conversion"
kubeadmbootstrapv1alpha4 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
Expand Down Expand Up @@ -68,3 +69,8 @@ func (dst *KubeadmConfigTemplateList) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*kubeadmbootstrapv1alpha4.KubeadmConfigTemplateList)
return Convert_v1alpha4_KubeadmConfigTemplateList_To_v1alpha3_KubeadmConfigTemplateList(src, dst, nil)
}

// Convert_v1alpha3_KubeadmConfigStatus_To_v1alpha4_KubeadmConfigStatus is an autogenerated conversion function.
func Convert_v1alpha3_KubeadmConfigStatus_To_v1alpha4_KubeadmConfigStatus(in *KubeadmConfigStatus, out *kubeadmbootstrapv1alpha4.KubeadmConfigStatus, s apiconversion.Scope) error { //nolint
return autoConvert_v1alpha3_KubeadmConfigStatus_To_v1alpha4_KubeadmConfigStatus(in, out, s)
}
18 changes: 6 additions & 12 deletions bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ type KubeadmConfigStatus struct {
// +optional
DataSecretName *string `json:"dataSecretName,omitempty"`

// BootstrapData will be a cloud-init script for now.
//
// Deprecated: This field has been deprecated in v1alpha3 and
// will be removed in a future version. Switch to DataSecretName.
//
// +optional
BootstrapData []byte `json:"bootstrapData,omitempty"`

// FailureReason will be set on non-retryable errors
// +optional
FailureReason string `json:"failureReason,omitempty"`
Expand Down
5 changes: 0 additions & 5 deletions bootstrap/kubeadm/api/v1alpha4/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -1359,10 +1359,6 @@ spec:
status:
description: KubeadmConfigStatus defines the observed state of KubeadmConfig
properties:
bootstrapData:
description: "BootstrapData will be a cloud-init script for now. \n Deprecated: This field has been deprecated in v1alpha3 and will be removed in a future version. Switch to DataSecretName."
format: byte
type: string
conditions:
description: Conditions defines current service state of the KubeadmConfig.
items:
Expand Down
3 changes: 0 additions & 3 deletions bootstrap/kubeadm/controllers/kubeadmconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,6 @@ func (r *KubeadmConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
log.Info("Cluster infrastructure is not ready, waiting")
conditions.MarkFalse(config, bootstrapv1.DataSecretAvailableCondition, bootstrapv1.WaitingForClusterInfrastructureReason, clusterv1.ConditionSeverityInfo, "")
return ctrl.Result{}, nil
// Migrate plaintext data to secret.
case config.Status.BootstrapData != nil && config.Status.DataSecretName == nil:
return ctrl.Result{}, r.storeBootstrapData(ctx, scope, config.Status.BootstrapData)
// Reconcile status for machines that already have a secret reference, but our status isn't up to date.
// This case solves the pivoting scenario (or a backup restore) which doesn't preserve the status subresource on objects.
case configOwner.DataSecretName() != nil && (!config.Status.Ready || config.Status.DataSecretName == nil):
Expand Down
Loading

0 comments on commit cbc3401

Please sign in to comment.