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

Commit 6111559

Browse files
authored
Merge pull request #206 from detiber/errReserved
🐛 Do not treat lack of reservations as a fatal error
2 parents 0b30d06 + 67a147d commit 6111559

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
branches:
77
- master
88

9+
env:
10+
KUBEBUILDER_DIR: /tmp/kubebuilder_install
11+
912
jobs:
1013
report:
1114
name: Report
@@ -24,8 +27,6 @@ jobs:
2427
- uses: actions/setup-go@v2
2528
with:
2629
go-version: '1.14.2' # The Go version to download (if necessary) and use.
27-
- name: kubebuilder-env
28-
run: echo "::set-env name=KUBEBUILDER_DIR::/tmp/kubebuilder_install"
2930
- name: kubebuilder
3031
run: make kubebuilder KUBEBUILDER_DIR=${KUBEBUILDER_DIR} # we use this dir because /usr/local/kubebuilder is protected
3132
- name: test

.github/workflows/release.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ on:
66
- 'v*'
77

88
name: Upload Release Asset
9+
env:
10+
IMAGENAME: packethost/cluster-api-provider-packet
11+
KUBEBUILDER_DIR: /tmp/kubebuilder_install
912

1013
jobs:
1114
readiness:
1215
name: check for appropriate image
1316
runs-on: ubuntu-latest
1417
steps:
15-
- name: Set version and imagename
18+
- name: Set version
1619
id: get_version
1720
run: |
18-
echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}
19-
echo ::set-env name=IMAGENAME::packethost/cluster-api-provider-packet
20-
echo ::set-env name=COMMIT::${GITHUB_SHA}
21+
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
22+
echo "COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
2123
- name: information
2224
run: echo "checking for existence of image ${IMAGENAME}:${COMMIT}. If it does not exist, this will fail; wait for an earlier PR merge action to complete and re-run this job."
2325
- name: docker login
@@ -36,8 +38,6 @@ jobs:
3638
- name: Checkout code
3739
uses: actions/checkout@v2
3840

39-
- name: kubebuilder-env
40-
run: echo "::set-env name=KUBEBUILDER_DIR::/tmp/kubebuilder_install"
4141
- name: kubebuilder
4242
run: make kubebuilder KUBEBUILDER_DIR=${KUBEBUILDER_DIR} # we use this dir because /usr/local/kubebuilder is protected
4343
- name: manifest
@@ -46,7 +46,8 @@ jobs:
4646
KUBEBUILDER_ASSETS: ${{ env.KUBEBUILDER_DIR }}/bin
4747
- name: Get the version
4848
id: get_version
49-
run: echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}
49+
run: |
50+
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
5051
- name: Create Release
5152
id: create_release
5253
uses: actions/create-release@v1
@@ -108,9 +109,8 @@ jobs:
108109
- name: Set version and imagename
109110
id: get_version
110111
run: |
111-
echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}
112-
echo ::set-env name=IMAGENAME::packethost/cluster-api-provider-packet
113-
echo ::set-env name=COMMIT::${GITHUB_SHA}
112+
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
113+
echo "COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
114114
- name: get-image
115115
run: docker image pull ${IMAGENAME}:${COMMIT}
116116
- name: release-latest

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)