isolated

package
v0.9.0-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CapabilityApplianceV1        Capability = "isolated.appliance.v1"
	CapabilityNetworkV1          Capability = "isolated.network.v1"
	CapabilityRelayV1            Capability = "isolated.relay.v1"
	CapabilityNATV1              Capability = "isolated.nat.v1"
	CapabilityStatsV1            Capability = "isolated.stats.v1"
	CapabilityAuthorityReleaseV1 Capability = "isolated.authority-release.v1"
	CapabilityParentLifecycleV1  Capability = "isolated.parent-lifecycle.v1"

	// Isolated orchestrators have no legacy fallback: authority release and
	// frozen-parent lifecycle are mandatory protocol-v2 operations.
	MinimumProtocolVersion uint32 = 2
	MaximumProtocolVersion uint32 = 2
)
View Source
const (
	BootstrapNetworkNone      = "none"
	BootstrapNetworkPreStaged = "pre_staged"
	BootstrapNetworkNAT       = "nat_enabled"
)
View Source
const (
	MaxPhysicalNameLength    = 63
	MaxWindowsNodeNameLength = 15
)
View Source
const (
	PrivateNetworkPrefixBits = 26
	PrivateSubnetCount       = 1 << (PrivateNetworkPrefixBits - 20)
	FirstGuestAddressOffset  = 10
	LastGuestAddressOffset   = 62
)
View Source
const (
	MaxNetworksPerOrchestrator = 16
	MaxVMsPerOrchestrator      = 100
	MinimumApplianceSchema     = appliance.CurrentSchemaVersion
	MaximumApplianceSchema     = appliance.CurrentSchemaVersion
)
View Source
const PhysicalHostIdentityVersion = "lablink-physical-host/v1"
View Source
const ShortIDLength = 12

Variables

This section is empty.

Functions

func CheckAgentCompatibility

func CheckAgentCompatibility(
	agent AgentCompatibility,
	requirements CompatibilityRequirements,
) error

func CheckOrchestratorCompatibility

func CheckOrchestratorCompatibility(agent AgentCompatibility, serverVersion string) error

func ErrorCode

func ErrorCode(err error) string

func GuestAddress

func GuestAddress(prefix netip.Prefix, offset int) (netip.Addr, error)

func LinuxDNSUpdateScript

func LinuxDNSUpdateScript(mac string, dns []string) (string, error)

func LinuxStaticNetworkBootstrapScript

func LinuxStaticNetworkBootstrapScript(ip string, prefixLength int, gateway, mac string, dns []string) (string, error)

func LinuxStaticNetworkConfig

func LinuxStaticNetworkConfig(ip string, prefixLength int, gateway, mac string, dns []string) (string, error)

func MergeApplianceNAT

func MergeApplianceNAT(
	local *isolatedstate.NATAllocation,
	orchestratorID string,
	live appliance.NATState,
) (isolatedstate.NATAllocation, error)

func MergeApplianceNetworkCache

func MergeApplianceNetworkCache(
	local isolatedstate.PrivateNetwork,
	live appliance.Network,
	reservation appliance.Reservation,
) (isolatedstate.PrivateNetwork, error)

MergeApplianceNetworkCache keeps Hyper-V identity from the host/server record while taking live addressing and generations from the appliance.

func NormalizeHostAlias

func NormalizeHostAlias(value string) (string, error)

func NormalizeHumanPrefix

func NormalizeHumanPrefix(value string) string

func ParseDNSServers

func ParseDNSServers(data string) ([]string, error)

func PhysicalName

func PhysicalName(humanPrefix, immutableID string, maxLength int) (string, error)

func PrivateGateway

func PrivateGateway(prefix netip.Prefix) netip.Addr

func PrivateSubnet

func PrivateSubnet(index int) (netip.Prefix, error)

func SortedAvailableSubnets

func SortedAvailableSubnets(
	snapshot appliance.DesiredSnapshot,
	routes []hyperv.IsolatedRouteObservation,
) []int

func SubnetIndexFromCIDR

func SubnetIndexFromCIDR(cidr string) (int, error)

func ValidateApprovedRevision

func ValidateApprovedRevision(plan RevisionedPlan, revision string) error

func ValidateBootstrapPolicy

func ValidateBootstrapPolicy(requirement string, natEnabled, knownNetworkBootstrap, domainJoin bool, services []ReachableService) error

func ValidateCascadeResume

func ValidateCascadeResume(
	stored DeleteOrchestratorPlan,
	operationID, revision string,
	currentChildren []CascadeChild,
) error

func ValidateGenerationConvergence

func ValidateGenerationConvergence(
	desired, applied, observed isolatedstate.Generation,
) error

func ValidatePhysicalName

func ValidatePhysicalName(value string, maxLength int) error

func ValidateResumeExact

func ValidateResumeExact(stored RevisionedPlan, operationID string, resumeExact bool, inputs map[string]any) error

func WindowsDNSUpdateScript

func WindowsDNSUpdateScript(mac string, dns []string) (string, error)

func WindowsStaticNetworkScript

func WindowsStaticNetworkScript(ip string, prefixLength int, gateway, mac string, dns []string) (string, error)

