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
11 changes: 3 additions & 8 deletions cmd/fleet-manager/synthetic.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ import (
// syntheticSite is the synthetic provider: the simulator site.
const syntheticSite = "synthetic-provider"

// syntheticCleaningPolicy is the fixture cleaning policy record every
// synthetic capacity names. Its digest is what each allocation pins.
const syntheticCleaningPolicy = `{"method":"overwrite","disks":"all"}`

// syntheticCustody builds the allocator, the custody coordinator loop and
// fixture discovery for synthetic staging. The manager's own identity is the
// Metal provider; the coordinator and the release controller authenticate
Expand Down Expand Up @@ -96,17 +92,16 @@ func syntheticCustody(ctx context.Context, scheme *runtime.Scheme, providerConfi
}
coordinator := &custody.Coordinator{Client: coordinatorClient, Registry: registry, Sites: sites, Config: custody.Config{Namespace: namespace, Principals: principals}}
log := ctrl.Log.WithName("custody")
cleaning := func(context.Context, string) (string, error) { return custody.SpecDigest(syntheticCleaningPolicy) }
projector := &capacity.Projector{Reader: projectorClient, Writer: projectorClient, Namespace: namespace, Cleaning: cleaning}

projector := &capacity.Projector{Reader: projectorClient, Writer: projectorClient, Namespace: namespace, Cleaning: capacity.Policies(projectorClient, namespace)}
loop := &delivery.Loop{Client: coordinatorClient, Coordinator: coordinator, Namespace: namespace, Capacity: projector,
Courier: &delivery.Courier{Client: coordinatorClient, Registry: registry, Coordinator: coordinator, Sites: sites, Namespace: namespace},
OnError: func(err error) { log.Info("coordinator pass incomplete", "error", err.Error()) }}
allocator := &allocation.Allocator{
Provider: provider, ProviderCreator: providerCreator,
Releaser: releaseClient, ReleaseCreator: releaseCreator,
Custody: coordinator, Namespace: namespace,
Cleaning: func(string) (string, error) { return custody.SpecDigest(syntheticCleaningPolicy) },
Capacity: &capacity.Projector{Reader: provider, Namespace: namespace, Cleaning: cleaning},
Capacity: &capacity.Projector{Reader: provider, Namespace: namespace, Cleaning: capacity.Policies(provider, namespace)},
// The synthetic site enrolls one boot NIC and one disk per Device.
BootInterface: "primary", TargetDisks: []string{"disk-0"},
Sites: sites,
Expand Down
7 changes: 2 additions & 5 deletions cmd/fleet-registration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

"go.datum.net/fleet/internal/capacity"
ops "go.datum.net/fleet/internal/api/operations/v1alpha1"
"go.datum.net/fleet/internal/custody/creatorwebhook"
"go.datum.net/fleet/internal/powerwebhook"
)
Expand Down Expand Up @@ -57,7 +57,7 @@ func run(ctx context.Context, configFile, providers, powerWriter, cert, key, cli
return err
}
scheme := runtime.NewScheme()
for _, add := range []func(*runtime.Scheme) error{clientgoscheme.AddToScheme, inventory.AddToScheme, metal.AddToScheme, resourcemanager.AddToScheme} {
for _, add := range []func(*runtime.Scheme) error{clientgoscheme.AddToScheme, inventory.AddToScheme, ops.AddToScheme, metal.AddToScheme, resourcemanager.AddToScheme} {
if err := add(scheme); err != nil {
return err
}
Expand All @@ -79,9 +79,6 @@ func run(ctx context.Context, configFile, providers, powerWriter, cert, key, cli
}
handler := registration.NewHandler(config.AuthorityID, projects, root, template, scheme)
handler.Projectors = projectors
// No cleaning policy resolver exists yet: the cleaning policy owner
// provides it. Until then no registered capacity can be enabled.
handler.Cleaning = capacity.Unresolved
tlsConfig, err := webhookTLS(clientCA, clients)
if err != nil {
return err
Expand Down
24 changes: 2 additions & 22 deletions cmd/fleet-standalone-smoke/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ import (
const (
providerPrincipal = "system:serviceaccount:fleet-system:fleet-standalone-smoke"
releasePrincipal = "system:serviceaccount:fleet-system:fleet-release-controller"
// cleaningPolicy is the fixture's cleaning policy record. Its digest is
// what each allocation pins.
cleaningPolicy = `{"name":"synthetic-tenant-reuse-v1","method":"overwrite","disks":"all"}`
)

func main() {
Expand Down Expand Up @@ -81,13 +78,12 @@ func main() {
must(err)
releaseCreator, err := allocation.Creator(ctx, releaseConfig)
must(err)
offers := &capacity.Projector{Reader: provider, Namespace: options.ProviderNamespace, Cleaning: fixtureResolver}
offers := &capacity.Projector{Reader: provider, Namespace: options.ProviderNamespace, Cleaning: capacity.Policies(provider, options.ProviderNamespace)}
allocator := &allocation.Allocator{
Provider: provider, ProviderCreator: providerCreator,
Releaser: releaseClient, ReleaseCreator: releaseCreator,
Custody: &custody.Coordinator{Client: coordinatorClient, Registry: registry, Config: custody.Config{Namespace: options.ProviderNamespace, Principals: principals()}},
Namespace: options.ProviderNamespace,
Cleaning: fixtureCleaning,
Capacity: offers,
// The fixture Device's boot NIC and the simulator's one enrolled disk.
BootInterface: "primary", TargetDisks: []string{"disk-0"},
Expand Down Expand Up @@ -144,7 +140,7 @@ func coordinate(ctx context.Context, config *rest.Config, registry *custody.Regi
}
coordinator := &custody.Coordinator{Client: api, Registry: registry, Sites: sites, Config: custody.Config{Namespace: namespace, Principals: principals()}}
logger := slog.New(slog.NewJSONHandler(os.Stderr, nil))
projector := &capacity.Projector{Reader: projectorClient, Writer: projectorClient, Namespace: namespace, Cleaning: fixtureResolver}
projector := &capacity.Projector{Reader: projectorClient, Writer: projectorClient, Namespace: namespace, Cleaning: capacity.Policies(projectorClient, namespace)}
loop := &delivery.Loop{Client: api, Coordinator: coordinator, Namespace: namespace, Capacity: projector, Courier: &delivery.Courier{Client: api, Registry: registry, Coordinator: coordinator, Sites: sites, Namespace: namespace},
OnError: func(err error) { logger.Info("coordinator pass incomplete", "error", err.Error()) }}
logger.Info("custody coordinator running", "namespace", namespace, "site", siteName)
Expand Down Expand Up @@ -177,26 +173,10 @@ func staff(ctx context.Context, config *rest.Config, author, approver, operator
return out, nil
}

// fixtureResolver is the projector's view of the fixture cleaning policy.
func fixtureResolver(_ context.Context, name string) (string, error) {
digest, err := fixtureCleaning(name)
if err != nil {
return "", capacity.ErrUnresolved
}
return digest, nil
}

func principals() custody.Principals {
return custody.Principals{custody.CreatorMetalProvider: {{Username: providerPrincipal}}, custody.CreatorReleaseController: {{Username: releasePrincipal}}}
}

func fixtureCleaning(name string) (string, error) {
if name != "synthetic-tenant-reuse-v1" {
return "", fmt.Errorf("no fixture cleaning policy %q", name)
}
return custody.SpecDigest(cleaningPolicy)
}

func newClient(config *rest.Config) (client.Client, error) {
scheme := runtime.NewScheme()
for _, add := range []func(*runtime.Scheme) error{clientgoscheme.AddToScheme, fleetv1.AddToScheme, inventory.AddToScheme, ops.AddToScheme} {
Expand Down
19 changes: 10 additions & 9 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ legacy management-cluster install and will be removed. See
[Planning and registering physical devices](../docs/operations/physical-inventory.md).

`config/components/device-operations` registers `DeviceCustody`, the Device
operation kinds, their ProtectedResources, the coordinator, requester, viewer,
recovery operator and power operator roles, and the creator webhook.
`config/milo` includes all of it, and the `fleet-registration` server serves
the webhook at `/validate-operation-creator`. `config/milo-synthetic` includes
the kinds, ProtectedResources and roles without the webhook, because it
installs no registration webhook. `config/standalone` includes only the CRDs
and enforces the creator rule with a ValidatingAdmissionPolicy. Including the
kinds installs no coordinator: the production manager has no provider, so
nothing creates custody operations there. See [device custody](../docs/development/device-custody.md#cutover-increment-c).
operation kinds, `CleaningPolicy`, their ProtectedResources, the coordinator,
requester, viewer, recovery operator, power operator and cleaning policy admin roles, and the
creator and cleaning policy webhooks. `config/milo` includes all of it, and the
`fleet-registration` server serves the webhooks at
`/validate-operation-creator` and `/validate-cleaning-policy`. `config/milo-synthetic` includes the kinds,
ProtectedResources and roles without the webhook, because it installs no
registration webhook. `config/standalone` includes only the CRDs and enforces the
creator rule with a ValidatingAdmissionPolicy. Including the kinds installs no
coordinator: the production manager has no provider, so nothing creates
custody operations there. See [device custody](../docs/development/device-custody.md#cutover-increment-c).

`config/base/bmc-discovery` runs read-only BMC discovery for one Milo project
in a cluster that can reach the BMC network: one replica, no leader election,
Expand Down
66 changes: 64 additions & 2 deletions config/base/crd/metal.datumapis.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ spec:
metadata: {type: object}
spec:
type: object
required: [consumerRef, machineRef, machineCapacityRef, deviceRef, accepted, hardware, authority, cleaningPolicyDigest, bootInterface, targetDisks]
required: [consumerRef, machineRef, machineCapacityRef, deviceRef, accepted, hardware, authority, cleaningPolicy, bootInterface, targetDisks]
x-kubernetes-validations:
- {rule: 'self == oldSelf', message: MachineAllocation identity and endpoints are immutable}
properties:
Expand Down Expand Up @@ -449,7 +449,69 @@ spec:
required: [name]
properties:
name: {type: string, minLength: 1}
cleaningPolicyDigest: {type: string, pattern: '^sha256:[a-f0-9]{64}$'}
cleaningPolicy:
type: object
required: [name, generation, digest, spec]
properties:
name: {type: string, minLength: 1, maxLength: 253}
generation: {type: integer, format: int64, minimum: 1}
digest: {type: string, pattern: '^sha256:[a-f0-9]{64}$'}
spec:
type: object
required: [assurance, rules]
properties:
assurance: {type: string, enum: [Clear, Purge]}
rules:
type: array
minItems: 1
maxItems: 16
x-kubernetes-list-type: map
x-kubernetes-list-map-keys: [name]
items:
type: object
required: [name, match, methods, verify, timePerTiB]
properties:
name: {type: string, minLength: 1, maxLength: 63}
match:
type: object
required: [protocol, mediaType]
properties:
protocol: {type: string, enum: [NVMe, SATA, SAS]}
mediaType: {type: string, enum: [SSD, HDD]}
methods:
type: array
minItems: 1
maxItems: 6
x-kubernetes-list-type: set
items: {type: string, enum: [CryptographicErase, BlockErase, SanitizeOverwrite, Format, SecureErase, Overwrite]}
verify:
type: object
required: [mode]
properties:
mode: {type: string, enum: [Full, Canary]}
samples: {type: integer, format: int32, minimum: 0, maximum: 1024}
timePerTiB: {type: string, minLength: 1, maxLength: 32, pattern: '^([0-9]+(\.[0-9]+)?(ns|us|µs|μs|ms|s|m|h))+$'}
qualified:
type: array
maxItems: 32
items:
type: object
required: [model, firmware, methods]
properties:
model: {type: string, minLength: 1, maxLength: 128}
firmware:
type: array
minItems: 1
maxItems: 16
x-kubernetes-list-type: set
items: {type: string, minLength: 1, maxLength: 64}
methods:
type: array
minItems: 1
maxItems: 6
x-kubernetes-list-type: set
items: {type: string, enum: [CryptographicErase, BlockErase, SanitizeOverwrite, Format, SecureErase, Overwrite]}
alwaysEncrypts: {type: boolean}
bootInterface: {type: string, minLength: 1, maxLength: 63}
targetDisks:
type: array
Expand Down
117 changes: 113 additions & 4 deletions config/components/device-operations/crds/fleet.datumapis.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,24 @@ spec:
type: integer
format: int32
minimum: 1
cleaningPolicyDigest:
type: string
pattern: ^sha256:[0-9a-f]{64}$
policy:
type: object
properties:
name:
type: string
minLength: 1
maxLength: 253
generation:
type: integer
format: int64
minimum: 1
digest:
type: string
pattern: ^sha256:[0-9a-f]{64}$
required:
- name
- generation
- digest
targetDisks:
type: array
minItems: 1
Expand Down Expand Up @@ -882,7 +897,7 @@ spec:
- deviceRef
- authority
- step
- cleaningPolicyDigest
- policy
- targetDisks
x-kubernetes-validations:
- rule: self == oldSelf
Expand Down Expand Up @@ -2043,3 +2058,97 @@ spec:
x-kubernetes-validations:
- rule: self.metadata.name.startsWith(self.spec.planRef.name + '-') && size(self.metadata.name) == size(self.spec.planRef.name) + 17
message: an approval's name is its plan's name and a suffix derived from the plan's UID
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: cleaningpolicies.fleet.datumapis.com
annotations:
discovery.miloapis.com/parent-contexts: Project
spec:
group: fleet.datumapis.com
names:
kind: CleaningPolicy
listKind: CleaningPolicyList
plural: cleaningpolicies
singular: cleaningpolicy
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
additionalPrinterColumns:
- name: Assurance
type: string
jsonPath: .spec.assurance
schema:
openAPIV3Schema:
type: object
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
spec:
type: object
required: [assurance, rules]
properties:
assurance: {type: string, enum: [Clear, Purge]}
rules:
type: array
minItems: 1
maxItems: 16
x-kubernetes-list-type: map
x-kubernetes-list-map-keys: [name]
items:
type: object
required: [name, match, methods, verify, timePerTiB]
properties:
name: {type: string, minLength: 1, maxLength: 63}
match:
type: object
required: [protocol, mediaType]
properties:
protocol: {type: string, enum: [NVMe, SATA, SAS]}
mediaType: {type: string, enum: [SSD, HDD]}
methods:
type: array
minItems: 1
maxItems: 6
x-kubernetes-list-type: set
items: {type: string, enum: [CryptographicErase, BlockErase, SanitizeOverwrite, Format, SecureErase, Overwrite]}
verify:
type: object
required: [mode]
properties:
mode: {type: string, enum: [Full, Canary]}
samples: {type: integer, format: int32, minimum: 0, maximum: 1024}
timePerTiB: {type: string, minLength: 1, maxLength: 32, pattern: '^([0-9]+(\.[0-9]+)?(ns|us|µs|μs|ms|s|m|h))+$'}
qualified:
type: array
maxItems: 32
items:
type: object
required: [model, firmware, methods]
properties:
model: {type: string, minLength: 1, maxLength: 128}
firmware:
type: array
minItems: 1
maxItems: 16
x-kubernetes-list-type: set
items: {type: string, minLength: 1, maxLength: 64}
methods:
type: array
minItems: 1
maxItems: 6
x-kubernetes-list-type: set
items: {type: string, enum: [CryptographicErase, BlockErase, SanitizeOverwrite, Format, SecureErase, Overwrite]}
alwaysEncrypts: {type: boolean}
x-kubernetes-validations:
- rule: self == oldSelf
message: a CleaningPolicy spec is immutable; create a new policy instead
required:
- spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: iam.miloapis.com/v1alpha1
kind: ProtectedResource
metadata:
name: fleet.datumapis.com-cleaningpolicy
spec:
serviceRef:
name: fleet.datumapis.com
kind: CleaningPolicy
plural: cleaningpolicies
singular: cleaningpolicy
# The spec is immutable, so no role needs update or patch. A changed
# policy is a new policy.
permissions: [list, get, watch, create, update, patch, delete]
parentResources:
- apiGroup: resourcemanager.miloapis.com
kind: Project
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resources:
- devicewipe.yaml
- devicepoweroperation.yaml
- devicerecovery.yaml
- cleaningpolicy.yaml
- devicecommissioning.yaml
- devicecommissioningplan.yaml
- devicecommissioningplanapproval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ spec:
- fleet.datumapis.com/devicecommissioningplanapprovals.get
- fleet.datumapis.com/devicecommissioningplanapprovals.list
- fleet.datumapis.com/devicecommissioningplanapprovals.watch
- fleet.datumapis.com/cleaningpolicies.get
Loading
Loading