Files
nomad/api/node_identity.go
James Rasell 953a149180 client: Allow operators to force a client to renew its identity. (#26277)
The Nomad client will have its identity renewed according to the
TTL which defaults to 24h. In certain situations such as root
keyring rotation, operators may want to force clients to renew
their identities before the TTL threshold is met. This change
introduces a client HTTP and RPC endpoint which will instruct the
node to request a new identity at its next heartbeat. This can be
used via the API or a new command.

While this is a manual intervention step on top of the any keyring
rotation, it dramatically reduces the initial feature complexity
as it provides an asynchronous and efficient method of renewal that
utilises existing functionality.
2025-07-16 14:56:00 +01:00

34 lines
868 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package api
type NodeIdentityRenewRequest struct {
NodeID string
}
type NodeIdentityRenewResponse struct{}
type NodeIdentity struct {
client *Client
}
func (n *Nodes) Identity() *NodeIdentity {
return &NodeIdentity{client: n.client}
}
// Renew instructs the node to request a new identity from the server at its
// next heartbeat.
//
// The request uses query options to control the forwarding behavior of the
// request only. Parameters such as Filter, WaitTime, and WaitIndex are not used
// and ignored.
func (n *NodeIdentity) Renew(req *NodeIdentityRenewRequest, qo *QueryOptions) (*NodeIdentityRenewResponse, error) {
var out NodeIdentityRenewResponse
_, err := n.client.postQuery("/v1/client/identity/renew", req, &out, qo)
if err != nil {
return nil, err
}
return &out, nil
}