Skip to content

Commit 0ad94d6

Browse files
committed
apis: add ServiceExport condition type/reasons
Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
1 parent a23ff80 commit 0ad94d6

File tree

1 file changed

+163
-0
lines changed

1 file changed

+163
-0
lines changed

pkg/apis/v1alpha1/serviceexport.go

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,17 @@ const (
6666
// service export has been recognized as valid by an mcs-controller.
6767
// This will be false if the service is found to be unexportable
6868
// (ExternalName, not found).
69+
//
70+
// Deprecated: use ServiceExportConditionAccepted instead
6971
ServiceExportValid = "Valid"
7072
// ServiceExportConflict means that there is a conflict between two
7173
// exports for the same Service. When "True", the condition message
7274
// should contain enough information to diagnose the conflict:
7375
// field(s) under contention, which cluster won, and why.
7476
// Users should not expect detailed per-cluster information in the
7577
// conflict message.
78+
//
79+
// Deprecated: use ServiceExportConditionConflicted instead
7680
ServiceExportConflict = "Conflict"
7781
)
7882

@@ -88,3 +92,162 @@ type ServiceExportList struct {
8892
// +listType=set
8993
Items []ServiceExport `json:"items"`
9094
}
95+
96+
// ServiceExportConditionType is a type of condition associated with a
97+
// ServiceExport. This type should be used with the ServiceExportStatus.Conditions
98+
// field.
99+
type ServiceExportConditionType string
100+
101+
// ServiceExportConditionReason defines the set of reasons that explain why a
102+
// particular ServiceExport condition type has been raised.
103+
type ServiceExportConditionReason string
104+
105+
// NewServiceExportCondition creates a new ServiceExport condition
106+
func NewServiceExportCondition(t ServiceExportConditionType, status metav1.ConditionStatus, reason ServiceExportConditionReason, msg string) metav1.Condition {
107+
return metav1.Condition{
108+
Type: string(t),
109+
Status: status,
110+
Reason: string(reason),
111+
Message: msg,
112+
LastTransitionTime: metav1.Now(),
113+
}
114+
}
115+
116+
const (
117+
// ServiceExportConditionAccepted is true when the Service Export is accepted.
118+
// This does not indicate whether or not the configuration has been exported
119+
// to a control plane / data plane.
120+
//
121+
//
122+
// Possible reasons for this condition to be true are:
123+
//
124+
// * "Accepted"
125+
//
126+
// Possible reasons for this condition to be False are:
127+
//
128+
// * "NoService"
129+
// * "InvalidServiceType"
130+
//
131+
// Controllers may raise this condition with other reasons,
132+
// but should prefer to use the reasons listed above to improve
133+
// interoperability.
134+
ServiceExportConditionAccepted ServiceExportConditionType = "Accepted"
135+
136+
// ServiceExportReasonAccepted is used with the "Accepted" condition when the
137+
// condition is True.
138+
ServiceExportReasonAccepted ServiceExportConditionReason = "Accepted"
139+
140+
// ServiceExportReasonNoService is used with the "Accepted" condition when
141+
// the associated Service does not exist.
142+
ServiceExportReasonNoService ServiceExportConditionReason = "NoService"
143+
144+
// ServiceExportReasonInvalidServiceType is used with the "Accepted"
145+
// condition when the associated Service has an invalid type
146+
// (per the KEP at least the ExternalName type).
147+
ServiceExportReasonInvalidServiceType ServiceExportConditionReason = "InvalidServiceType"
148+
)
149+
150+
const (
151+
// ServiceExportConditionExported is true when the service is exported to some
152+
// control plane or data plane. This condition might not makes sense
153+
// for every implementation, particularly if they function in a "pull mode"
154+
// rather than actually exporting the service, and in that case implementations
155+
// do not have do use this Condition type at all.
156+
//
157+
//
158+
// Possible reasons for this condition to be true are:
159+
//
160+
// * "Exported"
161+
//
162+
// Possible reasons for this condition to be False are:
163+
//
164+
// * "Pending"
165+
// * "Failed"
166+
//
167+
// Possible reasons for this condition to be Unknown are:
168+
//
169+
// * "Pending"
170+
//
171+
// Controllers may raise this condition with other reasons,
172+
// but should prefer to use the reasons listed above to improve
173+
// interoperability.
174+
ServiceExportConditionExported ServiceExportConditionType = "Exported"
175+
176+
// ServiceExportReasonExported is used with the "Exported" condition
177+
// when the condition is True.
178+
ServiceExportReasonExported ServiceExportConditionReason = "Exported"
179+
180+
// ServiceExportReasonPending is used with the "Exported" condition
181+
// when the service is in the process of being exported.
182+
ServiceExportReasonPending ServiceExportConditionReason = "Pending"
183+
184+
// ServiceExportReasonFailed is used with the "Exported" condition
185+
// when the service failed to be exported with the message providing
186+
// the specific reason.
187+
ServiceExportReasonFailed ServiceExportConditionReason = "Failed"
188+
)
189+
190+
const (
191+
// ServiceExportConditionConflicted indicates that some property of an
192+
// exported service has conflicting values across the constituent
193+
// ServiceExports. This condition must be at least raised on the
194+
// conflicting ServiceExport and is recommended to be raised on all on
195+
// all the constituent ServiceExports if feasible.
196+
//
197+
//
198+
// Possible reasons for this condition to be true are:
199+
//
200+
// * "PortConflict"
201+
// * "TypeConflict"
202+
// * "SessionAffinityConflict"
203+
// * "SessionAffinityConfigConflict"
204+
// * "AnnotationsConflict"
205+
// * "LabelsConflict"
206+
//
207+
// When multiple conflicts occurs the above reasons may be combined
208+
// using commas.
209+
//
210+
// Possible reasons for this condition to be False are:
211+
//
212+
// * "NoConflicts"
213+
//
214+
// Controllers may raise this condition with other reasons,
215+
// but should prefer to use the reasons listed above to improve
216+
// interoperability.
217+
ServiceExportConditionConflicted ServiceExportConditionType = "Conflicted"
218+
219+
// ServiceExportReasonPortConflict is used with the "Conflicted" condition
220+
// when the exported service has a conflict related to port configuration.
221+
// This includes when ports on resulting imported services would have
222+
// duplicated names (including unnamed/empty name) or duplicated
223+
// port/protocol pairs.
224+
ServiceExportReasonPortConflict ServiceExportConditionReason = "PortConflict"
225+
226+
// ServiceExportReasonTypeConflict is used with the "Conflicted" condition
227+
// when the exported service has a conflict related to the service type
228+
// (eg headless vs non-headless).
229+
ServiceExportReasonTypeConflict ServiceExportConditionReason = "TypeConflict"
230+
231+
// ServiceExportReasonSessionAffinityConflict is used with the "Conflicted"
232+
// condition when the exported service has a conflict related to session affinity.
233+
ServiceExportReasonSessionAffinityConflict ServiceExportConditionReason = "SessionAffinityConflict"
234+
235+
// ServiceExportReasonSessionAffinityConfigConflict is used with the
236+
// "Conflicted" condition when the exported service has a conflict related
237+
// to session affinity config.
238+
ServiceExportReasonSessionAffinityConfigConflict ServiceExportConditionReason = "SessionAffinityConfigConflict"
239+
240+
// ServiceExportReasonLabelsConflict is used with the "Conflicted"
241+
// condition when the ServiceExport has a conflict related to exported
242+
// labels.
243+
ServiceExportReasonLabelsConflict ServiceExportConditionReason = "LabelsConflict"
244+
245+
// ServiceExportReasonAnnotationsConflict is used with the "Conflicted"
246+
// condition when the ServiceExport has a conflict related to exported
247+
// annotations.
248+
ServiceExportReasonAnnotationsConflict ServiceExportConditionReason = "AnnotationsConflict"
249+
250+
// ServiceExportReasonNoConflicts is used with the "Conflicted" condition
251+
// when the condition is False.
252+
ServiceExportReasonNoConflicts ServiceExportConditionReason = "NoConflicts"
253+
)

0 commit comments

Comments
 (0)