Skip to content
Open
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
31 changes: 31 additions & 0 deletions config/base/crd/metal.datumapis.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,37 @@ spec:
properties:
name: {type: string, minLength: 1}
step: {type: integer, format: int32, minimum: 1}
network:
type: object
properties:
interfaces:
type: array
maxItems: 16
x-kubernetes-list-type: map
x-kubernetes-list-map-keys: [name]
items:
type: object
required: [name, network, attachment, claim]
properties:
name: {type: string, minLength: 1, maxLength: 63}
network:
type: object
required: [namespace, name]
properties: {namespace: {type: string, minLength: 1}, name: {type: string, minLength: 1}}
attachment:
type: object
required: [macAddress, switch, port]
properties:
macAddress: {type: string, pattern: '^([0-9a-f]{2}:){5}[0-9a-f]{2}$'}
switch: {type: string, minLength: 1, maxLength: 253}
port: {type: string, minLength: 1, maxLength: 63}
claim:
type: object
required: [namespace, name]
properties:
namespace: {type: string, minLength: 1}
name: {type: string, minLength: 1, maxLength: 253}
uid: {type: string}
conditions:
type: array
items: {type: object, x-kubernetes-preserve-unknown-fields: true}
Expand Down
9 changes: 6 additions & 3 deletions docs/development/device-custody.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ update). A retry finds the same allocation by its name.
A bootstrap reference is refused.
- **Release.** The allocation's holder moves to `Release` with all six gates
open. Then:
- Access, Network and Address close at once.
- Access closes at once.
- Network and Address close when every interface claim the allocation
recorded is gone. See [Network attachment](../operations/network-attachment.md).
- Operations closes when no installation of the allocation is active or
unended.
- Cleaning creates a `DeviceWipe`, step 1. A wipe that ended `Failed` sent
Expand Down Expand Up @@ -762,8 +764,9 @@ person.
deleted and the allocator selects again, because it exposed nothing. An `Active`
allocation that lost custody means the records disagree about who holds a
server a customer may be using. Fleet leaves it to an operator.
- **Release gates.** Access, Network and Address close at once, because no mode
provisions them. There is nothing to wait for.
- **Release gates.** Access closes at once, because no mode provisions it.
Network and Address close on the absence of every interface claim, because
the network owner keeps a claim until it detached the port.
- **Wipe retries.** A wipe that ended `Failed` sent nothing, so a new step is safe.
A wipe that ended `OutcomeUnknown` may have written to disks, so only a
`DeviceRecovery` `Retry` allows another.
Expand Down
1 change: 1 addition & 0 deletions docs/operations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ integrations. Real provider support and live Milo acceptance tests are incomplet
| Exercise Milo, Karmada and cell-local PXE end to end with one command | [Multi-plane acceptance](multiplane.md) (`task multiplane:acceptance`) | Native project routing, the custody coordinator, federation delivery/reflection, partition, [Kubernetes site execution](site-execution.md) (Flux-owned shared services, kro-created per-operation Jobs) with worker Pod/Job interruption, delivery and reflection faults, wrong location, release with a wipe and reuse; the run on the custody path passes every phase; every service [installed by per-cluster Flux](gitops.md) from a source built from the checkout; production authority unqualified |
| Drive the same pipeline through Redfish instead of libvirt | [Redfish-mode acceptance](redfish-lab.md) (`task multiplane:redfish-acceptance`) | Redfish site workers: per-Device credentials over a pinned TLS key, one-time PXE/disk boot overrides, power, lost-response recovery and a booted wipe, against the unmodified DMTF Redfish Interface Emulator with a lab-only libvirt adapter and two persistent lab VMs; synthetic credentials and networking; the run on custody passes every phase; not physical BMC or hardware qualification |
| Publish DHCP reservations for network boot | [Boot network](boot-network.md) | Boot addresses claimed from IPAM per installation and wipe, boot NICs from Device inventory, a reservation feed read from the site store that exists only while a boot is admitted, served and withdrawn evidence from the Kea synchronizer; tested against a real API server and unit tested, not exercised at a site |
| Attach a Machine's interfaces to customer networks | [Network attachment](network-attachment.md) | NSO interface claims per Machine interface with attachment points from inventory, Machine network status, and release gated on claim absence; tested against a real API server with a stand-in realizer; NSO has no physical attachment mode, so it is refused everywhere |
| Plan a rack slot and register the server bound to it | [Planning and registering physical devices](physical-inventory.md) | Operator-written `DeviceClaim` and `Device` records in the provider project in Milo, with immutable identity and binding, shown read-only in the staff portal; no capacity or hardware effect; unit tested |
| Record what each Device's BMC reports | [BMC discovery](bmc-discovery.md) | Read-only Redfish discovery into Device status, with TLS public-key pinning approved per BMC and identity compared with spec; unit and TLS end-to-end tested, not qualified on vendor hardware |
| Render deployment bundles and supply environment inputs | [Deployment manifests](../../config/README.md) | Packaging and security boundaries, not runtime readiness |
Expand Down
107 changes: 107 additions & 0 deletions docs/operations/network-attachment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Network attachment: Machine interfaces on customer networks

