Skip to content

Commit 57953fa

Browse files
scotwellsclaude
andcommitted
test(extension-server): drop shorthand label from connector test comment
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5717ef2 commit 57953fa

4 files changed

Lines changed: 42 additions & 75 deletions

File tree

api/v1alpha1/connector_types.go

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -181,38 +181,25 @@ const (
181181

182182
const ConnectorNameAnnotation = "networking.datum.org/connector-name"
183183

184-
// ConnectorLivenessAnnotation carries a compact snapshot of a Connector's
185-
// authoritative upstream liveness down to edge member clusters.
186-
//
187-
// A Connector's Ready condition and ConnectionDetails are computed in the
188-
// Project control plane and stored in the Connector's status subresource. The
189-
// edge extension server reads connectors from the local member-cluster cache to
190-
// decide whether a tunnel is online. Karmada propagates a resource template's
191-
// spec and metadata (labels/annotations) to member clusters but NOT the status
192-
// subresource, so the member-cluster Connector never carries Ready or
193-
// ConnectionDetails. To bridge that gap the replicator stamps the liveness onto
194-
// this annotation — which Karmada DOES propagate — and the extension server
195-
// reads it from there, falling back to status when the annotation is absent.
196-
//
197-
// The value is a JSON-marshalled ConnectorLiveness. Keep the JSON schema in
198-
// sync with that type.
184+
// ConnectorLivenessAnnotation carries a Connector's liveness down to edge
185+
// member clusters. Connector Ready + ConnectionDetails are authoritative in the
186+
// Project control plane and live in the status subresource, but Karmada
187+
// propagates a resource template's spec + metadata to members, NOT its status.
188+
// The replicator stamps liveness onto this annotation (which Karmada does
189+
// propagate) so the edge extension server can read it. Value is a
190+
// JSON-marshalled ConnectorLiveness; keep the schema in sync.
199191
const ConnectorLivenessAnnotation = "networking.datumapis.com/connector-liveness"
200192

201193
// ConnectorLiveness is the JSON payload stored in ConnectorLivenessAnnotation.
202-
//
203-
// It carries only the status-derived fields the extension server needs to
204-
// classify a connector online/offline and to build the data-plane tunnel
205-
// cluster. It deliberately does NOT include the tunnel TargetHost/TargetPort:
206-
// those are derived from the referencing HTTPProxy backend endpoint URL, not
207-
// from Connector status.
194+
// It carries only the status-derived fields the extension server consumes.
195+
// TargetHost/TargetPort are intentionally absent: they derive from the
196+
// referencing HTTPProxy backend endpoint, not from Connector status.
208197
type ConnectorLiveness struct {
209198
// Ready mirrors the upstream Connector's Ready condition being True.
210199
Ready bool `json:"ready"`
211200

212-
// NodeID is the connector's public-key id, taken from
213-
// Status.ConnectionDetails.PublicKey.Id when the connector is ready and
214-
// advertises PublicKey connection details. Empty otherwise. Used as the
215-
// tunnel endpoint_id in the data-plane connector cluster.
201+
// NodeID is Status.ConnectionDetails.PublicKey.Id, used as the tunnel
202+
// endpoint_id in the data-plane connector cluster.
216203
NodeID string `json:"nodeID,omitempty"`
217204
}
218205

internal/controller/gateway_resource_replicator_controller.go

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,20 @@ type replicationResourceConfig struct {
7474
conditionHandlers conditionReasonHandlers
7575

7676
// mirrorStatusDownstream copies upstream status → downstream status after
77-
// each spec sync. Used for resource types whose status is authoritative in
78-
// the upstream cluster and must be readable by consumers in the downstream
79-
// cluster. When true, skipUpstreamStatusSync is implicitly honoured as well.
77+
// each spec sync, for resource types whose status is authoritative upstream.
78+
// When true, skipUpstreamStatusSync is implicitly honoured as well.
8079
//
81-
// NOTE: this does NOT work across a Karmada hub→member boundary — Karmada
82-
// propagates a resource template's spec + metadata to members but NOT the
83-
// status subresource. For the Connector type (whose downstream consumer, the
84-
// edge extension server, lives on a member cluster) use
85-
// writeLivenessAnnotation instead, which rides an annotation Karmada does
86-
// propagate.
80+
// NOTE: ineffective across a Karmada hub→member boundary — Karmada does not
81+
// propagate the status subresource to members. For the Connector type (read
82+
// by the edge extension server on a member cluster) use
83+
// writeLivenessAnnotation instead.
8784
mirrorStatusDownstream bool
8885

89-
// writeLivenessAnnotation, when true, derives a compact liveness snapshot
90-
// from the upstream Connector's status and stores it as the
91-
// ConnectorLivenessAnnotation on the downstream object's metadata. Karmada
92-
// propagates resource-template annotations (but NOT the status subresource)
93-
// to member clusters, so this is how connector liveness reaches the edge
94-
// extension server. Used instead of mirrorStatusDownstream for the Connector
95-
// type. Implies skipUpstreamStatusSync should also be set.
86+
// writeLivenessAnnotation derives a compact liveness snapshot from the
87+
// upstream Connector's status and stores it as ConnectorLivenessAnnotation
88+
// on the downstream object's metadata. Karmada propagates metadata (but not
89+
// status) to members, so this is how connector liveness reaches the edge
90+
// extension server. Implies skipUpstreamStatusSync should also be set.
9691
writeLivenessAnnotation bool
9792

9893
// skipUpstreamStatusSync suppresses the normal downstream→upstream status
@@ -163,13 +158,10 @@ func initReplicationResourceConfigs() map[string]replicationResourceConfig {
163158
}
164159
}
165160

166-
// Connector liveness (Ready condition + connectionDetails) is authoritative
167-
// upstream and must be readable by the edge extension server so it can
168-
// determine whether a tunnel is online before injecting connector cluster
169-
// patches. The extension server runs on a member cluster, and Karmada does
170-
// not propagate the status subresource hub→member — only spec + metadata.
171-
// Carry liveness down through an annotation (which Karmada DOES propagate)
172-
// instead of mirroring status. Do not propagate status back upstream.
161+
// Connector liveness (Ready + connectionDetails) is authoritative upstream
162+
// and read by the edge extension server on a member cluster. Karmada does
163+
// not propagate status hub→member, so carry liveness down via an annotation
164+
// instead. Do not propagate status back upstream.
173165
connectorGVK := schema.GroupVersionKind{Group: groupNetworkingDatumAPIs, Version: versionV1Alpha1, Kind: KindConnector}
174166
configs[gvkKey(connectorGVK)] = replicationResourceConfig{
175167
writeLivenessAnnotation: true,
@@ -334,10 +326,8 @@ func (r *GatewayResourceReplicatorReconciler) ensureDownstreamResource(
334326
return fmt.Errorf("failed to set downstream controller reference: %w", err)
335327
}
336328

337-
// Stamp the connector liveness annotation onto the downstream object's
338-
// metadata. This is part of the same CreateOrUpdate Update, so it is
339-
// persisted as ordinary metadata (which Karmada propagates to members) —
340-
// no status subresource write involved.
329+
// Persisted as ordinary metadata via this same CreateOrUpdate Update —
330+
// no status subresource write — so Karmada propagates it to members.
341331
if resource.replicationResourceConfig.writeLivenessAnnotation {
342332
if err := setConnectorLivenessAnnotation(downstreamObj, upstreamObj); err != nil {
343333
return err
@@ -457,12 +447,10 @@ func (r *GatewayResourceReplicatorReconciler) mirrorUpstreamStatusToDownstream(
457447
return nil
458448
}
459449

460-
// setConnectorLivenessAnnotation derives a compact liveness snapshot from the
461-
// upstream Connector's status and stores it as ConnectorLivenessAnnotation on
462-
// the downstream object's metadata. It is the Karmada-friendly replacement for
463-
// mirroring the status subresource downstream: Karmada propagates a resource
464-
// template's metadata (annotations) to member clusters but not its status, so
465-
// the edge extension server reads liveness from this annotation instead.
450+
// setConnectorLivenessAnnotation stamps the upstream Connector's liveness onto
451+
// the downstream object's metadata. Karmada propagates metadata (but not the
452+
// status subresource) to members, so the edge extension server reads liveness
453+
// from this annotation rather than from downstream status.
466454
func setConnectorLivenessAnnotation(downstreamObj, upstreamObj *unstructured.Unstructured) error {
467455
liveness, err := connectorLivenessFromUpstream(upstreamObj)
468456
if err != nil {
@@ -483,10 +471,8 @@ func setConnectorLivenessAnnotation(downstreamObj, upstreamObj *unstructured.Uns
483471
return nil
484472
}
485473

486-
// connectorLivenessFromUpstream extracts the Ready condition and PublicKey node
487-
// ID from an upstream Connector's (unstructured) status. A connector with no
488-
// status, a non-True Ready condition, or no PublicKey connection details yields
489-
// a not-ready liveness with an empty NodeID.
474+
// connectorLivenessFromUpstream extracts Ready and the PublicKey node ID from an
475+
// upstream Connector's (unstructured) status.
490476
func connectorLivenessFromUpstream(upstreamObj *unstructured.Unstructured) (networkingv1alpha1.ConnectorLiveness, error) {
491477
var liveness networkingv1alpha1.ConnectorLiveness
492478

internal/extensionserver/cache/index.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,12 @@ func populateFromClient(ctx context.Context, cl client.Client, idx *PolicyIndex,
165165
return nil
166166
}
167167

168-
// connectorLiveness determines whether a connector is online and, if so, its
169-
// tunnel node ID. It prefers the ConnectorLivenessAnnotation, which is how
170-
// connector liveness reaches edge member clusters: a Connector's Ready condition
171-
// and ConnectionDetails are authoritative in the Project control plane and live
172-
// in its status subresource, but Karmada propagates a resource template's spec +
173-
// metadata (annotations) to members, NOT the status subresource. The replicator
174-
// stamps the liveness onto the annotation; this reads it back.
175-
//
176-
// When the annotation is absent or unparseable — single-cluster deployments
177-
// (where the local object carries real status), or member-cluster objects
178-
// written before this rollout — it falls back to the status-based
179-
// classification, preserving the previous behaviour.
168+
// connectorLiveness reports whether a connector is online and its tunnel node
169+
// ID. It prefers ConnectorLivenessAnnotation: on member clusters Karmada
170+
// delivers a connector's metadata but not its status, so liveness rides the
171+
// annotation. It falls back to status when the annotation is absent or
172+
// unparseable — single-cluster deployments and objects written before this
173+
// rollout — preserving the previous behaviour.
180174
func connectorLiveness(connector *networkingv1alpha1.Connector) (online bool, nodeID string) {
181175
if raw, ok := connector.Annotations[networkingv1alpha1.ConnectorLivenessAnnotation]; ok {
182176
var liveness networkingv1alpha1.ConnectorLiveness

internal/extensionserver/mutate/connector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func TestApplyConnectorRoutes_Offline_Prepends503Route_NoDomain(t *testing.T) {
310310
"offline route body must be 'Tunnel not online' per STATE.md contract")
311311

312312
// Second route: the original user-facing forwarding route must now be a
313-
// direct_response 503 too (Gap B), NOT a cluster route to the empty cluster.
313+
// direct_response 503 too, NOT a cluster route to the empty cluster.
314314
fwd := vh.Routes[1]
315315
assert.Equal(t, "fwd", fwd.GetName(), "forwarding route identity preserved")
316316
assert.Empty(t, routeCluster(fwd),

0 commit comments

Comments
 (0)