Documentation
¶
Index ¶
- Constants
- func BuildMigrationWorkflow(manager *Manager, profile, valuesFile string) (*automa.WorkflowBuilder, error)
- func ValidateStorageCompleteness(storage models.BlockNodeStorage, chartVersion string) error
- type Manager
- func (m *Manager) ClearStorageDirectory(dirPath string) error
- func (m *Manager) ComputeValuesFile(profile string, valuesFile string) (string, error)
- func (m *Manager) CreateNamespace(ctx context.Context, tempDir string) error
- func (m *Manager) CreateOptionalStorage(ctx context.Context, tempDir string, optStor OptionalStorage) error
- func (m *Manager) CreatePersistentVolumes(ctx context.Context, tempDir string) error
- func (m *Manager) DeleteNamespace(ctx context.Context, tempDir string) error
- func (m *Manager) DeletePersistentVolumes(ctx context.Context, tempDir string) error
- func (m *Manager) DeleteStatefulSetForUpgrade(ctx context.Context) error
- func (m *Manager) GetInstalledVersion() (string, error)
- func (m *Manager) GetReleaseValues() (map[string]interface{}, error)
- func (m *Manager) GetStoragePaths() (archivePath, livePath, logPath string, optionalPaths []string, err error)
- func (m *Manager) GetTargetVersion() string
- func (m *Manager) InstallChart(ctx context.Context, valuesFile string) (bool, error)
- func (m *Manager) ResetStorage(ctx context.Context) error
- func (m *Manager) ScaleStatefulSet(ctx context.Context, replicas int32) error
- func (m *Manager) SetupStorage(ctx context.Context) error
- func (m *Manager) UninstallChart(ctx context.Context) error
- func (m *Manager) UpgradeChart(ctx context.Context, valuesFile string, reuseValues bool) error
- func (m *Manager) WaitForPodReady(ctx context.Context) error
- func (m *Manager) WaitForPodsTerminated(ctx context.Context) error
- type OptionalStorage
- type StorageMigration
Constants ¶
const ( // Kubernetes resources ResourceNameSuffix = "-block-node-server" PodLabelSelector = "app.kubernetes.io/name=block-node-server" // Template paths NamespacePath = "files/block-node/namespace.yaml" StorageConfigPath = "files/block-node/storage-config.yaml" OptionalStoragePath = "files/block-node/optional-storage.yaml" ValuesPath = "files/block-node/full-values.yaml" NanoValuesPath = "files/block-node/nano-values.yaml" // Timeouts PodReadyTimeoutSeconds = 300 )
Variables ¶
This section is empty.
Functions ¶
func BuildMigrationWorkflow ¶ added in v0.7.0
func BuildMigrationWorkflow(manager *Manager, profile, valuesFile string) (*automa.WorkflowBuilder, error)
BuildMigrationWorkflow returns an automa workflow for executing applicable migrations. Returns nil if no migrations are needed (installed version is empty or no applicable migrations).
The workflow structure is:
[migration-start] → [migration-<id>] → ... → [migration-upgrade-chart]
Each migration step creates its PV/PVC. The final upgrade step performs a single StatefulSet delete + Helm upgrade to the target version with all new storages included.
func ValidateStorageCompleteness ¶ added in v0.15.0
func ValidateStorageCompleteness(storage models.BlockNodeStorage, chartVersion string) error
ValidateStorageCompleteness checks that enough storage paths are set to resolve all required paths for the given chart version. Either basePath must be set (to derive missing paths) or all required individual paths must be explicit. This includes core paths (archive, live, log) and version-dependent optional paths (verification, plugins).
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles block node setup and management operations. Methods are grouped by concern across sibling files:
- storage.go — directory setup, PV/PVC lifecycle, path resolution
- chart.go — Helm install/upgrade/uninstall, StatefulSet and pod lifecycle
- values.go — Helm values file computation and YAML injection helpers
func NewManager ¶
func NewManager(blockConfig models.BlockNodeInputs) (*Manager, error)
NewManager creates a new block node manager
func (*Manager) ClearStorageDirectory ¶ added in v0.8.0
ClearStorageDirectory removes all files and subdirectories from a storage directory while preserving the directory itself.
func (*Manager) ComputeValuesFile ¶
ComputeValuesFile generates the values file for helm installation based on profile and version. It writes the result to a temp file and returns the path.
When no custom values file is provided, the appropriate built-in template is rendered. When a custom values file is provided, persistence settings are injected to ensure weaver-managed PVCs are referenced (create: false + existingClaim) rather than letting the chart create its own.
In both cases, effective retention thresholds are merged into blockNode.config.
NOTE: Defense-in-depth path validation is applied even though the CLI layer also validates.
func (*Manager) CreateNamespace ¶
CreateNamespace creates the block-node namespace if it doesn't exist. ApplyManifest is idempotent so this is safe to call on every install.
func (*Manager) CreateOptionalStorage ¶ added in v0.10.0
func (m *Manager) CreateOptionalStorage(ctx context.Context, tempDir string, optStor OptionalStorage) error
CreateOptionalStorage creates a single optional PV/PVC using the unified template. Used during migration when other PVs already exist.
func (*Manager) CreatePersistentVolumes ¶
CreatePersistentVolumes creates PVs and PVCs from the storage config
func (*Manager) DeleteNamespace ¶
DeleteNamespace deletes the block-node namespace
func (*Manager) DeletePersistentVolumes ¶
DeletePersistentVolumes deletes PVs and PVCs
func (*Manager) DeleteStatefulSetForUpgrade ¶ added in v0.10.0
DeleteStatefulSetForUpgrade deletes the block node StatefulSet using orphan cascading and waits for it to be fully removed from the API server. This is required before any Helm upgrade that changes volumeClaimTemplates, since Kubernetes forbids in-place updates. Returns nil if the StatefulSet does not exist.
func (*Manager) GetInstalledVersion ¶ added in v0.7.0
GetInstalledVersion returns the currently installed Block Node chart version. Returns empty string if not installed.
func (*Manager) GetReleaseValues ¶ added in v0.7.0
GetReleaseValues returns the user-supplied values from the currently installed release. Returns nil if not installed or if no user values were supplied.
func (*Manager) GetStoragePaths ¶ added in v0.6.0
func (m *Manager) GetStoragePaths() (archivePath, livePath, logPath string, optionalPaths []string, err error)
GetStoragePaths returns the computed storage paths based on configuration. If individual paths are specified, they are used; otherwise, paths are derived from basePath. All paths are validated using sanity checks. optionalPaths contains the paths for applicable optional storages (in registry order).
func (*Manager) GetTargetVersion ¶ added in v0.10.0
GetTargetVersion returns the configured target version for block node.
func (*Manager) InstallChart ¶
InstallChart installs the block node helm chart
func (*Manager) ResetStorage ¶ added in v0.8.0
ResetStorage clears all block node storage directories.
func (*Manager) ScaleStatefulSet ¶ added in v0.8.0
ScaleStatefulSet scales the block node statefulset to the specified number of replicas
func (*Manager) SetupStorage ¶
SetupStorage creates the required directories for block node storage
func (*Manager) UninstallChart ¶
UninstallChart uninstalls the block node helm chart
func (*Manager) UpgradeChart ¶ added in v0.5.0
UpgradeChart upgrades the block node helm chart. When reuseValues is true and no custom values file is provided, the existing release values are reused unchanged (following Helm CLI convention).
func (*Manager) WaitForPodReady ¶
WaitForPodReady waits for the block node pod to be ready
type OptionalStorage ¶ added in v0.10.0
type OptionalStorage struct {
// Name is the human-readable name used in logs and template field names
// (e.g., "verification", "plugins"). Must match the Helm persistence key.
Name string
// MinVersion is the minimum Block Node version that requires this storage.
MinVersion string
// PVName is the PersistentVolume resource name (e.g., "verification-storage-pv").
PVName string
// PVCName is the PersistentVolumeClaim resource name (e.g., "verification-storage-pvc").
PVCName string
// DirName is the subdirectory name under basePath (e.g., "verification").
DirName string
// GetPath returns the models.red path from the storage models.
GetPath func(s *models.BlockNodeStorage) string
// SetPath sets the path in the storage models.
SetPath func(s *models.BlockNodeStorage, p string)
// GetSize returns the models.red size from the storage models.
GetSize func(s *models.BlockNodeStorage) string
}
OptionalStorage describes an optional storage volume that is conditionally required based on the target Block Node chart version.
func GetApplicableOptionalStorages ¶ added in v0.10.0
func GetApplicableOptionalStorages(targetVersion string) []OptionalStorage
GetApplicableOptionalStorages returns the subset of optional storages that are required by the given target version.
func GetOptionalStorages ¶ added in v0.10.0
func GetOptionalStorages() []OptionalStorage
GetOptionalStorages returns the full list of registered optional storages.
func (*OptionalStorage) RequiredByVersion ¶ added in v0.10.0
func (o *OptionalStorage) RequiredByVersion(targetVersion string) bool
RequiredByVersion returns true if the given target version requires this optional storage.
type StorageMigration ¶ added in v0.10.0
type StorageMigration struct {
migration.VersionMigration
// contains filtered or unexported fields
}
StorageMigration handles the breaking change pattern where a new storage PV/PVC is added to the Block Node StatefulSet. It is parameterized by the OptionalStorage descriptor, allowing a single implementation to serve all storage migrations.
Execute only creates the storage directory and PV/PVC — no Helm upgrade is performed. The single upgrade is appended as a final workflow step by BuildMigrationWorkflow.
func NewPluginsStorageMigration ¶ added in v0.10.0
func NewPluginsStorageMigration() *StorageMigration
NewPluginsStorageMigration creates the plugins storage migration.
func NewStorageMigration ¶ added in v0.10.0
func NewStorageMigration(optStorage OptionalStorage) *StorageMigration
NewStorageMigration creates a new storage migration for the given optional storage entry.
func NewVerificationStorageMigration ¶ added in v0.7.0
func NewVerificationStorageMigration() *StorageMigration
NewVerificationStorageMigration creates the verification storage migration.