A Machine names its interfaces in `spec.networkInterfaces`, each a
MachineProfile slot on a customer Network. Fleet asks NSO for one interface per
entry and names where the server's NIC meets the network. The network owner
connects the switch port. Fleet reports the result on the Machine and never
configures a switch.

This page describes the implemented contract. The design is the [server
networking enhancement][server-networking]. What is still proposed is listed
under [Implemented versus proposed](#implemented-versus-proposed).

## Before allocation

The Metal provider checks each interface before it reserves capacity:

- the name is unique;
- the Network is in the Machine's namespace, exists, is `Ready` at its
generation, and carries each requested address family; and
- the principal the Machine was admitted for may use the Network.

A failed check leaves the Machine `Pending`, with `Bound` and `Ready` false for
one of these reasons:

| Reason | Meaning |
| --- | --- |
| `NetworkAttachmentUnsupported` | No network owner is configured, or NSO has no physical attachment mode |
| `NetworkUseNotAuthorized` | The principal may not use a Network, or no network-use check is configured |
| `NetworkNotReady` | A Network is missing, not ready, or does not carry a requested family |

## Attachment

After allocation, the Metal provider records each interface on the
MachineAllocation's `status.network` before it creates anything:

- the interface name, which is the profile slot and the Device inventory
interface;
- the Network;
- the attachment point: the interface's MAC from Device inventory, and the
switch and port at the other end of the one cable record that names the
interface as the Device's component; and
- the claim's namespace and name, `fleet-` and 40 hex characters of the
SHA-256 of `<allocation>/<interface>`.

It then creates a `NetworkInterfaceClaim` in the Network's namespace, labeled
`fleet.datumapis.com/allocation` and `fleet.datumapis.com/machine-uid`, with
the configured physical attachment mode, and records the claim's UID. A crash
between the create and the UID write is recovered by name. Fleet adopts a claim
only if its labels and spec match exactly, never recreates a claim whose UID it
recorded, and records every proven UID even when a later interface fails.

The Network's namespace is the consumer's, so a consumer who learns the
allocation name could create a matching claim first, and Fleet would adopt it.
That claim asks for nothing Fleet would not, and the realizer checks the
attachment point against the allocation's record. Claims move to a namespace
the consumer cannot write once NSO defines one.

A claim's status wakes its Machine through the `machine-uid` label. The Machine
reports, per interface, the Network, the MAC, the MTU of the bound
`NetworkInterface`, its addresses, and the claim's `Allocated`, `Prepared` and
`Programmed` conditions. `NetworkReady` is `True` only when every interface
reports all three at the claim's generation. Until then the Machine is
`Pending` with reason `NetworkPending`. A recorded claim that changed or
disappeared reports `NetworkConfigurationChanged`, and an interface with no
single cable record reports `AttachmentPointUnknown`. When NSO cannot be read,
`NetworkReady` is `Unknown`, `Ready` is false, and the last network status
stays.

## Release

Release deletes every recorded claim with its UID as a precondition. The
`Network` and `Address` gates close only when every claim is gone, because NSO
keeps a claim until the realizer detached the port. A claim under the same name
with another UID is not Fleet's, so Fleet's own counts as gone and the other is
left alone.

An interface that asked to retain its addresses keeps them in the consumer's
project after release, as NSO's `Retain` policy defines. Fleet's obligation
ends when its claim is gone. If the NSO API stops serving claims after Fleet
recorded some, release waits with both gates open until an operator restores
it.

## Configuration

The allocator's network owner is an NSO adapter with:

- a client for the NSO API that holds the consumer's Networks and the claims;
- the physical attachment mode; and
- a network-use authorizer that checks the admitted principal.

Without all three, every Machine that requests interfaces is refused. The
synthetic staging provider uses the allocator's network owner when one is set;
no mode in this repository sets one.

## Implemented versus proposed

| Behavior | Status |
| --- | --- |
| Checks before allocation, attachment points from inventory, claims named and recorded on the allocation, Machine network status, release gated on claim absence | Implemented; tested against a real API server with NSO's CRDs, a stand-in `Physical` mode and a test realizer |
| NSO `Physical` attachment mode and attachment point fields | Proposed to NSO; the pinned NSO refuses `Physical`, and a test records that |
| Where a provider that is not compute creates claims, in a namespace the consumer cannot write | Proposed to NSO; Fleet creates claims in the Network's namespace |
| Network-use authorization of the admitted principal through Milo | Not implemented; no authorizer is configured, so interfaces are refused |
| The physical realizer that programs switch ports | Proposed to Networking |
| Host network configuration in installation inputs | Proposed |
| Fleet's IAM grants on interface claims in consumer projects | Not implemented |

[server-networking]: https://github.com/datum-cloud/fleet/pull/186
3 changes: 3 additions & 0 deletions internal/allocation/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ type Allocator struct {
// replaced by the requester's own. Nil means the site's DHCP is
// configured independently of Fleet.
BootAddresses *bootaddress.Claimer
// Network attaches Machine interfaces through the network owner. Nil
// refuses every Machine that requests interfaces.
Network Networks
}

// Get returns the Machine's allocation, or nil.
Expand Down
13 changes: 11 additions & 2 deletions internal/allocation/harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import (

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"

networkingv1 "go.datum.net/network-services-operator/api/v1alpha"

inventory "go.datum.net/fleet/internal/api/inventory/v1alpha1"
ops "go.datum.net/fleet/internal/api/operations/v1alpha1"
fleetv1 "go.datum.net/fleet/internal/api/v1alpha1"
Expand Down Expand Up @@ -64,7 +67,7 @@ type env struct {

func scheme(t *testing.T) *runtime.Scheme {
s := runtime.NewScheme()
for _, add := range []func(*runtime.Scheme) error{corev1.AddToScheme, inventory.AddToScheme, fleetv1.AddToScheme, ops.AddToScheme} {
for _, add := range []func(*runtime.Scheme) error{corev1.AddToScheme, inventory.AddToScheme, fleetv1.AddToScheme, ops.AddToScheme, networkingv1.AddToScheme} {
if err := add(s); err != nil {
t.Fatal(err)
}
Expand All @@ -73,6 +76,12 @@ func scheme(t *testing.T) *runtime.Scheme {
}

func startEnv(t *testing.T) *env {
t.Helper()
return startEnvWith(t)
}

// startEnvWith starts the environment with extra CRDs, such as NSO's.
func startEnvWith(t *testing.T, crds ...*apiextensionsv1.CustomResourceDefinition) *env {
t.Helper()
if os.Getenv("KUBEBUILDER_ASSETS") == "" {
t.Skip("KUBEBUILDER_ASSETS required")
Expand All @@ -84,7 +93,7 @@ func startEnv(t *testing.T) *env {
filepath.Join(root, "config", "components", "inventory", "crds"),
filepath.Join(root, "config", "components", "device-operations", "crds"),
filepath.Join(root, "internal", "bootaddress", "testdata"),
}, ErrorIfCRDPathMissing: true}
}, CRDs: crds, ErrorIfCRDPathMissing: true}
config, err := environment.Start()
if err != nil {
t.Fatal(err)
Expand Down
Loading
Loading