Types

type AddNetworkPlan

type AddNetworkPlan struct {
	Plan                      RevisionedPlan
	Network                   isolatedstate.PrivateNetwork
	Reservation               appliance.Reservation
	InventoryGeneration       uint64
	ResultingParentGeneration uint64
	Host                      NetworkHostObservation
	Imported                  bool
	CollisionRetries          int
}

type AddNetworkRequest

type AddNetworkRequest struct {
	OperationID              string
	Orchestrator             isolatedstate.Orchestrator
	NetworkID                NetworkID
	DisplayName              string
	ExpectedParentGeneration isolatedstate.Generation
	ExplicitSubnetIndex      *int
	Routes                   []hyperv.IsolatedRouteObservation
	HostFence                int64
	HostLeaseID              string
	HostLeaseSecret          []byte
	HostLeaseExpiresUnix     int64
}

type AgentCompatibility

type AgentCompatibility struct {
	Node            string
	AgentVersion    string
	Capabilities    []string
	ProtocolVersion uint32
}

type ApplianceClient

type ApplianceClient interface {
	GetApplianceState(context.Context, string) (appliance.DesiredSnapshot, error)
	ReserveResources(context.Context, string, appliance.ReserveRequest) (appliance.ReserveResult, error)
}

type ApplianceRPCClient

type ApplianceRPCClient struct {
	// contains filtered or unexported fields
}

ApplianceRPCClient adapts registered isolated-orchestrator nodes to the appliance domain interfaces.

func NewApplianceClient

func NewApplianceClient(
	reg *registry.Registry,
	pool *agentclient.Pool,
	serverVersion string,
) *ApplianceRPCClient

NewApplianceClient creates the production appliance adapter.

func NewApplianceRPCClient

func NewApplianceRPCClient(
	reg applianceNodeRegistry,
	pool applianceClientPool,
	serverVersion string,
) *ApplianceRPCClient

NewApplianceRPCClient creates a fail-closed appliance API adapter.

func (*ApplianceRPCClient) AdoptRelay

func (c *ApplianceRPCClient) AdoptRelay(
	ctx context.Context,
	orchestratorID string,
	input RelayInput,
) (RelayMutationResult, error)

func (*ApplianceRPCClient) ApplyPrivateNetwork

func (c *ApplianceRPCClient) ApplyPrivateNetwork(
	ctx context.Context,
	orchestratorID string,
	input ApplyPrivateNetworkInput,
) (NetworkMutationResult, error)

func (*ApplianceRPCClient) ApplyRelay

func (c *ApplianceRPCClient) ApplyRelay(
	ctx context.Context,
	orchestratorID string,
	input RelayInput,
) (RelayMutationResult, error)

func (*ApplianceRPCClient) CheckReadiness

func (c *ApplianceRPCClient) CheckReadiness(
	ctx context.Context,
	orchestratorID string,
) (ApplianceReadiness, error)

func (*ApplianceRPCClient) GetApplianceState

func (c *ApplianceRPCClient) GetApplianceState(
	ctx context.Context,
	orchestratorID string,
) (appliance.DesiredSnapshot, error)

GetApplianceState implements ApplianceClient.

func (*ApplianceRPCClient) GetRelayStats

func (c *ApplianceRPCClient) GetRelayStats(
	ctx context.Context,
	orchestratorID, relayID string,
) (appliance.RelayStats, error)

func (*ApplianceRPCClient) InspectApplianceState

func (c *ApplianceRPCClient) InspectApplianceState(
	ctx context.Context,
	orchestratorID string,
) (ApplianceSnapshot, error)

func (*ApplianceRPCClient) ListNATState

func (c *ApplianceRPCClient) ListNATState(
	ctx context.Context,
	orchestratorID, networkID, vmID, desiredState string,
	pageSize uint32,
	pageToken string,
) (NATList, error)

func (*ApplianceRPCClient) ListNatState

func (c *ApplianceRPCClient) ListNatState(
	ctx context.Context,
	orchestratorID, networkID, vmID, desiredState string,
	pageSize uint32,
	pageToken string,
) (NATList, error)

ListNatState is the generated-RPC-casing alias for ListNATState.

func (*ApplianceRPCClient) ListRelays

func (c *ApplianceRPCClient) ListRelays(
	ctx context.Context,
	orchestratorID, networkID, vmID string,
	includeRetired bool,
	pageSize uint32,
	pageToken string,
) (RelayList, error)

func (*ApplianceRPCClient) RebindRelays

func (c *ApplianceRPCClient) RebindRelays(
	ctx context.Context,
	orchestratorID string,
	header MutationEnvelope,
) ([]appliance.Relay, MutationResult, error)

func (*ApplianceRPCClient) ReconcileNAT

func (c *ApplianceRPCClient) ReconcileNAT(
	ctx context.Context,
	orchestratorID string,
	header MutationEnvelope,
	networkID string,
) (NATMutationResult, error)

func (*ApplianceRPCClient) ReconcileNat

func (c *ApplianceRPCClient) ReconcileNat(
	ctx context.Context,
	orchestratorID string,
	header MutationEnvelope,
	networkID string,
) (NATMutationResult, error)

