mounts

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package mounts is the VM side of dynamic share mounts. An operator (e.g. a teacher) publishes a ShareMount on the event bus — to one VM, or via control-plane fan-out to a whole class of student VMs — and each VM applies it: mount on action "" / "mount", tear down on "unmount".

State is pushed whole and applied idempotently (replace-by-ID), so a missed message self-heals on the next publish — the same model pkg/mesh uses for WireGuard membership.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleMessage

func HandleMessage(data []byte, apply ApplyFunc) error

HandleMessage decodes a published mount update and applies it. Pure aside from the injected apply, so the decode/validate path is testable without a broker or a kernel.

func Subject

func Subject(vmID string) string

Subject is the per-VM event-bus subject share mount updates arrive on. A class-wide publish is the control plane's job: it resolves the group to its VMs and publishes to each VM's subject (mirrors how weft fans out mesh updates), so the guest only ever trusts its own subject.

Types

type ApplyFunc

type ApplyFunc func(pod.ShareMount) error

ApplyFunc mounts or unmounts one share according to spec.Action. The real implementation drives the CubeFS FUSE client (Linux); tests inject a stub.

type Subscriber

type Subscriber struct {
	// contains filtered or unexported fields
}

Subscriber listens for this VM's share-mount updates and applies each one.

func NewSubscriber

func NewSubscriber(nc *nats.Conn, vmID string, apply ApplyFunc, logger *log.Logger) *Subscriber

NewSubscriber builds a Subscriber for vmID that applies updates via apply.

func (*Subscriber) Start

func (s *Subscriber) Start() (*nats.Subscription, error)

Start subscribes to the VM's mounts subject. The returned subscription is live until unsubscribed or the connection drops.

Two delivery modes :

  1. JetStream (production) : a stream named `weft-mounts` with `weft.mounts.*` subjects + LastPerSubject retention is the boot-time replay guarantee — the subscriber's first connect gets the most recent ShareMount state for its VM, even if the publisher (e.g. loom-server) emitted it before the VM was alive. The subscriber auto-ensures the stream exists ; a re-attempt after a transient publisher failure is a no-op.

  2. Core NATS (dev fallback) : when JetStream isn't available on the broker the subscriber falls back to a plain Subscribe, matching the original behaviour. Boot-time delivery is then best-effort (depends on publisher timing) but interactive publish-while-running keeps working.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL