Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ tasks:
deps: [golangci-lint, yamlfmt, yaml-ext, 'build:ebpf']
cmds:
- '{{.GOLANGCI_LINT}} run'
# examples/edge-provider and examples/looking-glass-client are their
# own modules, which the root run skips.
# examples/edge-provider, examples/looking-glass-client and
# examples/worker-client are their own modules, which the root run skips.
- cd examples/edge-provider && {{.GOLANGCI_LINT}} run --config ../../.golangci.yaml
- cd examples/looking-glass-client && {{.GOLANGCI_LINT}} run --config ../../.golangci.yaml
- cd examples/worker-client && {{.GOLANGCI_LINT}} run --config ../../.golangci.yaml
- '{{.YAMLFMT}} -lint'
lint-fix:
desc: Lint and apply fixes
Expand Down Expand Up @@ -171,6 +172,7 @@ tasks:
- go build -ldflags "{{.LDFLAGS}}" -o bin/galactic-gateway ./cmd/galactic-gateway
- go build -ldflags "{{.LDFLAGS}}" -o bin/galactic-nat ./cmd/galactic-nat
- go build -ldflags "{{.LDFLAGS}}" -o bin/galactic-vrf ./cmd/galactic-vrf
- go build -ldflags "{{.LDFLAGS}}" -o bin/galactic-worker ./cmd/galactic-worker
- go build -ldflags "{{.LDFLAGS}}" -o bin/fabric-config-agent ./cmd/fabric-config-agent
- go build -ldflags "{{.LDFLAGS}}" -o bin/fabric-api ./cmd/fabric-api
- go build -ldflags "{{.LDFLAGS}}" -o bin/galactic-controller ./cmd/galactic-controller
Expand All @@ -186,6 +188,7 @@ tasks:
- bash scripts/ci.sh unittest
- task: test:edge-provider
- task: test:looking-glass-client
- task: test:worker-client
test:edge-provider:
desc: Build, vet and unit-test the reference edge provider (examples/edge-provider, its own module)
dir: examples/edge-provider
Expand All @@ -206,6 +209,19 @@ tasks:
echo "the client imports Galactic packages beyond the published service API" >&2
exit 1
fi
test:worker-client:
desc: Build, vet and unit-test the independent Worker client (examples/worker-client, its own module)
dir: examples/worker-client
cmds:
- go build ./...
- go vet ./...
- go test -race ./...
# The client must build from the published Worker API alone.
- |
if go list -deps ./... | grep -E '^go\.datum\.net/galactic/' | grep -vxE 'go\.datum\.net/galactic/(api/galactic/worker/v1alpha1|pkg/workerclient)'; then
echo "the client imports Galactic packages beyond the published Worker API" >&2
exit 1
fi
test:unit-root:
desc: Re-run just the requireRoot(t)-gated unit tests, as root
deps: ['build:ebpf']
Expand Down
118 changes: 118 additions & 0 deletions api/galactic/worker/v1alpha1/contract.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Copyright 2026 Datum Cloud, Inc.
//
// SPDX-License-Identifier: AGPL-3.0-or-later

package workerv1alpha1

// The names below are part of the published contract
// (docs/worker/contract.md). Clients compare against them; Worker emits them.

const (
// Version is the API version this package serves.
Version = "v1alpha1"
// ErrorDomain is the google.rpc.ErrorInfo domain of every refusal.
ErrorDomain = "worker.galactic.datumapis.com"
// TokenAudience is the audience of the projected ServiceAccount token a
// client presents.
TokenAudience = "galactic-worker"
// DefaultSocketPath is where Worker serves the API.
DefaultSocketPath = "/run/galactic-worker/worker.sock"
// SessionMetadataKey carries the session ID on every call but the first
// GetCapabilities. A GetCapabilities that carries a live session ID
// renews that session instead of starting a new one.
SessionMetadataKey = "x-galactic-worker-session"
)

// ErrorInfo metadata keys.
const (
// MetadataCurrentGeneration is the claim's current generation, on
// StaleGeneration and GenerationConflict.
MetadataCurrentGeneration = "current_generation"
// MetadataServedVersions lists the versions Worker serves, comma
// separated, on UnsupportedVersion.
MetadataServedVersions = "served_versions"
)

// Capability names.
const (
CapabilityLocalTap = "local.tap"
CapabilityLocalVethPair = "local.veth_pair"
CapabilityLocalRoutedLink = "local.routed_link"
CapabilityLocalSocket = "local.socket"
CapabilityFabricSRv6 = "fabric.srv6"
)

// Capabilities lists every capability in the order GetCapabilities reports
// them.
var Capabilities = []string{
CapabilityLocalTap, CapabilityLocalVethPair, CapabilityLocalRoutedLink,
CapabilityLocalSocket, CapabilityFabricSRv6,
}

// HandoffCapability is the Local capability a handoff kind needs, or "" for
// HANDOFF_UNSPECIFIED.
func HandoffCapability(h Handoff) string {
switch h {
case Handoff_HANDOFF_TAP:
return CapabilityLocalTap
case Handoff_HANDOFF_VETH_PAIR:
return CapabilityLocalVethPair
case Handoff_HANDOFF_ROUTED_LINK:
return CapabilityLocalRoutedLink
case Handoff_HANDOFF_SOCKET:
return CapabilityLocalSocket
default:
return ""
}
}

// Condition types.
const (
ConditionAdmitted = "Admitted"
ConditionResolved = "Resolved"
ConditionProgrammed = "Programmed"
ConditionReady = "Ready"
ConditionWithdrawing = "Withdrawing"
)

// Refusal reasons, carried in google.rpc.ErrorInfo.
const (
ReasonMalformedSpec = "MalformedSpec"
ReasonWrongNode = "WrongNode"
ReasonNoIdentity = "NoIdentity"
ReasonIdentityExpired = "IdentityExpired"
ReasonVPCNotAuthorized = "VPCNotAuthorized"
ReasonAttachmentClaimedByAnotherCaller = "AttachmentClaimedByAnotherCaller"
ReasonNotOwner = "NotOwner"
ReasonCapabilityNotAllowed = "CapabilityNotAllowed"
ReasonUnsupportedVersion = "UnsupportedVersion"
ReasonClaimExists = "ClaimExists"
ReasonClaimNotFound = "ClaimNotFound"
ReasonGenerationConflict = "GenerationConflict"
ReasonNoSession = "NoSession"
ReasonStaleGeneration = "StaleGeneration"
ReasonResyncing = "Resyncing"
ReasonShuttingDown = "ShuttingDown"
ReasonClaimLimit = "ClaimLimit"
ReasonTableRangeExhausted = "TableRangeExhausted"
)

// Status reasons, carried in conditions, destination status and
// capabilities.
const (
ReasonPending = "Pending"
ReasonAsExpected = "AsExpected"
ReasonModeUnavailable = "ModeUnavailable"
ReasonDestinationKindUnsupported = "DestinationKindUnsupported"
ReasonDestinationNotFound = "DestinationNotFound"
ReasonLocatorUnknown = "LocatorUnknown"
ReasonModuleNotRunning = "ModuleNotRunning"
ReasonDatapathNotLoaded = "DatapathNotLoaded"
ReasonHookUnsupported = "HookUnsupported"
ReasonHandoffInterfaceMissing = "HandoffInterfaceMissing"
ReasonProgrammingFailed = "ProgrammingFailed"
ReasonScopeOwnedElsewhere = "ScopeOwnedElsewhere"
ReasonAuthorizationRevoked = "AuthorizationRevoked"
ReasonLeaseExpired = "LeaseExpired"
ReasonReleased = "Released"
)
Loading
Loading