Skip to content

Commit

Permalink
Import deprecated but needed errors constants from CAPI
Browse files Browse the repository at this point in the history
Context: kubernetes-sigs/cluster-api#10784
We'll maintain them here for the time being, until we have conditions
replacing these errors.
  • Loading branch information
EmilienM committed Nov 20, 2024
1 parent 47e380f commit fa6367c
Show file tree
Hide file tree
Showing 24 changed files with 124 additions and 108 deletions.
5 changes: 3 additions & 2 deletions api/v1alpha6/openstackcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ package v1alpha6
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
capierrors "sigs.k8s.io/cluster-api/errors"

capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
)

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

// FailureMessage will be set in the event that there is a terminal problem
// reconciling the OpenStackCluster and will contain a more verbose string suitable
Expand Down
7 changes: 4 additions & 3 deletions api/v1alpha6/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"

capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
)

const (
Expand Down Expand Up @@ -118,7 +119,7 @@ type OpenStackMachineStatus struct {
// +optional
InstanceState *InstanceState `json:"instanceState,omitempty"`

FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
FailureReason *capoerrors.DeprecatedCAPIMachineStatusError `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 Expand Up @@ -189,7 +190,7 @@ func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) {
}

// SetFailure sets the OpenStackMachine status failure reason and failure message.
func (r *OpenStackMachine) SetFailure(failureReason errors.MachineStatusError, failureMessage error) {
func (r *OpenStackMachine) SetFailure(failureReason capoerrors.DeprecatedCAPIMachineStatusError, failureMessage error) {
r.Status.FailureReason = &failureReason
r.Status.FailureMessage = ptr.To(failureMessage.Error())
}
Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha6/zz_generated.conversion.go

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

6 changes: 3 additions & 3 deletions api/v1alpha6/zz_generated.deepcopy.go

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

5 changes: 3 additions & 2 deletions api/v1alpha7/openstackcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ package v1alpha7
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
capierrors "sigs.k8s.io/cluster-api/errors"

capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
)

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

// FailureMessage will be set in the event that there is a terminal problem
// reconciling the OpenStackCluster and will contain a more verbose string suitable
Expand Down
7 changes: 4 additions & 3 deletions api/v1alpha7/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"

capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
)

const (
Expand Down Expand Up @@ -118,7 +119,7 @@ type OpenStackMachineStatus struct {
// +optional
InstanceState *InstanceState `json:"instanceState,omitempty"`

FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
FailureReason *capoerrors.DeprecatedCAPIMachineStatusError `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 Expand Up @@ -187,7 +188,7 @@ func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) {
}

// SetFailure sets the OpenStackMachine status failure reason and failure message.
func (r *OpenStackMachine) SetFailure(failureReason errors.MachineStatusError, failureMessage error) {
func (r *OpenStackMachine) SetFailure(failureReason capoerrors.DeprecatedCAPIMachineStatusError, failureMessage error) {
r.Status.FailureReason = &failureReason
r.Status.FailureMessage = ptr.To(failureMessage.Error())
}
Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha7/zz_generated.conversion.go

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

6 changes: 3 additions & 3 deletions api/v1alpha7/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions api/v1beta1/openstackcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
capierrors "sigs.k8s.io/cluster-api/errors"

capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
)

Expand Down Expand Up @@ -256,7 +256,7 @@ type OpenStackClusterStatus struct {
// OpenStackClusters can be added as events to the OpenStackCluster object
// and/or logged in the controller's output.
// +optional
FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"`
FailureReason *capoerrors.DeprecatedCAPIClusterStatusError `json:"failureReason,omitempty"`

// FailureMessage will be set in the event that there is a terminal problem
// reconciling the OpenStackCluster and will contain a more verbose string suitable
Expand Down
6 changes: 3 additions & 3 deletions api/v1beta1/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"

capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
)

Expand Down Expand Up @@ -211,7 +211,7 @@ type OpenStackMachineStatus struct {
// +optional
Resources *MachineResources `json:"resources,omitempty"`

FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
FailureReason *capoerrors.DeprecatedCAPIMachineStatusError `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 Expand Up @@ -276,7 +276,7 @@ func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) {
}

// SetFailure sets the OpenStackMachine status failure reason and failure message.
func (r *OpenStackMachine) SetFailure(failureReason errors.MachineStatusError, failureMessage error) {
func (r *OpenStackMachine) SetFailure(failureReason capoerrors.DeprecatedCAPIMachineStatusError, failureMessage error) {
r.Status.FailureReason = &failureReason
r.Status.FailureMessage = ptr.To(failureMessage.Error())
}
Expand Down
6 changes: 3 additions & 3 deletions api/v1beta1/zz_generated.deepcopy.go

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

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

3 changes: 1 addition & 2 deletions controllers/openstackcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/utils/ptr"
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/collections"
Expand Down Expand Up @@ -882,7 +881,7 @@ func (r *OpenStackClusterReconciler) SetupWithManager(ctx context.Context, mgr c

func handleUpdateOSCError(openstackCluster *infrav1.OpenStackCluster, message error, isFatal bool) {
if isFatal {
err := capierrors.UpdateClusterError
err := capoerrors.DeprecatedCAPOUpdateClusterError
openstackCluster.Status.FailureReason = &err
openstackCluster.Status.FailureMessage = ptr.To(message.Error())
}
Expand Down
Loading

0 comments on commit fa6367c

Please sign in to comment.