docs: add package and doc comments for exported identifiers

Document every exported type, function and method in the migration,
storage and cephfsnative packages and add package comments for
migration and the cephmig command, following the commentary rules of
Effective Go. Comments on unexported helpers now start with the name
they describe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-12-03 18:07:48 +01:00
1 parent 7413b9a43a
commit c2ef7a6c3b
12 files changed
+150 -7

No files matched your search

+12 -2
View File
@@ -18,6 +18,8 @@ import (
"time"
)
// Engine runs the snapshot-based migration workflow. Transport moves the
// data; Access, if nil, defaults to mounted filesystem access.
type Engine struct {
Exec Executor
Transport Transport
@@ -34,6 +36,8 @@ type endpointInfo struct {
Encryption string `json:"enctag"`
Earmark string `json:"earmark"`
}
// Inspection is the result of Engine.Inspect.
type Inspection struct {
SourceFSID string `json:"source_fsid"`
TargetFSID string `json:"target_fsid"`
@@ -45,6 +49,8 @@ type Inspection struct {
Notes []string `json:"notes"`
}
// SnapshotIdentityNote documents the accepted deviation that native
// snapshot identities are not preserved at the target.
const SnapshotIdentityNote = "Native snapshot IDs and Ceph birthtimes are recreated at the target; original creation timestamps are recorded in the migration journal."
func (e Engine) log(format string, args ...any) {
@@ -159,8 +165,8 @@ func emptyDirectory(path string) error {
return nil
}
// The claim is outside the migrated tree and survives deletion of the local
// journal. O_EXCL prevents two different jobs from adopting the same target.
// claimTarget locks the target subvolume for the job id. The claim is outside
// the migrated tree and survives deletion of the local journal. O_EXCL prevents two different jobs from adopting the same target.
func claimTarget(root, fsid string, ep Endpoint, id string) (*os.File, error) {
key := sha256.Sum256([]byte(fsid + "\x00" + ep.Filesystem + "\x00" + ep.Group + "\x00" + ep.Subvolume))
dir := filepath.Join(root, ".cephmig", "claims")
@@ -230,6 +236,10 @@ func snapshotDetails(ctx context.Context, src ceph, name string) (Snapshot, erro
return s, err
}
// Sync performs one migration round: it resumes unfinished snapshots,
// transfers newly discovered ones and then a fresh snapshot of the live
// subvolume. With final set, writers must be stopped; Sync then verifies
// the complete inventory and marks the job ready for cutover.
func (e Engine) Sync(ctx context.Context, c Config, statePath string, final bool) error {
if err := c.Validate(); err != nil {
return err