Skip to content

Commit e65d208

Browse files
committed
Import deprecated but needed errors constants from CAPI
Context: kubernetes-sigs/cluster-api#10784 We'll maintain them here for the time being, until we have conditions replacing these errors.
1 parent 8ecfa9e commit e65d208

23 files changed

+87
-75
lines changed

api/v1alpha6/openstackcluster_types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package v1alpha6
1818

1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
2122
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22-
capierrors "sigs.k8s.io/cluster-api/errors"
2323
)
2424

2525
const (
@@ -190,7 +190,7 @@ type OpenStackClusterStatus struct {
190190
// OpenStackClusters can be added as events to the OpenStackCluster object
191191
// and/or logged in the controller's output.
192192
// +optional
193-
FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"`
193+
FailureReason *capoerrors.DeprecatedCAPIClusterStatusError `json:"failureReason,omitempty"`
194194

195195
// FailureMessage will be set in the event that there is a terminal problem
196196
// reconciling the OpenStackCluster and will contain a more verbose string suitable

api/v1alpha6/openstackmachine_types.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
"k8s.io/utils/ptr"
23+
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
2324
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
24-
"sigs.k8s.io/cluster-api/errors"
2525
)
2626

2727
const (
@@ -118,7 +118,7 @@ type OpenStackMachineStatus struct {
118118
// +optional
119119
InstanceState *InstanceState `json:"instanceState,omitempty"`
120120

121-
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
121+
FailureReason *errors.DeprecatedCAPIMachineStatusError `json:"failureReason,omitempty"`
122122

123123
// FailureMessage will be set in the event that there is a terminal problem
124124
// reconciling the Machine and will contain a more verbose string suitable
@@ -189,7 +189,7 @@ func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) {
189189
}
190190

191191
// SetFailure sets the OpenStackMachine status failure reason and failure message.
192-
func (r *OpenStackMachine) SetFailure(failureReason errors.MachineStatusError, failureMessage error) {
192+
func (r *OpenStackMachine) SetFailure(failureReason errors.DeprecatedCAPIMachineStatusError, failureMessage error) {
193193
r.Status.FailureReason = &failureReason
194194
r.Status.FailureMessage = ptr.To(failureMessage.Error())
195195
}

api/v1alpha6/zz_generated.conversion.go

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha6/zz_generated.deepcopy.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha7/openstackcluster_types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package v1alpha7
1818

1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
2122
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22-
capierrors "sigs.k8s.io/cluster-api/errors"
2323
)
2424

2525
const (
@@ -207,7 +207,7 @@ type OpenStackClusterStatus struct {
207207
// OpenStackClusters can be added as events to the OpenStackCluster object
208208
// and/or logged in the controller's output.
209209
// +optional
210-
FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"`
210+
FailureReason *capoerrors.DeprecatedCAPIClusterStatusError `json:"failureReason,omitempty"`
211211

212212
// FailureMessage will be set in the event that there is a terminal problem
213213
// reconciling the OpenStackCluster and will contain a more verbose string suitable

api/v1alpha7/openstackmachine_types.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
"k8s.io/utils/ptr"
23+
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
2324
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
24-
"sigs.k8s.io/cluster-api/errors"
2525
)
2626

2727
const (
@@ -118,7 +118,7 @@ type OpenStackMachineStatus struct {
118118
// +optional
119119
InstanceState *InstanceState `json:"instanceState,omitempty"`
120120

121-
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
121+
FailureReason *errors.DeprecatedCAPIMachineStatusError `json:"failureReason,omitempty"`
122122

123123
// FailureMessage will be set in the event that there is a terminal problem
124124
// reconciling the Machine and will contain a more verbose string suitable
@@ -187,7 +187,7 @@ func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) {
187187
}
188188

189189
// SetFailure sets the OpenStackMachine status failure reason and failure message.
190-
func (r *OpenStackMachine) SetFailure(failureReason errors.MachineStatusError, failureMessage error) {
190+
func (r *OpenStackMachine) SetFailure(failureReason errors.DeprecatedCAPIMachineStatusError, failureMessage error) {
191191
r.Status.FailureReason = &failureReason
192192
r.Status.FailureMessage = ptr.To(failureMessage.Error())
193193
}

api/v1alpha7/zz_generated.conversion.go

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha7/zz_generated.deepcopy.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/openstackcluster_types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package v1beta1
1818

1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
2122
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22-
capierrors "sigs.k8s.io/cluster-api/errors"
2323

2424
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
2525
)
@@ -256,7 +256,7 @@ type OpenStackClusterStatus struct {
256256
// OpenStackClusters can be added as events to the OpenStackCluster object
257257
// and/or logged in the controller's output.
258258
// +optional
259-
FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"`
259+
FailureReason *capoerrors.DeprecatedCAPIClusterStatusError `json:"failureReason,omitempty"`
260260

261261
// FailureMessage will be set in the event that there is a terminal problem
262262
// reconciling the OpenStackCluster and will contain a more verbose string suitable

api/v1beta1/openstackmachine_types.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
"k8s.io/utils/ptr"
23+
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
2324
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
24-
"sigs.k8s.io/cluster-api/errors"
2525

2626
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
2727
)
@@ -211,7 +211,7 @@ type OpenStackMachineStatus struct {
211211
// +optional
212212
Resources *MachineResources `json:"resources,omitempty"`
213213

214-
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
214+
FailureReason *errors.DeprecatedCAPIMachineStatusError `json:"failureReason,omitempty"`
215215

216216
// FailureMessage will be set in the event that there is a terminal problem
217217
// reconciling the Machine and will contain a more verbose string suitable
@@ -276,7 +276,7 @@ func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) {
276276
}
277277

278278
// SetFailure sets the OpenStackMachine status failure reason and failure message.
279-
func (r *OpenStackMachine) SetFailure(failureReason errors.MachineStatusError, failureMessage error) {
279+
func (r *OpenStackMachine) SetFailure(failureReason errors.DeprecatedCAPIMachineStatusError, failureMessage error) {
280280
r.Status.FailureReason = &failureReason
281281
r.Status.FailureMessage = ptr.To(failureMessage.Error())
282282
}

api/v1beta1/zz_generated.deepcopy.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controllers/openstackcluster_controller.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"k8s.io/client-go/tools/record"
3434
"k8s.io/utils/ptr"
3535
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
36-
capierrors "sigs.k8s.io/cluster-api/errors"
3736
"sigs.k8s.io/cluster-api/util"
3837
"sigs.k8s.io/cluster-api/util/annotations"
3938
"sigs.k8s.io/cluster-api/util/collections"
@@ -882,7 +881,7 @@ func (r *OpenStackClusterReconciler) SetupWithManager(ctx context.Context, mgr c
882881

883882
func handleUpdateOSCError(openstackCluster *infrav1.OpenStackCluster, message error, isFatal bool) {
884883
if isFatal {
885-
err := capierrors.UpdateClusterError
884+
err := capoerrors.DeprecatedCAPOUpdateClusterError
886885
openstackCluster.Status.FailureReason = &err
887886
openstackCluster.Status.FailureMessage = ptr.To(message.Error())
888887
}

controllers/openstackmachine_controller.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"k8s.io/client-go/tools/record"
3131
"k8s.io/utils/ptr"
3232
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
33-
capierrors "sigs.k8s.io/cluster-api/errors"
3433
ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1"
3534
"sigs.k8s.io/cluster-api/util"
3635
"sigs.k8s.io/cluster-api/util/annotations"
@@ -51,6 +50,7 @@ import (
5150
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/services/loadbalancer"
5251
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/services/networking"
5352
"sigs.k8s.io/cluster-api-provider-openstack/pkg/scope"
53+
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
5454
)
5555

5656
// OpenStackMachineReconciler reconciles a OpenStackMachine object.
@@ -298,7 +298,7 @@ func removeAPIServerEndpoint(scope *scope.WithLogger, openStackCluster *infrav1.
298298
instanceNS, err := instanceStatus.NetworkStatus()
299299
if err != nil {
300300
openStackMachine.SetFailure(
301-
capierrors.UpdateMachineError,
301+
capoerrors.DeprecatedCAPIUpdateMachineError,
302302
fmt.Errorf("get network status for OpenStack instance %s with ID %s: %v", instanceStatus.Name(), instanceStatus.ID(), err),
303303
)
304304
return nil
@@ -437,7 +437,7 @@ func (r *OpenStackMachineReconciler) reconcileMachineState(scope *scope.WithLogg
437437
scope.Logger().Info("Machine instance state is ERROR", "id", openStackServer.Status.InstanceID)
438438
if machine.Status.NodeRef == nil {
439439
err := fmt.Errorf("instance state %v is unexpected", openStackServer.Status.InstanceState)
440-
openStackMachine.SetFailure(capierrors.UpdateMachineError, err)
440+
openStackMachine.SetFailure(capoerrors.DeprecatedCAPIUpdateMachineError, err)
441441
}
442442
conditions.MarkFalse(openStackMachine, infrav1.InstanceReadyCondition, infrav1.InstanceStateErrorReason, clusterv1.ConditionSeverityError, "")
443443
return &ctrl.Result{}

docs/book/src/api/v1alpha6/api.md

+2-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)