ReconcileNat is the generated-RPC-casing alias for ReconcileNAT.

func (*ApplianceRPCClient) RegisterIsolatedGuest

func (c *ApplianceRPCClient) RegisterIsolatedGuest(
	ctx context.Context,
	orchestratorID string,
	input RegisterGuestInput,
) (GuestMutationResult, error)

func (*ApplianceRPCClient) ReleaseAuthority

func (c *ApplianceRPCClient) ReleaseAuthority(
	ctx context.Context,
	orchestratorID string,
	envelope MutationEnvelope,
) error

func (*ApplianceRPCClient) ReleaseResources

func (c *ApplianceRPCClient) ReleaseResources(
	ctx context.Context,
	orchestratorID string,
	request appliance.ReleaseRequest,
) (appliance.ReleaseResult, error)

func (*ApplianceRPCClient) RemoveIsolatedGuest

func (c *ApplianceRPCClient) RemoveIsolatedGuest(
	ctx context.Context,
	orchestratorID string,
	header MutationEnvelope,
	networkID string,
) (GuestMutationResult, error)

func (*ApplianceRPCClient) RemovePrivateNetwork

func (c *ApplianceRPCClient) RemovePrivateNetwork(
	ctx context.Context,
	orchestratorID string,
	header MutationEnvelope,
) (NetworkMutationResult, error)

func (*ApplianceRPCClient) RemoveRelay

func (c *ApplianceRPCClient) RemoveRelay(
	ctx context.Context,
	orchestratorID string,
	header MutationEnvelope,
	vmID, networkID string,
) (RelayMutationResult, error)

func (*ApplianceRPCClient) ReserveResources

func (c *ApplianceRPCClient) ReserveResources(
	ctx context.Context,
	orchestratorID string,
	request appliance.ReserveRequest,
) (appliance.ReserveResult, error)

ReserveResources implements ApplianceClient.

func (*ApplianceRPCClient) SetNATState

func (c *ApplianceRPCClient) SetNATState(
	ctx context.Context,
	orchestratorID string,
	input NATInput,
) (NATMutationResult, error)

func (*ApplianceRPCClient) SetNatState

func (c *ApplianceRPCClient) SetNatState(
	ctx context.Context,
	orchestratorID string,
	input NATInput,
) (NATMutationResult, error)

SetNatState is the generated-RPC-casing alias for SetNATState.

func (*ApplianceRPCClient) SetParentLifecycle

func (c *ApplianceRPCClient) SetParentLifecycle(
	ctx context.Context,
	orchestratorID string,
	envelope MutationEnvelope,
	state string,
	newParentGeneration uint64,
) error

func (*ApplianceRPCClient) ValidateRelay

func (c *ApplianceRPCClient) ValidateRelay(
	ctx context.Context,
	orchestratorID, relayID string,
	probeTarget bool,
) (RelayValidation, error)

type ApplianceReadiness

type ApplianceReadiness struct {
	Node                string
	AgentVersion        string
	Capabilities        []string
	ProtocolVersion     uint32
	Ready               bool
	ApplianceGeneration uint64
	Error               string
}

ApplianceReadiness is the capability and readiness result reported by an orchestrator agent.

type ApplianceSnapshot

type ApplianceSnapshot struct {
	SchemaVersion       uint32
	ProtocolVersion     uint32
	Ready               bool
	ApplianceGeneration uint64
	InventoryGeneration uint64
	Fence               FenceState
	MainIPv4            string
	PolicyVerified      bool
	IPv4Forwarding      bool
	Error               string
	Desired             appliance.DesiredSnapshot
	ApplyIntents        []ApplyIntent
}

ApplianceSnapshot contains the complete paged appliance inventory.

type ApplianceStatusError

type ApplianceStatusError struct {
	Status              *status.Status
	Code                appliance.ErrorCode
	ResourceID          string
	InventoryGeneration uint64
	Generation          GenerationState
	Fence               FenceState
	Collision           *appliance.CollisionError
	// contains filtered or unexported fields
}

ApplianceStatusError preserves the original gRPC status and details while exposing the appliance domain code through errors.As and ErrorCodeOf.

func (*ApplianceStatusError) Error

func (e *ApplianceStatusError) Error() string

func (*ApplianceStatusError) GRPCStatus

func (e *ApplianceStatusError) GRPCStatus() *status.Status

func (*ApplianceStatusError) Unwrap

func (e *ApplianceStatusError) Unwrap() error

type ApplyIntent

type ApplyIntent struct {
	MutationID        string
	ResourceKind      string
	ResourceID        string
	DesiredGeneration uint64
	ParentGeneration  uint64
	Fence             uint64
	SemanticHash      string
	CompiledHash      string
	Phase             string
	Error             string
	CreatedAtUnix     int64
	UpdatedAtUnix     int64
}

ApplyIntent is an incomplete or recoverable appliance mutation.

type ApplyPrivateNetworkInput

type ApplyPrivateNetworkInput struct {
	Header        MutationEnvelope
	ReservationID string
	CIDR          string
	GatewayIPv4   string
	NICMAC        string
	InterfaceName string
	DNSServers    []string
}

