Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 92e2e68

Browse files
committed
Do not treat lack of reservations as a fatal error
1 parent 0b30d06 commit 92e2e68

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

controllers/packetmachine_controller.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222
"net/http"
23+
"strings"
2324
"time"
2425

2526
corev1 "k8s.io/api/core/v1"
@@ -238,8 +239,14 @@ func (r *PacketMachineReconciler) reconcile(ctx context.Context, machineScope *s
238239
createDeviceReq.ExtraTags = tags
239240

240241
dev, err = r.PacketClient.NewDevice(createDeviceReq)
241-
if err != nil {
242-
errs := fmt.Errorf("failed to create machine %s: %v", machineScope.Name(), err)
242+
243+
switch {
244+
// TODO: find a better way than parsing the error messages for this.
245+
case strings.Contains(err.Error(), " no available hardware reservations "):
246+
// Do not treat an error indicating there are no hardware reservations available as fatal
247+
return ctrl.Result{}, fmt.Errorf("failed to create machine %s: %w", machineScope.Name(), err)
248+
case err != nil:
249+
errs := fmt.Errorf("failed to create machine %s: %w", machineScope.Name(), err)
243250
machineScope.SetErrorReason(capierrors.CreateMachineError)
244251
machineScope.SetErrorMessage(errs)
245252
return ctrl.Result{}, errs
@@ -280,10 +287,7 @@ func (r *PacketMachineReconciler) reconcile(ctx context.Context, machineScope *s
280287
Address: controlPlaneEndpoint.Address,
281288
}); err != nil {
282289
r.Log.Error(err, "err assigining elastic ip to control plane. retrying...")
283-
return ctrl.Result{
284-
Requeue: true,
285-
RequeueAfter: time.Second * 20,
286-
}, nil
290+
return ctrl.Result{RequeueAfter: time.Second * 20}, nil
287291
}
288292
}
289293
machineScope.SetReady()

0 commit comments

Comments
 (0)