Documentation
¶
Overview ¶
Package admission is the endpoint group for admission: the nodes that ask to join, the nodes osapi has admitted, and the decisions against nodes. It is separate from the agent group, which is the running fleet: an admitted node keeps its record while it is offline, and a node waits for admission before it is part of the fleet.
Index ¶
- Variables
- func Admit(ctx context.Context, d Deps, in AdmitInput) (struct{}, error)
- func Delete(ctx context.Context, d Deps, in MachineInput) (struct{}, error)
- func Reject(ctx context.Context, d Deps, in RejectInput) (struct{}, error)
- func Revoke(ctx context.Context, d Deps, in MachineInput) (struct{}, error)
- type Admission
- type AdmitInput
- type AdmitRequest
- type Deps
- type Jobs
- type ListAdmissionResponse
- type ListInput
- type MachineInput
- type RejectInput
- type RejectRequest
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is a machine that osapi has no record of, or that has no // record in the state the method needs. ErrNotFound = errors.New("admission record not found") // ErrMismatch is an admit whose fingerprint is not the one of the key // the machine requested with. ErrMismatch = errors.New("fingerprint does not match the request") )
var Group = endpoint.Register(endpoint.Define( "admission", "The admission of nodes", endpoint.Area(area.Fleet), endpoint.Title("Admission API"), endpoint.Tag("admission", "Admission", "Admit, reject and revoke the nodes that ask to join."), endpoint.Uses[Deps](), endpoint.Doc[types.AdmissionState]( "The state of a node's admission record: pending, admitted, rejected or revoked.", ), endpoint.Get[ListInput, ListAdmissionResponse]("list"). Fails("a state that is not one of the four", ListInput{State: "accepted"}). Handle(List). ID("GetAdmissions"). Describe("List admission records"). Explain("Returns each machine's admission record: pending, admitted, rejected or "+ "revoked, with whether it is online and when it was last seen."). Returns("The admission records."). Command("List admission records", "Each node that asked to join, each node osapi admitted, and each decision\n"+ "against a node. An admitted node that is not running is Offline, with when\n"+ "it was last seen."). Example(""). Prints(sampleList). Example("--state pending"), endpoint.Get[MachineInput, Admission]("get"). Fails("a machine ID over 255 characters", MachineInput{MachineID: long}). Handle(Get). ID("GetAdmission"). Describe("Get a machine's admission record"). Explain("Returns one machine's admission record by machine ID."). Returns("The admission record."). Command("Get a machine's admission record", ""). Example("--machine-id d530664edc1c431eb5ef1e9dfd6617a5"). Prints(samplePending). Errors(endpoint.NotFound(ErrNotFound, "No admission record for the machine.")), endpoint.Post[AdmitInput, struct{}]("admit"). AdminOnly(). Fails("a machine ID over 255 characters", AdmitInput{MachineID: long, Body: AdmitRequest{Fingerprint: "SHA256:x"}}). Fails("no fingerprint", AdmitInput{MachineID: "m1", Body: AdmitRequest{}}). Fails("a fingerprint over 255 characters", AdmitInput{MachineID: "m1", Body: AdmitRequest{Fingerprint: long}}). Status(http.StatusNoContent). Handle(Admit). Action("admit"). ID("AdmitMachine"). Describe("Admit a pending machine"). Explain("Admits a pending machine. The fingerprint must be the one that "+ "`osapi pki key get --name agent` prints on the machine: it proves that the request "+ "came from the machine the operator is looking at."). Returns("The machine is admitted."). Command("Admit a pending machine", "Run `osapi pki key get --name agent` on the machine, and give the fingerprint that it\n"+ "prints. The controller admits the machine only when the fingerprint is the\n"+ "one of the key in its request."). Example("--machine-id d530664edc1c431eb5ef1e9dfd6617a5 --fingerprint SHA256:1f53dea6..."). Errors( endpoint.NotFound(ErrNotFound, "No pending request from the machine."), endpoint.Conflict(ErrMismatch, "The fingerprint does not match the request."), ), endpoint.Post[RejectInput, struct{}]("reject"). AdminOnly(). Fails("a machine ID over 255 characters", RejectInput{MachineID: long}). Fails("a reason over 1024 characters", RejectInput{MachineID: "m1", Body: RejectRequest{Reason: strings.Repeat("a", 1025)}}). Status(http.StatusNoContent). Handle(Reject). Action("reject"). ID("RejectMachine"). Describe("Reject a pending machine"). Explain("Rejects a pending machine, and keeps a record of the decision, so a "+ "machine that asks again is flagged."). Returns("The machine is rejected."). Command("Reject a pending machine", ""). Example("--machine-id d530664edc1c431eb5ef1e9dfd6617a5 --reason \"unknown host\""). Errors(endpoint.NotFound(ErrNotFound, "No pending request from the machine.")), endpoint.Post[MachineInput, struct{}]("revoke"). AdminOnly(). Fails("a machine ID over 255 characters", MachineInput{MachineID: long}). Status(http.StatusNoContent). Handle(Revoke). Action("revoke"). ID("RevokeMachine"). Describe("Revoke an admitted machine"). Explain("Removes an admitted machine's key, and keeps a record of the decision. "+ "Nothing the machine signs verifies afterwards; to return, it asks again."). Returns("The machine is revoked."). Command("Revoke an admitted machine", "The controller removes the key of the machine. Its responses and its\n"+ "registration stop verifying at once, so a target does not find it."). Example("--machine-id d530664edc1c431eb5ef1e9dfd6617a5"). Errors(endpoint.NotFound(ErrNotFound, "No admitted machine with the ID.")), endpoint.Delete[MachineInput, struct{}]("delete"). AdminOnly(). Fails("a machine ID over 255 characters", MachineInput{MachineID: long}). Status(http.StatusNoContent). Handle(Delete). ID("DeleteMachine"). Describe("Delete a machine"). Explain("Removes a machine's key and each record of it, and keeps none. A machine "+ "that asks again is new. Use it for a machine that goes away on purpose, such "+ "as a VM that is rebuilt; revoke a machine that is not trusted."). Returns("The machine is deleted."). Command("Delete a machine", "The controller removes the key of the machine and each record of it. Unlike\n"+ "revoke, it keeps no record, so a machine that asks again is new. Use it\n"+ "before a machine is rebuilt or removed."). Example("--machine-id d530664edc1c431eb5ef1e9dfd6617a5"). Errors(endpoint.NotFound(ErrNotFound, "No record of the machine.")), ))
Group is the admission group's definition.
Functions ¶
func Admit ¶
func Admit( ctx context.Context, d Deps, in AdmitInput, ) (struct{}, error)
Admit admits a pending machine when the fingerprint is the one of its request.
func Delete ¶
func Delete( ctx context.Context, d Deps, in MachineInput, ) (struct{}, error)
Delete removes a machine's key and each record of it.
Types ¶
type Admission ¶
type Admission struct {
MachineID string `` /* 176-byte string literal not displayed */
Hostname string `` /* 150-byte string literal not displayed */
State types.AdmissionState `` /* 152-byte string literal not displayed */
Online bool `json:"online" doc:"Whether the node is running now: it is in the registry."`
LastSeen *time.Time `` /* 262-byte string literal not displayed */
Fingerprint string `` /* 249-byte string literal not displayed */
EncryptionKey string `` /* 272-byte string literal not displayed */
RequestedAt *time.Time `` /* 272-byte string literal not displayed */
AdmittedAt *time.Time `` /* 272-byte string literal not displayed */
DecidedAt *time.Time `` /* 272-byte string literal not displayed */
Reason string `` /* 272-byte string literal not displayed */
Previous types.AdmissionState `` /* 272-byte string literal not displayed */
PreviousFingerprint string `` /* 272-byte string literal not displayed */
JoinToken string `` /* 272-byte string literal not displayed */
}
Admission is one machine's admission record.
type AdmitInput ¶
type AdmitInput struct {
MachineID string `json:"machine_id" in:"path" validate:"required,min=1,max=255" doc:"The machine ID of the node."`
Body AdmitRequest ` in:"body" validate:"required"`
}
AdmitInput names a pending machine, and the fingerprint the machine printed.
type AdmitRequest ¶
type AdmitRequest struct {
Fingerprint string `` /* 234-byte string literal not displayed */
}
AdmitRequest is the fingerprint that proves the machine.
type Deps ¶
type Deps struct {
// Store keeps the admission records.
Store Store
// Jobs reads the registry, for which nodes are online, and the last
// time each node reported.
Jobs Jobs
}
Deps is what the admission group's handlers use.
type Jobs ¶
type Jobs interface {
ListAgents(ctx context.Context) ([]job.AgentInfo, error)
AgentsLastSeen(ctx context.Context) (map[string]time.Time, error)
}
Jobs is the part of the job client the admission group uses.
type ListAdmissionResponse ¶
type ListAdmissionResponse struct {
TotalItems int `json:"total_items" doc:"The number of records." example:"3"`
Items []Admission `json:"items" doc:"The admission records, in hostname order."`
}
ListAdmissionResponse is the admission records.
type ListInput ¶
type ListInput struct {
State types.AdmissionState `` /* 127-byte string literal not displayed */
}
ListInput filters the records by state.
type MachineInput ¶
type MachineInput struct {
MachineID string `json:"machine_id" in:"path" validate:"required,min=1,max=255" doc:"The machine ID of the node."`
}
MachineInput names a machine.
type RejectInput ¶
type RejectInput struct {
MachineID string `json:"machine_id" in:"path" validate:"required,min=1,max=255" doc:"The machine ID of the node."`
Body RejectRequest ` in:"body" validate:"required"`
}
RejectInput names a pending machine, and why it is rejected.
type RejectRequest ¶
type RejectRequest struct {
Reason string `` /* 161-byte string literal not displayed */
}
RejectRequest is why the machine is rejected.
type Store ¶
type Store interface {
List(ctx context.Context) ([]admission.Record, error)
Get(ctx context.Context, machineID string) (admission.Record, error)
Admit(ctx context.Context, machineID string, fingerprint string) error
Reject(ctx context.Context, machineID string, reason string) error
Revoke(ctx context.Context, machineID string) error
Delete(ctx context.Context, machineID string) error
}
Store keeps the admission records.