|
| 1 | +/* |
| 2 | +Copyright © contributors to CloudNativePG, established as |
| 3 | +CloudNativePG a Series of LF Projects, LLC. |
| 4 | +
|
| 5 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +you may not use this file except in compliance with the License. |
| 7 | +You may obtain a copy of the License at |
| 8 | +
|
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | +Unless required by applicable law or agreed to in writing, software |
| 12 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +See the License for the specific language governing permissions and |
| 15 | +limitations under the License. |
| 16 | +
|
| 17 | +SPDX-License-Identifier: Apache-2.0 |
| 18 | +*/ |
| 19 | + |
| 20 | +package v1 |
| 21 | + |
| 22 | +import ( |
| 23 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 24 | +) |
| 25 | + |
| 26 | +// +kubebuilder:object:root=true |
| 27 | + |
| 28 | +// FailoverQuorumList contains a list of FailoverQuorum |
| 29 | +type FailoverQuorumList struct { |
| 30 | + metav1.TypeMeta `json:",inline"` |
| 31 | + // Standard list metadata. |
| 32 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
| 33 | + // +optional |
| 34 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 35 | + // List of failoverquorums |
| 36 | + Items []FailoverQuorum `json:"items"` |
| 37 | +} |
| 38 | + |
| 39 | +// +genclient |
| 40 | +// +kubebuilder:object:root=true |
| 41 | +// +kubebuilder:storageversion |
| 42 | +// +kubebuilder:subresource:status |
| 43 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" |
| 44 | + |
| 45 | +// FailoverQuorum contains the information about the current failover |
| 46 | +// quorum status of a PG cluster. It is updated by the instance manager |
| 47 | +// of the primary node and reset to zero by the operator to trigger |
| 48 | +// an update. |
| 49 | +type FailoverQuorum struct { |
| 50 | + metav1.TypeMeta `json:",inline"` |
| 51 | + metav1.ObjectMeta `json:"metadata"` |
| 52 | + |
| 53 | + // Most recently observed status of the failover quorum. |
| 54 | + // +optional |
| 55 | + Status FailoverQuorumStatus `json:"status"` |
| 56 | +} |
| 57 | + |
| 58 | +// FailoverQuorumStatus is the latest observed status of the failover |
| 59 | +// quorum of the PG cluster. |
| 60 | +type FailoverQuorumStatus struct { |
| 61 | + // Contains the latest reported Method value. |
| 62 | + // +optional |
| 63 | + Method string `json:"method,omitempty"` |
| 64 | + |
| 65 | + // StandbyNames is the list of potentially synchronous |
| 66 | + // instance names. |
| 67 | + // +optional |
| 68 | + StandbyNames []string `json:"standbyNames,omitempty"` |
| 69 | + |
| 70 | + // StandbyNumber is the number of synchronous standbys that transactions |
| 71 | + // need to wait for replies from. |
| 72 | + // +optional |
| 73 | + StandbyNumber int `json:"standbyNumber,omitempty"` |
| 74 | + |
| 75 | + // Primary is the name of the primary instance that updated |
| 76 | + // this object the latest time. |
| 77 | + // +optional |
| 78 | + Primary string `json:"primary,omitempty"` |
| 79 | +} |
| 80 | + |
| 81 | +func init() { |
| 82 | + SchemeBuilder.Register(&FailoverQuorum{}, &FailoverQuorumList{}) |
| 83 | +} |
0 commit comments