Skip to content

Commit 9517ff4

Browse files
tomhjpirbekrm
andcommitted
k8s-operator,cmd/k8s-operator: add proxy status to service conditions
Adds a new TailscaleProxyReady condition type for use in corev1.Service conditions. Also switches our CRDs to use metav1.Condition instead of ConnectorCondition. The Go structs are seralized identically, but it updates some descriptions and validation rules. Updates #12216 Co-authored-by: Irbe Krumina <irbe@tailscale.com> Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
1 parent a95ea31 commit 9517ff4

21 files changed

+507
-284
lines changed

cmd/k8s-operator/connector.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ import (
3333

3434
const (
3535
reasonConnectorCreationFailed = "ConnectorCreationFailed"
36-
37-
reasonConnectorCreated = "ConnectorCreated"
38-
reasonConnectorCleanupFailed = "ConnectorCleanupFailed"
39-
reasonConnectorCleanupInProgress = "ConnectorCleanupInProgress"
40-
reasonConnectorInvalid = "ConnectorInvalid"
36+
reasonConnectorCreated = "ConnectorCreated"
37+
reasonConnectorInvalid = "ConnectorInvalid"
4138

4239
messageConnectorCreationFailed = "Failed creating Connector: %v"
4340
messageConnectorInvalid = "Connector is invalid: %v"
@@ -108,7 +105,7 @@ func (a *ConnectorReconciler) Reconcile(ctx context.Context, req reconcile.Reque
108105
}
109106

110107
oldCnStatus := cn.Status.DeepCopy()
111-
setStatus := func(cn *tsapi.Connector, _ tsapi.ConnectorConditionType, status metav1.ConditionStatus, reason, message string) (reconcile.Result, error) {
108+
setStatus := func(cn *tsapi.Connector, _ tsapi.ConditionType, status metav1.ConditionStatus, reason, message string) (reconcile.Result, error) {
112109
tsoperator.SetConnectorCondition(cn, tsapi.ConnectorReady, status, reason, message, cn.Generation, a.clock, logger)
113110
if !apiequality.Semantic.DeepEqual(oldCnStatus, cn.Status) {
114111
// An error encountered here should get returned by the Reconcile function.

cmd/k8s-operator/connector_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,9 @@ func TestConnectorWithProxyClass(t *testing.T) {
272272
// its resources.
273273
mustUpdateStatus(t, fc, "", "custom-metadata", func(pc *tsapi.ProxyClass) {
274274
pc.Status = tsapi.ProxyClassStatus{
275-
Conditions: []tsapi.ConnectorCondition{{
275+
Conditions: []metav1.Condition{{
276276
Status: metav1.ConditionTrue,
277-
Type: tsapi.ProxyClassready,
277+
Type: string(tsapi.ProxyClassready),
278278
ObservedGeneration: pc.Generation,
279279
}}}
280280
})

cmd/k8s-operator/deploy/crds/tailscale.com_connectors.yaml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,46 @@ spec:
8888
description: List of status conditions to indicate the status of the Connector. Known condition types are `ConnectorReady`.
8989
type: array
9090
items:
91-
description: ConnectorCondition contains condition information for a Connector.
91+
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
9292
type: object
9393
required:
94+
- lastTransitionTime
95+
- message
96+
- reason
9497
- status
9598
- type
9699
properties:
97100
lastTransitionTime:
98-
description: LastTransitionTime is the timestamp corresponding to the last status change of this condition.
101+
description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
99102
type: string
100103
format: date-time
101104
message:
102-
description: Message is a human readable description of the details of the last transition, complementing reason.
105+
description: message is a human readable message indicating details about the transition. This may be an empty string.
103106
type: string
107+
maxLength: 32768
104108
observedGeneration:
105-
description: If set, this represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.condition[x].observedGeneration is 9, the condition is out of date with respect to the current state of the Connector.
109+
description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
106110
type: integer
107111
format: int64
112+
minimum: 0
108113
reason:
109-
description: Reason is a brief machine readable explanation for the condition's last transition.
114+
description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.
110115
type: string
116+
maxLength: 1024
117+
minLength: 1
118+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
111119
status:
112-
description: Status of the condition, one of ('True', 'False', 'Unknown').
120+
description: status of the condition, one of True, False, Unknown.
113121
type: string
122+
enum:
123+
- "True"
124+
- "False"
125+
- Unknown
114126
type:
115-
description: Type of the condition, known values are (`SubnetRouterReady`).
127+
description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
116128
type: string
129+
maxLength: 316
130+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
117131
x-kubernetes-list-map-keys:
118132
- type
119133
x-kubernetes-list-type: map

cmd/k8s-operator/deploy/crds/tailscale.com_dnsconfigs.yaml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,46 @@ spec:
6363
conditions:
6464
type: array
6565
items:
66-
description: ConnectorCondition contains condition information for a Connector.
66+
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
6767
type: object
6868
required:
69+
- lastTransitionTime
70+
- message
71+
- reason
6972
- status
7073
- type
7174
properties:
7275
lastTransitionTime:
73-
description: LastTransitionTime is the timestamp corresponding to the last status change of this condition.
76+
description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
7477
type: string
7578
format: date-time
7679
message:
77-
description: Message is a human readable description of the details of the last transition, complementing reason.
80+
description: message is a human readable message indicating details about the transition. This may be an empty string.
7881
type: string
82+
maxLength: 32768
7983
observedGeneration:
80-
description: If set, this represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.condition[x].observedGeneration is 9, the condition is out of date with respect to the current state of the Connector.
84+
description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
8185
type: integer
8286
format: int64
87+
minimum: 0
8388
reason:
84-
description: Reason is a brief machine readable explanation for the condition's last transition.
89+
description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.
8590
type: string
91+
maxLength: 1024
92+
minLength: 1
93+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
8694
status:
87-
description: Status of the condition, one of ('True', 'False', 'Unknown').
95+
description: status of the condition, one of True, False, Unknown.
8896
type: string
97+
enum:
98+
- "True"
99+
- "False"
100+
- Unknown
89101
type:
90-
description: Type of the condition, known values are (`SubnetRouterReady`).
102+
description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
91103
type: string
104+
maxLength: 316
105+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
92106
x-kubernetes-list-map-keys:
93107
- type
94108
x-kubernetes-list-type: map

cmd/k8s-operator/deploy/crds/tailscale.com_proxyclasses.yaml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,32 +1046,46 @@ spec:
10461046
description: List of status conditions to indicate the status of the ProxyClass. Known condition types are `ProxyClassReady`.
10471047
type: array
10481048
items:
1049-
description: ConnectorCondition contains condition information for a Connector.
1049+
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
10501050
type: object
10511051
required:
1052+
- lastTransitionTime
1053+
- message
1054+
- reason
10521055
- status
10531056
- type
10541057
properties:
10551058
lastTransitionTime:
1056-
description: LastTransitionTime is the timestamp corresponding to the last status change of this condition.
1059+
description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
10571060
type: string
10581061
format: date-time
10591062
message:
1060-
description: Message is a human readable description of the details of the last transition, complementing reason.
1063+
description: message is a human readable message indicating details about the transition. This may be an empty string.
10611064
type: string
1065+
maxLength: 32768
10621066
observedGeneration:
1063-
description: If set, this represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.condition[x].observedGeneration is 9, the condition is out of date with respect to the current state of the Connector.
1067+
description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
10641068
type: integer
10651069
format: int64
1070+
minimum: 0
10661071
reason:
1067-
description: Reason is a brief machine readable explanation for the condition's last transition.
1072+
description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.
10681073
type: string
1074+
maxLength: 1024
1075+
minLength: 1
1076+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
10691077
status:
1070-
description: Status of the condition, one of ('True', 'False', 'Unknown').
1078+
description: status of the condition, one of True, False, Unknown.
10711079
type: string
1080+
enum:
1081+
- "True"
1082+
- "False"
1083+
- Unknown
10721084
type:
1073-
description: Type of the condition, known values are (`SubnetRouterReady`).
1085+
description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
10741086
type: string
1087+
maxLength: 316
1088+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
10751089
x-kubernetes-list-map-keys:
10761090
- type
10771091
x-kubernetes-list-type: map

0 commit comments

Comments
 (0)