Skip to content

Commit db98067

Browse files
scotwellsclaude
andcommitted
fix(connector): read liveness node id directly, drop type-switch helper
The annotation still carries the full connectionDetails so the data is available for future connection types without a schema change. But the extension server reads the only field it uses today — the PublicKey node id — directly, rather than behind a type-switch helper. Pre-abstracting node-id extraction before we know what future connection types need is premature, so the ConnectorConnectionDetails.TunnelNodeID() helper is removed in favour of a direct, nil-guarded field read. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e83ab2b commit db98067

2 files changed

Lines changed: 17 additions & 25 deletions

File tree

api/v1alpha1/connector_types.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -212,30 +212,13 @@ type ConnectorLiveness struct {
212212
Ready bool `json:"ready"`
213213

214214
// ConnectionDetails is the upstream Connector's full
215-
// Status.ConnectionDetails, copied verbatim so the extension server can
216-
// extract the tunnel node ID in a type-aware way (see TunnelNodeID). Nil
215+
// Status.ConnectionDetails, copied verbatim. Carrying the complete structure
216+
// keeps the data available for future connection types without an
217+
// annotation-schema change; consumers read the field they need directly. Nil
217218
// when the upstream connector has not yet published connection details.
218219
ConnectionDetails *ConnectorConnectionDetails `json:"connectionDetails,omitempty"`
219220
}
220221

221-
// TunnelNodeID returns the data-plane tunnel endpoint_id for these connection
222-
// details, dispatching on the connection Type so new connection types can be
223-
// added by extending the switch rather than by assuming PublicKey. It returns
224-
// an empty string for nil details or any type that does not (yet) advertise a
225-
// node ID.
226-
func (d *ConnectorConnectionDetails) TunnelNodeID() string {
227-
if d == nil {
228-
return ""
229-
}
230-
switch d.Type {
231-
case PublicKeyConnectorConnectionType:
232-
if d.PublicKey != nil {
233-
return d.PublicKey.Id
234-
}
235-
}
236-
return ""
237-
}
238-
239222
// +kubebuilder:object:root=true
240223
// +kubebuilder:subresource:status
241224
// +kubebuilder:selectablefield:JSONPath=".status.connectionDetails.publicKey.id"

internal/extensionserver/cache/index.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,15 @@ func connectorLiveness(connector *networkingv1alpha1.Connector) (online bool, no
181181
if raw, ok := connector.Annotations[networkingv1alpha1.ConnectorLivenessAnnotation]; ok {
182182
var liveness networkingv1alpha1.ConnectorLiveness
183183
if err := json.Unmarshal([]byte(raw), &liveness); err == nil {
184-
// TunnelNodeID dispatches on the connection type, so a new
185-
// connection type is supported by extending that switch rather than
186-
// by changing the annotation schema here.
187-
return liveness.Ready, liveness.ConnectionDetails.TunnelNodeID()
184+
// The annotation carries the full connectionDetails so the data is
185+
// available for future connection types, but today we read the only
186+
// field we use — the PublicKey node id — directly.
187+
if details := liveness.ConnectionDetails; details != nil &&
188+
details.Type == networkingv1alpha1.PublicKeyConnectorConnectionType &&
189+
details.PublicKey != nil {
190+
nodeID = details.PublicKey.Id
191+
}
192+
return liveness.Ready, nodeID
188193
}
189194
// Unparseable annotation: fall through to status-based classification.
190195
}
@@ -194,7 +199,11 @@ func connectorLiveness(connector *networkingv1alpha1.Connector) (online bool, no
194199
networkingv1alpha1.ConnectorConditionReady,
195200
)
196201
if online {
197-
nodeID = connector.Status.ConnectionDetails.TunnelNodeID()
202+
if details := connector.Status.ConnectionDetails; details != nil &&
203+
details.Type == networkingv1alpha1.PublicKeyConnectorConnectionType &&
204+
details.PublicKey != nil {
205+
nodeID = details.PublicKey.Id
206+
}
198207
}
199208
return online, nodeID
200209
}

0 commit comments

Comments
 (0)