Skip to content

Commit

Permalink
wait up to 30 seconds for root disk to resize (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyDumaine authored Mar 26, 2024
1 parent 1a657d6 commit 60f6c60
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions cloud/scope/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type LinodeInstanceClient interface {
CreateInstanceDisk(ctx context.Context, linodeID int, opts linodego.InstanceDiskCreateOptions) (*linodego.InstanceDisk, error)
GetInstance(ctx context.Context, linodeID int) (*linodego.Instance, error)
DeleteInstance(ctx context.Context, linodeID int) error
WaitForInstanceDiskStatus(ctx context.Context, instanceID int, diskID int, status linodego.DiskStatus, timeoutSeconds int) (*linodego.InstanceDisk, error)
}

// LinodeVPCClient defines the methods that a Linode client must have to interact with Linode's VPC service.
Expand Down
12 changes: 11 additions & 1 deletion controller/linodemachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ import (
)

// default etcd Disk size in MB
const defaultEtcdDiskSize = 10240
const (
defaultEtcdDiskSize = 10240
defaultResizeTimeoutSeconds = 30
)

var skippedMachinePhases = map[string]bool{
string(clusterv1.MachinePhasePending): true,
Expand Down Expand Up @@ -342,6 +345,13 @@ func (r *LinodeMachineReconciler) configureDisksControlPlane(

return err
}
// wait for the disk to resize
_, err = machineScope.LinodeClient.WaitForInstanceDiskStatus(ctx, linodeInstanceID, rootDiskID, linodego.DiskReady, defaultResizeTimeoutSeconds)
if err != nil {
logger.Error(err, fmt.Sprintf("Failed to resize root disk within resize timeout of %d seconds", defaultResizeTimeoutSeconds))

return err
}

// create the etcd disk
_, err = machineScope.LinodeClient.CreateInstanceDisk(
Expand Down
30 changes: 30 additions & 0 deletions mock/client.go

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

0 comments on commit 60f6c60

Please sign in to comment.