Skip to content
Open
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
21 changes: 21 additions & 0 deletions api/v1beta1/conditions_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,27 @@ const (
RebootSucceededCondition clusterv1beta1.ConditionType = "RebootSucceeded"
)

const (
// NodeProvisioningSucceededCondition aggregates the result of all image-url-command v2 phases.
// True once all four phase conditions are True; False on any permanent failure; Unknown while in progress.
NodeProvisioningSucceededCondition clusterv1beta1.ConditionType = "NodeProvisioningSucceeded"
// PreparationSucceededCondition reports disks partitioned, filesystems mounted, required binaries verified.
PreparationSucceededCondition clusterv1beta1.ConditionType = "PreparationSucceeded"
// ImageDeploymentSucceededCondition reports OCI tarball pulled, checksum/signature verified, image written to disk.
ImageDeploymentSucceededCondition clusterv1beta1.ConditionType = "ImageDeploymentSucceeded"
// BootstrapDeliverySucceededCondition reports cloud-init/CAPI bootstrap data written into the deployed image.
BootstrapDeliverySucceededCondition clusterv1beta1.ConditionType = "BootstrapDeliverySucceeded"
// HandoverSucceededCondition reports reboot initiated; binary completed, controller takes over.
HandoverSucceededCondition clusterv1beta1.ConditionType = "HandoverSucceeded"

// ProvisioningPhaseSucceededReason indicates a provisioning phase completed successfully.
ProvisioningPhaseSucceededReason = "Succeeded"
// ProvisioningPhaseFailedReason indicates a provisioning phase failed permanently.
ProvisioningPhaseFailedReason = "Failed"
// ProvisioningPhaseNotStartedReason indicates a provisioning phase was never reached.
ProvisioningPhaseNotStartedReason = "NotStarted"
)

const (
// RemediationSkippedCondition reports that remediation was skipped because
// the HCloudMachine has a state that makes remediation unnecessary or impossible.
Expand Down
13 changes: 13 additions & 0 deletions api/v1beta1/hcloudmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ type HCloudMachineSpec struct {
// +optional
ImageURLCommand string `json:"imageURLCommand,omitempty"`

// ImageURLCommandAPIVersion is the output format version of the ImageURLCommand binary.
// When set to "v2", CAPH reads /root/output.json after the command completes and maps each
// provisioning phase to a condition on the HCloudMachine (PreparationSucceeded,
// ImageDeploymentSucceeded, BootstrapDeliverySucceeded, HandoverSucceeded, and the aggregate
// NodeProvisioningSucceeded).
//
// Leave empty (default) to use the legacy IMAGE_URL_DONE log-based detection.
//
// +kubebuilder:validation:Enum="";v2
// +kubebuilder:validation:Optional
// +optional
ImageURLCommandAPIVersion string `json:"imageURLCommandAPIVersion,omitempty"`

// SSHKeys define machine-specific SSH keys and override cluster-wide SSH keys.
// +optional
SSHKeys []SSHKey `json:"sshKeys,omitempty"`
Expand Down
13 changes: 13 additions & 0 deletions api/v1beta1/hcloudmachine_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ func validateHCloudMachineSpecUpdate(oldSpec, newSpec HCloudMachineSpec) field.E
)
}

// ImageURLCommandAPIVersion is immutable
if !reflect.DeepEqual(oldSpec.ImageURLCommandAPIVersion, newSpec.ImageURLCommandAPIVersion) {
allErrs = append(allErrs,
field.Forbidden(field.NewPath("spec", "imageURLCommandAPIVersion"), "field is immutable"),
)
}

// SSHKeys is immutable
if !reflect.DeepEqual(oldSpec.SSHKeys, newSpec.SSHKeys) {
allErrs = append(allErrs,
Expand Down Expand Up @@ -114,5 +121,11 @@ func validateHCloudMachineSpec(spec HCloudMachineSpec) field.ErrorList {
}
}

if spec.ImageURLCommandAPIVersion != "" && spec.ImageURL == "" {
allErrs = append(allErrs,
field.Invalid(field.NewPath("spec", "imageURLCommandAPIVersion"), spec.ImageURLCommandAPIVersion,
"imageURLCommandAPIVersion requires imageURL to be set"))
}

return allErrs
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ spec:
ImageURLCommand must be set if ImageURL is set. ImageURLCommand must be empty if ImageURL is
empty.
type: string
imageURLCommandAPIVersion:
description: |-
ImageURLCommandAPIVersion is the output format version of the ImageURLCommand binary.
When set to "v2", CAPH reads /root/output.json after the command completes and maps each
provisioning phase to a condition on the HCloudMachine (PreparationSucceeded,
ImageDeploymentSucceeded, BootstrapDeliverySucceeded, HandoverSucceeded, and the aggregate
NodeProvisioningSucceeded).

Leave empty (default) to use the legacy IMAGE_URL_DONE log-based detection.
enum:
- ""
- v2
type: string
placementGroupName:
description: PlacementGroupName defines the placement group of the
machine in HCloud API that must reference an existing placement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ spec:
ImageURLCommand must be set if ImageURL is set. ImageURLCommand must be empty if ImageURL is
empty.
type: string
imageURLCommandAPIVersion:
description: |-
ImageURLCommandAPIVersion is the output format version of the ImageURLCommand binary.
When set to "v2", CAPH reads /root/output.json after the command completes and maps each
provisioning phase to a condition on the HCloudMachine (PreparationSucceeded,
ImageDeploymentSucceeded, BootstrapDeliverySucceeded, HandoverSucceeded, and the aggregate
NodeProvisioningSucceeded).

Leave empty (default) to use the legacy IMAGE_URL_DONE log-based detection.
enum:
- ""
- v2
type: string
placementGroupName:
description: PlacementGroupName defines the placement group
of the machine in HCloud API that must reference an existing
Expand Down
2 changes: 1 addition & 1 deletion hack/update-operator-dev-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if ! kubectl cluster-info >/dev/null; then
fi

current_context=$(kubectl config current-context)
if ! echo "$current_context" | grep -P '.*-admin@.*-mgt-cluster|kind-'; then
if ! echo "$current_context" | grep -P '.*-admin@.*-mgt-cluster|kind-|img-url-cmd-via-go'; then
echo "The script refuses to update because the current context is: $current_context"
echo "Expecting something like foo-mgt-cluster-admin@foo-mgt-cluster with 'foo' being a short version of your name"
exit 1
Expand Down
152 changes: 136 additions & 16 deletions pkg/services/baremetal/client/mocks/ssh/Client.go

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

Loading
Loading