type AuthoritativeReservationRequest

type AuthoritativeReservationRequest struct {
	OrchestratorID string
	Explicit       bool
	MaxAttempts    int
	Build          ReservationRequestBuilder
}

type AuthoritativeReservationResult

type AuthoritativeReservationResult struct {
	Result   appliance.ReserveResult
	Attempts int
}

func ReserveAuthoritativeResources

func ReserveAuthoritativeResources(
	ctx context.Context,
	client ApplianceClient,
	request AuthoritativeReservationRequest,
) (AuthoritativeReservationResult, error)

ReserveAuthoritativeResources implements the appliance-authoritative half of the allocation handshake. The caller imports only the returned accepted values into its server cache.

type Capability

type Capability string

func RequiredOrchestratorCapabilities

func RequiredOrchestratorCapabilities() []Capability

type CascadeChild

type CascadeChild struct {
	ResourceType              string
	ResourceID                string
	Action                    cascadeauth.Action
	ExpectedHostIdentity      string
	ExpectedApplianceIdentity string
	ExpectedGeneration        isolatedstate.Generation
	ExpectedIncarnation       isolatedstate.Incarnation
	ExpectedImmutableIdentity string
}

type CompatibilityError

type CompatibilityError struct {
	Code                string
	Node                string
	AgentVersion        string
	ServerVersion       string
	MissingCapabilities []Capability
	ProtocolVersion     uint32
	SupportedProtocol   ProtocolRange
}

func (*CompatibilityError) Error

func (e *CompatibilityError) Error() string

type CompatibilityRequirements

type CompatibilityRequirements struct {
	Capabilities  []Capability
	ProtocolRange ProtocolRange
	ServerVersion string
}

func OrchestratorCompatibilityRequirements

func OrchestratorCompatibilityRequirements(serverVersion string) CompatibilityRequirements

func (CompatibilityRequirements) Validate

func (r CompatibilityRequirements) Validate() error

type CreateGuestRequest

type CreateGuestRequest struct {
	OperationID                 string
	VMID                        VMID
	RelayID                     RelayID
	Network                     isolatedstate.PrivateNetwork
	Orchestrator                isolatedstate.Orchestrator
	DisplayName                 string
	GuestOS                     isolatedstate.GuestOS
	ProfileName                 string
	NATEnabled                  bool
	BootstrapNetworkRequirement string
	KnownNetworkBootstrap       bool
	DomainJoin                  bool
	ReachableServices           []ReachableService
	ExpectedParentGeneration    isolatedstate.Generation
	HostFence                   int64
	HostLeaseID                 string
	HostLeaseSecret             []byte
	HostLeaseExpiresUnix        int64
	StorageRoot                 string
	VMPath                      string
	VHDPath                     string
}

type DeleteOrchestratorPlan

type DeleteOrchestratorPlan struct {
	Plan      RevisionedPlan
	Authority isolatedstate.CascadeAuthority
}

func BuildOrchestratorDeletePlan

func BuildOrchestratorDeletePlan(request DeleteOrchestratorRequest) (DeleteOrchestratorPlan, error)

func RestoreApprovedOrchestratorDeletePlan

func RestoreApprovedOrchestratorDeletePlan(
	plan RevisionedPlan,
	hostFence int64,
) (DeleteOrchestratorPlan, error)

RestoreApprovedOrchestratorDeletePlan reconstructs the immutable cascade authority from the stored approved plan without replanning against the post-freeze parent generation.

type DeleteOrchestratorRequest

type DeleteOrchestratorRequest struct {
	OperationID        string
	Orchestrator       isolatedstate.Orchestrator
	Cascade            bool
	Children           []CascadeChild
	ExpectedGeneration isolatedstate.Generation
}

type DomainError

type DomainError struct {
	Code    string
	Message string
}

func (*DomainError) Error

func (e *DomainError) Error() string

type FenceState

type FenceState struct {
	PhysicalHostID   string
	HostFence        uint64
	HostLeaseID      string
	ParentResourceID string
	ParentGeneration uint64
	Frozen           bool
	Deleting         bool
	Lost             bool
}

FenceState describes the accepted physical-host authority without exposing its lease secret.

type GenerationState

type GenerationState struct {
	Desired  uint64
	Applied  uint64
	Observed uint64
	Parent   uint64
}

GenerationState is the version tuple returned for a durable mutation.

type GuestAllocationClient

type GuestAllocationClient interface {
	GetApplianceState(context.Context, string) (appliance.DesiredSnapshot, error)
	ReserveResources(context.Context, string, appliance.ReserveRequest) (appliance.ReserveResult, error)
}

type GuestDomain

type GuestDomain struct {
	Appliance GuestAllocationClient
}

func (GuestDomain) ReserveAndPlan

func (d GuestDomain) ReserveAndPlan(ctx context.Context, request CreateGuestRequest) (GuestPlan, error)

type GuestMutationResult

type GuestMutationResult struct {
	Guest    appliance.Guest
	Mutation MutationResult
	Pending  bool
}

type GuestPlan

type GuestPlan struct {
	VM                          isolatedstate.IsolatedVM      `json:"vm"`
	Relay                       isolatedstate.RelayAllocation `json:"relay"`
	NAT                         isolatedstate.NATAllocation   `json:"nat"`
	Reservations                []appliance.Reservation       `json:"reservations"`
	ResultingParentGeneration   uint64                        `json:"resulting_parent_generation"`
	BootstrapNetworkRequirement string                        `json:"bootstrap_network_requirement"`
	ReachableServices           []ReachableService            `json:"reachable_services,omitempty"`
}

type GuestRepairDecision

type GuestRepairDecision struct {
	Recreate        bool                      `json:"recreate"`
	NextIncarnation isolatedstate.Incarnation `json:"next_incarnation"`
	Reason          string                    `json:"reason"`
}

func DecideGuestRepair

func DecideGuestRepair(vm isolatedstate.IsolatedVM, observation GuestRepairObservation, repairErr error) GuestRepairDecision

type GuestRepairObservation

type GuestRepairObservation struct {
	HostIdentityValid  bool
	NICValid           bool
	TimeSyncEnabled    bool
	RelayValid         bool
	GuestReachable     bool
	StaticNetworkValid bool
	NATValid           bool
	RegistryValid      bool
}

type HostCreateFenceRequest

type HostCreateFenceRequest struct {
	PhysicalHostID string
	HostNode       string
	OperationID    string
	LockKey        hyperv.IsolatedResourceLockKey
}

type HostFenceLease

type HostFenceLease struct {
	LeaseID       string
	LeaseSecret   string
	ExpiresAtUnix int64
	Fence         int64
	LockKey       hyperv.IsolatedResourceLockKey
}

func (HostFenceLease) Validate

func (l HostFenceLease) Validate(expectedLock hyperv.IsolatedResourceLockKey) error

type HostIdentityChangedError

type HostIdentityChangedError struct {
	Alias    string
	Expected PhysicalHostID
	Observed PhysicalHostID
}

func (*HostIdentityChangedError) Error

func (e *HostIdentityChangedError) Error() string

type HostNetworkClient

type HostNetworkClient interface {
	ObserveNetwork(context.Context, NetworkHostQuery) (NetworkHostObservation, error)
}

type HostPlanningClient

type HostPlanningClient interface {
	AcquireOrchestratorCreateFence(context.Context, HostCreateFenceRequest) (HostFenceLease, error)
	ReleaseOrchestratorCreateFence(context.Context, HostCreateFenceRequest, HostFenceLease) error
	ReconcileStaleOrchestratorMetadata(context.Context, StaleOrchestratorMetadataRequest) error
	PreflightOrchestrator(context.Context, ResourcePreflightInput) (ResourcePreflightResult, error)
}

type HostReference

type HostReference struct {
	Alias      string
	PhysicalID PhysicalHostID
}

func NewHostReference

func NewHostReference(alias string, physicalID PhysicalHostID) (HostReference, error)

func (HostReference) CanonicalKey

func (r HostReference) CanonicalKey() string

func (HostReference) SamePhysicalHost

func (r HostReference) SamePhysicalHost(other HostReference) bool

func (HostReference) Validate

func (r HostReference) Validate() error

func (HostReference) VerifyObserved

func (r HostReference) VerifyObserved(observed PhysicalHostID) error

type LostNetworkCleanupRequest

type LostNetworkCleanupRequest struct {
	OperationID string
	Network     isolatedstate.PrivateNetwork
	Authority   isolatedstate.CascadeAuthority
}

type MutationEnvelope

type MutationEnvelope struct {
	Header               appliance.MutationHeader
	PhysicalHostID       string
	HostLeaseID          string
	HostLeaseSecret      []byte
	HostLeaseExpiresUnix int64
	CascadeOperationID   string
	CascadePlanRevision  string
	CascadePlanHash      string
	CascadeItemID        string
	CascadeResourceKind  string
	CascadeAction        string
	CascadeItems         []appliance.CascadeAuthorityItem
}

MutationEnvelope contains the complete mutation authority sent on the wire.

type MutationResult

type MutationResult struct {
	MutationID          string
	SemanticHash        string
	CompiledHash        string
	Generation          GenerationState
	Replayed            bool
	ApplianceGeneration uint64
	Pending             bool
}

MutationResult is the typed durable result of an appliance mutation.

type NATDNSStatus

type NATDNSStatus struct {
	NetworkCopiedJSON string                            `json:"network_copied_json"`
	GuestCopiedJSON   string                            `json:"guest_copied_json"`
	CopyDrift         bool                              `json:"copy_drift"`
	Pending           *isolatedstate.GuestPendingUpdate `json:"pending_update,omitempty"`
}

type NATInput

type NATInput struct {
	Header        MutationEnvelope
	ReservationID string
	NetworkID     string
	DesiredState  string
	ConntrackMark uint32
}

type NATList

type NATList struct {
	States              []appliance.NATState
	NextPageToken       string
	ApplianceGeneration uint64
}

type NATMutationResult

type NATMutationResult struct {
	NAT      appliance.NATState
	Mutation MutationResult
	Pending  bool
}

type NATValidationMode

type NATValidationMode int
const (
	NATValidateMutation NATValidationMode = iota
	NATValidateImport
)

type NetworkCapacityObservation

type NetworkCapacityObservation struct {
	Limit                  int
	Used                   int
	AvailableNetworkSlots  int
	AvailableSubnetIndexes []int
	RouteConflicts         []RouteConflictObservation
}

type NetworkDomain

type NetworkDomain struct {
	State     NetworkStateClient
	Appliance ApplianceClient
	Host      HostNetworkClient
}

func (NetworkDomain) BuildRemovePlan

func (d NetworkDomain) BuildRemovePlan(
	ctx context.Context,
	request RemoveNetworkRequest,
) (RevisionedPlan, error)

func (NetworkDomain) ReserveAndPlan

func (d NetworkDomain) ReserveAndPlan(
	ctx context.Context,
	request AddNetworkRequest,
) (AddNetworkPlan, error)

type NetworkHostObservation

type NetworkHostObservation struct {
	SwitchExists        bool
	SwitchName          string
	SwitchGUID          string
	SwitchPrivate       bool
	HostNICCount        int
	ConnectedAdapters   int
	SwitchOwned         bool
	OwnedOrchestratorID string
	OwnedNetworkID      string
	AdapterExists       bool
	AdapterName         string
	AdapterID           string
	AdapterMAC          string
	AdapterSwitchGUID   string
	AdapterOwned        bool
}

type NetworkHostQuery

type NetworkHostQuery struct {
	PhysicalHostID      string
	OrchestratorID      string
	OrchestratorVMGUID  string
	NetworkID           string
	SwitchName          string
	OrchestratorAdapter string
}

type NetworkID

type NetworkID string

func NewNetworkID

func NewNetworkID() (NetworkID, error)

func ParseNetworkID

func ParseNetworkID(value string) (NetworkID, error)

func (NetworkID) Short

func (id NetworkID) Short() string

func (NetworkID) String

func (id NetworkID) String() string

func (NetworkID) Validate

func (id NetworkID) Validate() error

type NetworkMutationResult

type NetworkMutationResult struct {
	Network  appliance.Network
	Mutation MutationResult
	Pending  bool
}

type NetworkPhysicalNames

type NetworkPhysicalNames struct {
	HyperVSwitchName        string
	OrchestratorAdapterName string
}

func NetworkNames

func NetworkNames(id NetworkID) (NetworkPhysicalNames, error)

type NetworkReservationImport

type NetworkReservationImport struct {
	NetworkID             string
	OrchestratorID        string
	ReservationID         string
	SubnetIndex           int
	CIDR                  string
	GatewayIPv4           string
	OrchestratorMAC       string
	DesiredGeneration     isolatedstate.Generation
	AppliedGeneration     isolatedstate.Generation
	ObservedGeneration    isolatedstate.Generation
	HyperVSwitchGUID      string
	OrchestratorAdapterID string
}

type NetworkStateClient

type NetworkStateClient interface {
	ListNetworks(context.Context, string) ([]isolatedstate.PrivateNetwork, error)
	CountActiveVMs(context.Context, string) (int, error)
	ImportNetworkReservation(context.Context, NetworkReservationImport) error
}

type OperationCapacity

type OperationCapacity struct {
	FreeSubnets               int
	PrivateAdapterSlots       int
	SwitchSlots               int
	HostResourcesAvailable    bool
	FreeGuestIPs              int
	FreeMACs                  int
	FreeRelayPorts            int
	FreeConntrackMarks        int
	GuestSlots                int
	NATSupported              bool
	ReservedConntrackMark     bool
	ExistingOrchestratorCount int
}

func (OperationCapacity) Supports

func (c OperationCapacity) Supports(operation OrchestratorOperation) error

type OperationID

type OperationID string

func NewOperationID

func NewOperationID() (OperationID, error)

func ParseOperationID

func ParseOperationID(value string) (OperationID, error)

func (OperationID) Short

func (id OperationID) Short() string

func (OperationID) String

func (id OperationID) String() string

func (OperationID) Validate

func (id OperationID) Validate() error

type OrchestratorCreatePlan

type OrchestratorCreatePlan struct {
	Plan      RevisionedPlan
	Names     OrchestratorPhysicalNames
	Lease     HostFenceLease
	Preflight ResourcePreflightResult
	Reused    *SelectionResult
}

type OrchestratorCreateRequest

type OrchestratorCreateRequest struct {
	OperationID              string
	PhysicalHostID           string
	HostNode                 string
	DisplayName              string
	ProfileName              string
	MainVSwitch              string
	OrchestratorID           OrchestratorID
	ProjectedStorageBytes    int64
	ExistingReservedMemoryMB int
	ServerVersion            string
	PostFenceTimeout         time.Duration
	Progress                 func(string, string)
}

type OrchestratorDomain

type OrchestratorDomain struct {
	State     OrchestratorStateClient
	Probe     OrchestratorProbeClient
	Host      HostPlanningClient
	Appliance ApplianceClient
}

