diff --git a/pkg/bootstrap/doc.go b/pkg/bootstrap/doc.go index 06902648c3..abceb4a6ff 100644 --- a/pkg/bootstrap/doc.go +++ b/pkg/bootstrap/doc.go @@ -19,9 +19,21 @@ package bootstrap contains the necessary type definitions to implement the exter mechanism that machine-controller can use instead of generating instance user-data itself. Any external bootstrap provider needs to implement the logic as laid out in this documentation. -This package can be imported to ensure the correct values are used. +This package can be imported to ensure the correct values and patterns are used. + +machine-controller will expect a Secret object in the namespace defined by `CloudInitSettingsNamespace`, +using `CloudConfigSecretNamePattern` as a pattern to determine the Secret name. This secret must provide +valid user-data that will be passed to the cloud provider instance on creation. + +Example code that determines the secret name for a specific Machine: + +``` +bootstrapSecretName := fmt.Sprintf(bootstrap.CloudConfigSecretNamePattern, + referencedMachineDeployment, + machine.Namespace, + bootstrap.BootstrapCloudConfig) +``` -machine-controller will expect two Secret objects in the namespace defined by `bootstrap.CloudInitSettingsNamespace`. */ package bootstrap diff --git a/pkg/bootstrap/types.go b/pkg/bootstrap/types.go index 348506900e..5c8aae5bd6 100644 --- a/pkg/bootstrap/types.go +++ b/pkg/bootstrap/types.go @@ -17,7 +17,7 @@ limitations under the License. package bootstrap /* -Do not update existing consts in this file as they are used by external bootstrap providers. Instead, +Do NOT update existing consts in this file as they are used by external bootstrap providers. Instead, introduce new consts (e.g. `CloudConfigSecretNamePatternV2`) and ensure that machine-controller still supports the old "interface" (the existing consts) for a few releases, in addition to any new interfaces you are introducing. @@ -26,8 +26,7 @@ you are introducing. type CloudConfigSecret string const ( - ProvisioningCloudConfig CloudConfigSecret = "provisioning" - BootstrapCloudConfig CloudConfigSecret = "bootstrap" + BootstrapCloudConfig CloudConfigSecret = "bootstrap" CloudConfigSecretNamePattern = "%s-%s-%s-config" diff --git a/pkg/controller/machine/machine_controller.go b/pkg/controller/machine/machine_controller.go index 5b1164ebb5..55e2aa03c5 100644 --- a/pkg/controller/machine/machine_controller.go +++ b/pkg/controller/machine/machine_controller.go @@ -819,27 +819,6 @@ func (r *Reconciler) ensureInstanceExistsForMachine( return nil, fmt.Errorf("failed to find machine's MachineDployment: %w", err) } - // We need to ensure that both provisoning and bootstrapping secrets have been created. And that the revision - // matches with the machine deployment revision - provisioningSecretName := fmt.Sprintf(bootstrap.CloudConfigSecretNamePattern, - referencedMachineDeployment, - machine.Namespace, - bootstrap.ProvisioningCloudConfig) - - // Ensure that the provisioning secret exists - provisioningSecret := &corev1.Secret{} - if err := r.client.Get(ctx, - types.NamespacedName{Name: provisioningSecretName, Namespace: util.CloudInitNamespace}, - provisioningSecret); err != nil { - klog.Errorf(CloudInitNotReadyError, bootstrap.ProvisioningCloudConfig, machine.Name) - return nil, err - } - - provisioningSecretRevision := provisioningSecret.Annotations[bootstrap.MachineDeploymentRevision] - if provisioningSecretRevision != machineDeploymentRevision { - return nil, fmt.Errorf(CloudInitNotReadyError, bootstrap.ProvisioningCloudConfig, machine.Name) - } - bootstrapSecretName := fmt.Sprintf(bootstrap.CloudConfigSecretNamePattern, referencedMachineDeployment, machine.Namespace,