Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.
Merged
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
5 changes: 3 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
branches:
- master

env:
KUBEBUILDER_DIR: /tmp/kubebuilder_install

jobs:
report:
name: Report
Expand All @@ -24,8 +27,6 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: '1.14.2' # The Go version to download (if necessary) and use.
- name: kubebuilder-env
run: echo "::set-env name=KUBEBUILDER_DIR::/tmp/kubebuilder_install"
- name: kubebuilder
run: make kubebuilder KUBEBUILDER_DIR=${KUBEBUILDER_DIR} # we use this dir because /usr/local/kubebuilder is protected
- name: test
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ on:
- 'v*'

name: Upload Release Asset
env:
IMAGENAME: packethost/cluster-api-provider-packet
KUBEBUILDER_DIR: /tmp/kubebuilder_install

jobs:
readiness:
name: check for appropriate image
runs-on: ubuntu-latest
steps:
- name: Set version and imagename
- name: Set version
id: get_version
run: |
echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}
echo ::set-env name=IMAGENAME::packethost/cluster-api-provider-packet
echo ::set-env name=COMMIT::${GITHUB_SHA}
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo "COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
- name: information
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."
- name: docker login
Expand All @@ -36,8 +38,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: kubebuilder-env
run: echo "::set-env name=KUBEBUILDER_DIR::/tmp/kubebuilder_install"
- name: kubebuilder
run: make kubebuilder KUBEBUILDER_DIR=${KUBEBUILDER_DIR} # we use this dir because /usr/local/kubebuilder is protected
- name: manifest
Expand All @@ -46,7 +46,8 @@ jobs:
KUBEBUILDER_ASSETS: ${{ env.KUBEBUILDER_DIR }}/bin
- name: Get the version
id: get_version
run: echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}
run: |
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand Down Expand Up @@ -108,9 +109,8 @@ jobs:
- name: Set version and imagename
id: get_version
run: |
echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}
echo ::set-env name=IMAGENAME::packethost/cluster-api-provider-packet
echo ::set-env name=COMMIT::${GITHUB_SHA}
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo "COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
- name: get-image
run: docker image pull ${IMAGENAME}:${COMMIT}
- name: release-latest
Expand Down
16 changes: 10 additions & 6 deletions controllers/packetmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"net/http"
"strings"
"time"

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

dev, err = r.PacketClient.NewDevice(createDeviceReq)
if err != nil {
errs := fmt.Errorf("failed to create machine %s: %v", machineScope.Name(), err)

switch {
// TODO: find a better way than parsing the error messages for this.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not overly happy with this approach, but I wasn't able to find a unique error code that we could match against and this substring appears to be unique from the API for this error. This is the same approach taken in the autoscaler integration: https://github.com/kubernetes/autoscaler/pull/3483/files#diff-364a854e7bf33e867868548a8220972f41ca9cd66260a875d728f20c9500a13cR559-R562

case strings.Contains(err.Error(), " no available hardware reservations "):
// Do not treat an error indicating there are no hardware reservations available as fatal
return ctrl.Result{}, fmt.Errorf("failed to create machine %s: %w", machineScope.Name(), err)
case err != nil:
errs := fmt.Errorf("failed to create machine %s: %w", machineScope.Name(), err)
machineScope.SetErrorReason(capierrors.CreateMachineError)
machineScope.SetErrorMessage(errs)
return ctrl.Result{}, errs
Expand Down Expand Up @@ -280,10 +287,7 @@ func (r *PacketMachineReconciler) reconcile(ctx context.Context, machineScope *s
Address: controlPlaneEndpoint.Address,
}); err != nil {
r.Log.Error(err, "err assigining elastic ip to control plane. retrying...")
return ctrl.Result{
Requeue: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requeue: true overrides the RequeueAfter time set below it

RequeueAfter: time.Second * 20,
}, nil
return ctrl.Result{RequeueAfter: time.Second * 20}, nil
}
}
machineScope.SetReady()
Expand Down