func (OrchestratorDomain) ImportServerCache

func (d OrchestratorDomain) ImportServerCache(ctx context.Context, orchestratorID string) (ServerCacheImport, error)

func (OrchestratorDomain) PlanCreateOrReuse

func (OrchestratorDomain) Select

type OrchestratorID

type OrchestratorID string

func NewOrchestratorID

func NewOrchestratorID() (OrchestratorID, error)

func ParseOrchestratorID

func ParseOrchestratorID(value string) (OrchestratorID, error)

func (OrchestratorID) Short

func (id OrchestratorID) Short() string

func (OrchestratorID) String

func (id OrchestratorID) String() string

func (OrchestratorID) Validate

func (id OrchestratorID) Validate() error

type OrchestratorObservation

type OrchestratorObservation struct {
	Record                  isolatedstate.Orchestrator
	HostReachable           bool
	VMState                 string
	MainNICHealthy          bool
	AgentAuthenticated      bool
	Agent                   AgentCompatibility
	ApplianceReady          bool
	AppliancePolicyVerified bool
	ApplianceSchema         int
	ApplyIntentError        string
	RouteConflict           bool
	ImmutableIdentityMatch  bool
	Capacity                OperationCapacity
}

type OrchestratorOperation

type OrchestratorOperation string
const (
	OperationAddNetwork OrchestratorOperation = "add_network"
	OperationAddGuest   OrchestratorOperation = "add_guest"
	OperationEnableNAT  OrchestratorOperation = "enable_nat"
	OperationReconcile  OrchestratorOperation = "reconcile"
)

type OrchestratorPhysicalNames

type OrchestratorPhysicalNames struct {
	HyperVName string
	NodeName   string
}

type OrchestratorProbeClient

type OrchestratorProbeClient interface {
	ObserveOrchestrator(context.Context, isolatedstate.Orchestrator) (OrchestratorObservation, error)
	RecoverOrchestrator(context.Context, isolatedstate.Orchestrator) (RecoveryResult, error)
}

type OrchestratorStateClient

type OrchestratorStateClient interface {
	ListOrchestrators(context.Context, string) ([]isolatedstate.Orchestrator, error)
	GetOrchestrator(context.Context, string) (isolatedstate.Orchestrator, error)
	ImportApplianceCache(context.Context, ServerCacheImport) error
}

type PhysicalHostID

type PhysicalHostID string

func ParsePhysicalHostID

func ParsePhysicalHostID(value string) (PhysicalHostID, error)

func (PhysicalHostID) String

func (id PhysicalHostID) String() string

func (PhysicalHostID) Validate

func (id PhysicalHostID) Validate() error

type PhysicalHostIdentity

type PhysicalHostIdentity struct {
	MachineGUID string
	SMBIOSUUID  string
	ID          PhysicalHostID
}

func DerivePhysicalHostIdentity

func DerivePhysicalHostIdentity(machineGUID, smbiosUUID string) (PhysicalHostIdentity, error)

type PlanAction

type PlanAction struct {
	Phase              string `json:"phase"`
	Action             string `json:"action"`
	ResourceType       string `json:"resource_type"`
	ResourceID         string `json:"resource_id"`
	ExpectedIdentity   string `json:"expected_identity,omitempty"`
	ExpectedGeneration int64  `json:"expected_generation"`
	NewGeneration      int64  `json:"new_generation"`
}

type ProtocolRange

type ProtocolRange struct {
	Minimum uint32
	Maximum uint32
}

func (ProtocolRange) Contains

func (r ProtocolRange) Contains(version uint32) bool

func (ProtocolRange) Validate

func (r ProtocolRange) Validate() error

type ReachableService

type ReachableService struct {
	Kind    string `json:"kind"`
	Address string `json:"address"`
	Port    int    `json:"port,omitempty"`
}

type ReconcileNetworkRequest

type ReconcileNetworkRequest struct {
	OperationID        string
	Network            isolatedstate.PrivateNetwork
	RefreshDNS         bool
	ExpectedGeneration isolatedstate.Generation
	Host               NetworkHostObservation
}

type ReconcileOrchestratorRequest

type ReconcileOrchestratorRequest struct {
	OperationID        string
	Orchestrator       isolatedstate.Orchestrator
	RefreshDNS         bool
	RepairRegistry     bool
	ExpectedGeneration isolatedstate.Generation
}

type RecoveryResult

type RecoveryResult struct {
	Observation OrchestratorObservation
	Steps       []RecoveryStep
}

type RecoveryStep

type RecoveryStep struct {
	Action string
	Detail string
}

type RegisterGuestInput

type RegisterGuestInput struct {
	Header        MutationEnvelope
	ReservationID string
	NetworkID     string
	IPv4          string
	MAC           string
}

type RelayID

type RelayID string

func NewRelayID

func NewRelayID() (RelayID, error)

func ParseRelayID

func ParseRelayID(value string) (RelayID, error)

func (RelayID) Short

func (id RelayID) Short() string

func (RelayID) String

func (id RelayID) String() string

func (RelayID) Validate

func (id RelayID) Validate() error

type RelayInput

