Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Conditions for OpenStackMachines #1288

Merged
merged 1 commit into from
Jul 29, 2022
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
3 changes: 3 additions & 0 deletions api/v1alpha3/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha3
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"
)

Expand Down Expand Up @@ -125,6 +126,8 @@ type OpenStackMachineStatus struct {
// controller's output.
// +optional
FailureMessage *string `json:"errorMessage,omitempty"`

Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha3/zz_generated.conversion.go

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

8 changes: 8 additions & 0 deletions api/v1alpha3/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions api/v1alpha4/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha4
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"
)

Expand Down Expand Up @@ -125,6 +126,8 @@ type OpenStackMachineStatus struct {
// controller's output.
// +optional
FailureMessage *string `json:"errorMessage,omitempty"`

Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha4/zz_generated.conversion.go

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

7 changes: 7 additions & 0 deletions api/v1alpha4/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions api/v1alpha5/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha5
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"
)

Expand Down Expand Up @@ -129,6 +130,8 @@ type OpenStackMachineStatus struct {
// controller's output.
// +optional
FailureMessage *string `json:"failureMessage,omitempty"`

Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha5/zz_generated.conversion.go

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

7 changes: 7 additions & 0 deletions api/v1alpha5/zz_generated.deepcopy.go

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

53 changes: 53 additions & 0 deletions api/v1alpha6/conditions_consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright 2022 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha6

import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

const (
// InstanceReadyCondition reports on current status of the OpenStack instance. Ready indicates the instance is in a Running state.
InstanceReadyCondition clusterv1.ConditionType = "InstanceReady"

// WaitingForClusterInfrastructureReason used when machine is waiting for cluster infrastructure to be ready before proceeding.
WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure"
// WaitingForBootstrapDataReason used when machine is waiting for bootstrap data to be ready before proceeding.
WaitingForBootstrapDataReason = "WaitingForBootstrapData"
// InvalidMachineSpecReason used when the machine spec is invalid.
InvalidMachineSpecReason = "InvalidMachineSpec"
// InstanceCreateFailedReason used when creating the instance failed.
InstanceCreateFailedReason = "InstanceCreateFailed"
// InstanceNotFoundReason used when the instance couldn't be retrieved.
InstanceNotFoundReason = "InstanceNotFound"
// InstanceStateErrorReason used when the instance is in error state.
InstanceStateErrorReason = "InstanceStateError"
// InstanceDeletedReason used when the instance is in a deleted state.
InstanceDeletedReason = "InstanceDeleted"
// InstanceNotReadyReason used when the instance is in a pending state.
InstanceNotReadyReason = "InstanceNotReady"
// InstanceDeleteFailedReason used when deleting the instance failed.
InstanceDeleteFailedReason = "InstanceDeleteFailed"
)

const (
// APIServerIngressReadyCondition reports on the current status of the network ingress (Loadbalancer, Floating IP) for Control Plane machines. Ready indicates that the instance can receive requests.
APIServerIngressReadyCondition clusterv1.ConditionType = "APIServerIngressReadyCondition"

// LoadBalancerMemberErrorReason used when the instance could not be added as a loadbalancer member.
LoadBalancerMemberErrorReason = "LoadBalancerMemberError"
// FloatingIPErrorReason used when the floating ip could not be created or attached.
FloatingIPErrorReason = "FloatingIPError"
)
13 changes: 13 additions & 0 deletions api/v1alpha6/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha6
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"
)

Expand Down Expand Up @@ -129,6 +130,8 @@ type OpenStackMachineStatus struct {
// controller's output.
// +optional
FailureMessage *string `json:"failureMessage,omitempty"`

Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down Expand Up @@ -160,6 +163,16 @@ type OpenStackMachineList struct {
Items []OpenStackMachine `json:"items"`
}

// GetConditions returns the observations of the operational state of the OpenStackMachine resource.
func (r *OpenStackMachine) GetConditions() clusterv1.Conditions {
return r.Status.Conditions
}

// SetConditions sets the underlying service state of the OpenStackMachine to the predescribed clusterv1.Conditions.
func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) {
r.Status.Conditions = conditions
}

func init() {
SchemeBuilder.Register(&OpenStackMachine{}, &OpenStackMachineList{})
}
7 changes: 7 additions & 0 deletions api/v1alpha6/zz_generated.deepcopy.go

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

Loading