Documentation
¶
Overview ¶
Package nodestorage routes server file, configuration and content I/O through the node that owns the server (ADR 0005). The local accessor is confined to the server data root. Remote nodes on shared storage are served through the controller's mount of that storage; other remote nodes get a typed refusal until a remote adapter is wired, so a controller-local path is never silently mistaken for a remote node's storage.
Index ¶
- Variables
- func EnsureDataRoot(node NodeInfo, dataRoot string) (string, error)
- func IsEscape(err error) bool
- func IsLegacyLocalNodeID(nodeID string) bool
- func IsSymlink(err error) bool
- func IsUnavailable(err error) bool
- func MapDataPath(node NodeInfo, dataRoot string) (string, error)
- func MapPath(node NodeInfo, dataRoot, p string) string
- func NodePath(node NodeInfo, dataRoot, p string) string
- type Accessor
- type NodeInfo
Constants ¶
This section is empty.
Variables ¶
var ErrEscape = errors.New("path escapes the data root")
ErrEscape reports a path that would leave the server data root.
var ErrSymlink = errors.New("cannot write through symbolic link")
ErrSymlink reports an attempt to write through a symbolic link. Writes must land on real files inside the data root.
ErrUnavailable reports that the owning node's storage adapter is not configured. Callers must treat it as a refusal, never fall back to local paths for a remote node.
Functions ¶
func EnsureDataRoot ¶
EnsureDataRoot resolves the mapped data root like MapDataPath and creates the server directory under it when missing, so restore can target a fresh directory on shared storage. The controller-side storage root itself must already exist: creating it could hide a missing mount and silently store server data on the controller's local disk.
func IsLegacyLocalNodeID ¶
IsLegacyLocalNodeID reports whether a node ID designates the controller's own daemon on the legacy single-node deployment path. The aliases match the ones the Docker client pool accepts.
func IsUnavailable ¶
IsUnavailable reports whether err is the typed remote-node refusal.
func MapDataPath ¶
MapDataPath maps a server data root to the controller-side directory that holds it. Local nodes keep the path unchanged. Remote nodes on shared storage are mapped through the controller's mount of that storage: the server directory keeps its name under the controller-side root. Other remote nodes are refused with ErrUnavailable.
func MapPath ¶
MapPath maps an arbitrary path under a server data root to its controller-side location (see MapDataPath). Paths outside the data root and nodes without reachable storage are returned unchanged.
Types ¶
type Accessor ¶
type Accessor interface {
Stat(rel string) (os.FileInfo, error)
ReadFile(rel string) ([]byte, error)
WriteFile(rel string, data []byte) error
ReadDir(rel string) ([]os.DirEntry, error)
MkdirAll(rel string) error
Remove(rel string) error
RemoveAll(rel string) error
Rename(oldRel, newRel string) error
Root() string
// Close releases the accessor's handle on the data root. Callers must
// close accessors they open.
Close() error
}
Accessor performs file operations inside one server's data root on the node that owns the server. All paths are relative to the root; every operation is confined to it.
func ForNode ¶
ForNode returns the accessor for a server data root owned by a node. Local nodes (the controller's own daemon) use the confined local accessor rooted at the server's data path. Remote nodes on shared storage are served through the controller's mount of that storage (see MapDataPath). Remote nodes without shared storage are refused until their storage adapter is wired.