type RelayInput struct {
	Header        MutationEnvelope
	ReservationID string
	VMID          string
	NetworkID     string
	ListenPort    uint32
	TargetIPv4    string
}

type RelayList

type RelayList struct {
	Relays              []appliance.Relay
	NextPageToken       string
	ApplianceGeneration uint64
}

type RelayMutationResult

type RelayMutationResult struct {
	Relay    appliance.Relay
	Mutation MutationResult
	Pending  bool
}

type RelayValidation

type RelayValidation struct {
	Relay               appliance.Relay
	ListenerValid       bool
	MappingValid        bool
	GenerationValid     bool
	TargetReachable     bool
	Message             string
	ApplianceGeneration uint64
}

type RemoveNetworkRequest

type RemoveNetworkRequest struct {
	OperationID        string
	Network            isolatedstate.PrivateNetwork
	ExpectedGeneration isolatedstate.Generation
	Host               NetworkHostObservation
}

type ReservationRequestBuilder

type ReservationRequestBuilder func(
	appliance.DesiredSnapshot,
	int,
) (appliance.ReserveRequest, error)

type ResourcePreflightInput

type ResourcePreflightInput struct {
	PhysicalHostID              string
	HostNode                    string
	MainVSwitch                 string
	ProfileName                 string
	ProjectedMemoryMB           int
	ProjectedStorageBytes       int64
	ExistingOrchestratorCount   int
	AggregateReservedMemoryMB   int
	RequiredPrivateAdapterSlots int
	RequiredSwitchSlots         int
	RequiredFreeSubnets         int
	RequiredRelayPorts          int
	RequiredGuestSlots          int
}

type ResourcePreflightResult

type ResourcePreflightResult struct {
	Allowed                       bool
	Reason                        string
	AvailableMemoryMB             int
	AvailableStorageBytes         int64
	HostReportedSyntheticAdapters int
	EffectivePrivateAdapterSlots  int
	AvailableSwitchSlots          int
}

type RevisionedPlan

type RevisionedPlan struct {
	Kind         string         `json:"kind"`
	OperationID  string         `json:"operation_id"`
	ResourceID   string         `json:"resource_id"`
	SemanticHash string         `json:"semantic_hash"`
	PlanHash     string         `json:"plan_hash"`
	Revision     string         `json:"revision"`
	Actions      []PlanAction   `json:"actions"`
	Inputs       map[string]any `json:"inputs"`
}

func BuildLostNetworkCleanupPlan

func BuildLostNetworkCleanupPlan(request LostNetworkCleanupRequest) (RevisionedPlan, error)

func BuildNetworkReconcilePlan

func BuildNetworkReconcilePlan(request ReconcileNetworkRequest) (RevisionedPlan, error)

func BuildOrchestratorReconcilePlan

func BuildOrchestratorReconcilePlan(request ReconcileOrchestratorRequest) (RevisionedPlan, error)

type RouteConflictObservation

type RouteConflictObservation struct {
	Candidate netip.Prefix
	Route     hyperv.IsolatedRouteObservation
}

func FindPrivateRouteConflicts

func FindPrivateRouteConflicts(
	candidate netip.Prefix,
	routes []hyperv.IsolatedRouteObservation,
) []RouteConflictObservation

type SelectionRequest

type SelectionRequest struct {
	PhysicalHostID       string
	ExplicitOrchestrator string
	Operation            OrchestratorOperation
	ServerVersion        string
}

type SelectionResult

type SelectionResult struct {
	Orchestrator isolatedstate.Orchestrator
	Observation  OrchestratorObservation
	Recovery     []RecoveryStep
	Skipped      []SelectionSkip
}

type SelectionSkip

type SelectionSkip struct {
	OrchestratorID string
	Code           string
	Reason         string
	Recovery       []RecoveryStep
}

type ServerCacheImport

type ServerCacheImport struct {
	OrchestratorID      string
	ApplianceSchema     int
	InventoryGeneration uint64
	ParentGeneration    uint64
	Networks            []appliance.Network
	Guests              []appliance.Guest
	Relays              []appliance.Relay
	NAT                 []appliance.NATState
	Reservations        []appliance.Reservation
}

type StaleOrchestratorMetadataRequest

type StaleOrchestratorMetadataRequest struct {
	PhysicalHostID   string
	HostNode         string
	OperationID      string
	OrchestratorID   string
	HyperVName       string
	OrchestratorVMID string
	LifecycleState   string
	Lease            HostFenceLease
}

type VMID

type VMID string

func NewVMID

func NewVMID() (VMID, error)

func ParseVMID

func ParseVMID(value string) (VMID, error)

func (VMID) Short

func (id VMID) Short() string

func (VMID) String

func (id VMID) String() string

func (VMID) Validate

func (id VMID) Validate() error

type VMPhysicalNames

type VMPhysicalNames struct {
	HyperVName         string
	NodeName           string
	PrivateAdapterName string
}

func VMNames

func VMNames(id VMID) (VMPhysicalNames, error)

type ValidatedNAT

type ValidatedNAT struct {
	Reservation appliance.Reservation
	Guest       appliance.Guest
	Live        appliance.NATState
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL