Skip to content

Commit

Permalink
Remove provisioning secret as implementation detail of OSM
Browse files Browse the repository at this point in the history
Signed-off-by: Marvin Beckers <[email protected]>
  • Loading branch information
embik committed Aug 30, 2022
1 parent a5089f8 commit 29eb2e8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
16 changes: 14 additions & 2 deletions pkg/bootstrap/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions pkg/bootstrap/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"

Expand Down
21 changes: 0 additions & 21 deletions pkg/controller/machine/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 29eb2e8

Please sign in to comment.