Skip to content

Commit

Permalink
capi v1.9.0-beta.0: fix deprecated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
damdo committed Nov 6, 2024
1 parent 354615b commit fcf032d
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 22 deletions.
3 changes: 1 addition & 2 deletions api/v1beta1/gcpmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1beta1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/cluster-api/errors"
)

const (
Expand Down Expand Up @@ -386,7 +385,7 @@ type GCPMachineStatus struct {
// can be added as events to the Machine object and/or logged in the
// controller's output.
// +optional
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
FailureReason *string `json:"failureReason,omitempty"`

// FailureMessage will be set in the event that there is a terminal problem
// reconciling the Machine and will contain a more verbose string suitable
Expand Down
3 changes: 1 addition & 2 deletions api/v1beta1/zz_generated.deepcopy.go

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

3 changes: 1 addition & 2 deletions cloud/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
corev1 "k8s.io/api/core/v1"
infrav1 "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
capierrors "sigs.k8s.io/cluster-api/errors"
)

// Cloud alias for cloud.Cloud interface.
Expand Down Expand Up @@ -99,7 +98,7 @@ type MachineSetter interface {
SetProviderID()
SetInstanceStatus(v infrav1.InstanceStatus)
SetFailureMessage(v error)
SetFailureReason(v capierrors.MachineStatusError)
SetFailureReason(v string)
SetAnnotation(key, value string)
SetAddresses(addressList []corev1.NodeAddress)
}
Expand Down
3 changes: 1 addition & 2 deletions cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"sigs.k8s.io/cluster-api-provider-gcp/cloud/providerid"
"sigs.k8s.io/cluster-api-provider-gcp/cloud/services/shared"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
capierrors "sigs.k8s.io/cluster-api/errors"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -201,7 +200,7 @@ func (m *MachineScope) SetFailureMessage(v error) {
}

// SetFailureReason sets the GCPMachine status failure reason.
func (m *MachineScope) SetFailureReason(v capierrors.MachineStatusError) {
func (m *MachineScope) SetFailureReason(v string) {
m.GCPMachine.Status.FailureReason = &v
}

Expand Down
6 changes: 3 additions & 3 deletions controllers/gcpcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func (r *GCPClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
c, err := ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(&infrav1.GCPCluster{}).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue)).
WithEventFilter(predicates.ResourceIsNotExternallyManaged(log)).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue)).
WithEventFilter(predicates.ResourceIsNotExternallyManaged(mgr.GetScheme(), log)).
Build(r)
if err != nil {
return errors.Wrap(err, "error creating controller")
Expand All @@ -93,7 +93,7 @@ func (r *GCPClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
}
return requests
}),
predicates.ClusterUnpaused(log),
predicates.ClusterUnpaused(mgr.GetScheme(), log),
)); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down
7 changes: 3 additions & 4 deletions controllers/gcpmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"sigs.k8s.io/cluster-api-provider-gcp/cloud/services/compute/instances"
"sigs.k8s.io/cluster-api-provider-gcp/util/reconciler"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
capierrors "sigs.k8s.io/cluster-api/errors"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/predicates"
Expand Down Expand Up @@ -60,7 +59,7 @@ func (r *GCPMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
c, err := ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(&infrav1.GCPMachine{}).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
Watches(
&clusterv1.Machine{},
handler.EnqueueRequestsFromMapFunc(util.MachineToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("GCPMachine"))),
Expand All @@ -83,7 +82,7 @@ func (r *GCPMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
if err := c.Watch(
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(clusterToObjectFunc),
predicates.ClusterUnpausedAndInfrastructureReady(log),
predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), log),
)); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down Expand Up @@ -244,7 +243,7 @@ func (r *GCPMachineReconciler) reconcile(ctx context.Context, machineScope *scop
machineScope.SetReady()
return ctrl.Result{}, nil
default:
machineScope.SetFailureReason(capierrors.UpdateMachineError)
machineScope.SetFailureReason("UpdateError")
machineScope.SetFailureMessage(errors.Errorf("GCPMachine instance state %s is unexpected", instanceState))
return ctrl.Result{Requeue: true}, nil
}
Expand Down
6 changes: 3 additions & 3 deletions exp/controllers/gcpmanagedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (r *GCPManagedClusterReconciler) SetupWithManager(ctx context.Context, mgr
c, err := ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(&infrav1exp.GCPManagedCluster{}).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue)).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue)).
Watches(
&infrav1exp.GCPManagedControlPlane{},
handler.EnqueueRequestsFromMapFunc(r.managedControlPlaneMapper()),
Expand All @@ -158,8 +158,8 @@ func (r *GCPManagedClusterReconciler) SetupWithManager(ctx context.Context, mgr
if err = c.Watch(
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1exp.GroupVersion.WithKind("GCPManagedCluster"), mgr.GetClient(), &infrav1exp.GCPManagedCluster{})),
predicates.ClusterUnpaused(log),
predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue),
predicates.ClusterUnpaused(mgr.GetScheme(), log),
predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue),
)); err != nil {
return fmt.Errorf("adding watch for ready clusters: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions exp/controllers/gcpmanagedcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (r *GCPManagedControlPlaneReconciler) SetupWithManager(ctx context.Context,
c, err := ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(gcpManagedControlPlane).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue)).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue)).
Build(r)
if err != nil {
return errors.Wrap(err, "error creating controller")
Expand All @@ -76,7 +76,7 @@ func (r *GCPManagedControlPlaneReconciler) SetupWithManager(ctx context.Context,
if err = c.Watch(
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, gcpManagedControlPlane.GroupVersionKind(), mgr.GetClient(), &infrav1exp.GCPManagedControlPlane{})),
predicates.ClusterUnpausedAndInfrastructureReady(log),
predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), log),
)); err != nil {
return fmt.Errorf("failed adding a watch for ready clusters: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions exp/controllers/gcpmanagedmachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (r *GCPManagedMachinePoolReconciler) SetupWithManager(ctx context.Context,
c, err := ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(&infrav1exp.GCPManagedMachinePool{}).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue)).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue)).
Watches(
&expclusterv1.MachinePool{},
handler.EnqueueRequestsFromMapFunc(machinePoolToInfrastructureMapFunc(gvk)),
Expand All @@ -180,7 +180,7 @@ func (r *GCPManagedMachinePoolReconciler) SetupWithManager(ctx context.Context,
if err := c.Watch(
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
handler.EnqueueRequestsFromMapFunc(clusterToObjectFunc),
predicates.ClusterUnpausedAndInfrastructureReady(log),
predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), log),
)); err != nil {
return errors.Wrap(err, "failed adding a watch for ready clusters")
}
Expand Down

0 comments on commit fcf032d

Please sign in to comment.