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

Commit ca4a80e

Browse files
authored
Merge pull request #290 from detiber/backportProviderID
✨ Support updated providerid
2 parents 5c96390 + 3bfa6f4 commit ca4a80e

File tree

11 files changed

+4735
-486
lines changed

11 files changed

+4735
-486
lines changed

config/rbac/role.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ rules:
1414
- get
1515
- list
1616
- watch
17+
- apiGroups:
18+
- bootstrap.cluster.x-k8s.io
19+
resources:
20+
- kubeadmconfigs
21+
- kubeadmconfigs/status
22+
verbs:
23+
- get
24+
- list
25+
- watch
1726
- apiGroups:
1827
- cluster.x-k8s.io
1928
resources:

controllers/packetmachine_controller.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,16 @@ package controllers
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"net/http"
2324
"strings"
2425
"time"
2526

26-
corev1 "k8s.io/api/core/v1"
27-
2827
"github.com/go-logr/logr"
2928
"github.com/google/uuid"
3029
"github.com/packethost/packngo"
31-
"github.com/pkg/errors"
32-
30+
corev1 "k8s.io/api/core/v1"
3331
apierrors "k8s.io/apimachinery/pkg/api/errors"
3432
"k8s.io/apimachinery/pkg/runtime"
3533
"k8s.io/client-go/tools/record"
@@ -65,6 +63,7 @@ type PacketMachineReconciler struct {
6563
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=packetmachines,verbs=get;list;watch;create;update;patch;delete
6664
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=packetmachines/status,verbs=get;update;patch
6765
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=machines;machines/status,verbs=get;list;watch
66+
// +kubebuilder:rbac:groups=bootstrap.cluster.x-k8s.io,resources=kubeadmconfigs;kubeadmconfigs/status,verbs=get;list;watch
6867
// +kubebuilder:rbac:groups="",resources=secrets;,verbs=get;list;watch
6968

7069
func (r *PacketMachineReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr error) {
@@ -132,7 +131,7 @@ func (r *PacketMachineReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
132131
}
133132

134133
// Create the machine scope
135-
machineScope, err := scope.NewMachineScope(scope.MachineScopeParams{
134+
machineScope, err := scope.NewMachineScope(ctx, scope.MachineScopeParams{
136135
Logger: logger,
137136
Client: r.Client,
138137
Cluster: cluster,
@@ -141,7 +140,7 @@ func (r *PacketMachineReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
141140
PacketMachine: packetmachine,
142141
})
143142
if err != nil {
144-
return ctrl.Result{}, errors.Errorf("failed to create scope: %+v", err)
143+
return ctrl.Result{}, fmt.Errorf("failed to create scope: %w", err)
145144
}
146145

147146
// Always close the scope when exiting this function so we can persist any PacketMachine changes.
@@ -298,7 +297,7 @@ func (r *PacketMachineReconciler) reconcile(ctx context.Context, machineScope *s
298297
result = ctrl.Result{}
299298
default:
300299
machineScope.SetErrorReason(capierrors.UpdateMachineError)
301-
machineScope.SetErrorMessage(errors.Errorf("Instance status %q is unexpected", dev.State))
300+
machineScope.SetErrorMessage(fmt.Errorf("Instance status %q is unexpected", dev.State))
302301
result = ctrl.Result{}
303302
}
304303

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ require (
1414
k8s.io/client-go v0.17.17
1515
k8s.io/klog/v2 v2.0.0
1616
k8s.io/utils v0.0.0-20201110183641-67b214c5f920
17-
sigs.k8s.io/cluster-api v0.3.16
17+
sigs.k8s.io/cluster-api v0.3.23
1818
sigs.k8s.io/controller-runtime v0.5.14
1919
)

go.sum

Lines changed: 6 additions & 34 deletions
Large diffs are not rendered by default.

main.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ import (
2222
"time"
2323

2424
"k8s.io/apimachinery/pkg/runtime"
25+
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2526
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
2627
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
2728
"k8s.io/client-go/tools/record"
2829
"k8s.io/klog/v2/klogr"
30+
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
31+
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha3"
2932
ctrl "sigs.k8s.io/controller-runtime"
3033
"sigs.k8s.io/controller-runtime/pkg/healthz"
3134

32-
packet "sigs.k8s.io/cluster-api-provider-packet/pkg/cloud/packet"
33-
3435
infrastructurev1alpha3 "sigs.k8s.io/cluster-api-provider-packet/api/v1alpha3"
3536
"sigs.k8s.io/cluster-api-provider-packet/controllers"
36-
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
37+
packet "sigs.k8s.io/cluster-api-provider-packet/pkg/cloud/packet"
3738
// +kubebuilder:scaffold:imports
3839
)
3940

@@ -43,9 +44,11 @@ var (
4344
)
4445

4546
func init() {
46-
_ = clientgoscheme.AddToScheme(scheme)
47-
_ = infrastructurev1alpha3.AddToScheme(scheme)
48-
_ = clusterv1.AddToScheme(scheme)
47+
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
48+
utilruntime.Must(infrastructurev1alpha3.AddToScheme(scheme))
49+
utilruntime.Must(clusterv1.AddToScheme(scheme))
50+
utilruntime.Must(bootstrapv1.AddToScheme(scheme))
51+
4952
// +kubebuilder:scaffold:scheme
5053
}
5154

0 commit comments

Comments
 (0)