common

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

pkg/providers/common/update.go

Index

Constants

View Source
const (
	UpdateQueueSize         = 100
	ResourcePollingInterval = 2 * time.Second
	DebugFilePath           = "/tmp/andaime-debug.log"
	DefaultSSHUser          = "andaimeuser"
	DebugFilePermissions    = 0644
	WaitingForMachinesTime  = 1 * time.Minute
)

Variables

View Source
var (
	ErrNoRegionsSpecified = fmt.Errorf("no regions specified")
	ErrNoImagesFound      = fmt.Errorf("no images found")
)

Provide a list of errors that can be used by any provider

Functions

func CreateNewMachine

func CreateNewMachine(
	deploymentType models.DeploymentType,
	location string,
	diskSizeGB int,
	vmSize string,
	diskImageFamily string,
	diskImageURL string,
	privateKeyPath string,
	privateKeyBytes []byte,
	publicKeyPath string,
	publicKeyBytes []byte,
) (models.Machiner, error)

func GenerateTags

func GenerateTags(projectID, uniqueID string) map[string]string

GenerateTags creates a map of tags for cloud resources

func IsValidResourceGroupName

func IsValidResourceGroupName(name string) bool

func PrepareDeployment

func PrepareDeployment(
	ctx context.Context,
	provider models.DeploymentType,
) (*models.Deployment, error)

func ProcessMachinesConfig

func ProcessMachinesConfig(
	providerType models.DeploymentType,
	validateMachineTypeFn func(context.Context, string, string) (bool, error),
) (map[string]models.Machiner, map[string]bool, error)

func SetDefaultConfigurations

func SetDefaultConfigurations(provider models.DeploymentType)

Types

type ClusterDeployer

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

ClusterDeployer struct that implements ClusterDeployerInterface

func NewClusterDeployer

func NewClusterDeployer(provider models.DeploymentType) *ClusterDeployer

func (*ClusterDeployer) ApplyBacalhauConfigs

func (cd *ClusterDeployer) ApplyBacalhauConfigs(
	ctx context.Context,
	sshConfig sshutils.SSHConfiger,
	combinedSettings []models.BacalhauSettings,
) error

func (*ClusterDeployer) ExecuteCustomScript

func (cd *ClusterDeployer) ExecuteCustomScript(
	ctx context.Context,
	sshConfig sshutils.SSHConfiger,
	machine models.Machiner,
) error

func (*ClusterDeployer) FindOrchestratorMachine

func (cd *ClusterDeployer) FindOrchestratorMachine() (models.Machiner, error)

func (*ClusterDeployer) HandleDeploymentError

func (cd *ClusterDeployer) HandleDeploymentError(
	_ context.Context,
	machine models.Machiner,
	err error,
) error

func (*ClusterDeployer) InstallBacalhau

func (cd *ClusterDeployer) InstallBacalhau(
	ctx context.Context,
	sshConfig sshutils.SSHConfiger,
) error

func (*ClusterDeployer) InstallBacalhauRunScript

func (cd *ClusterDeployer) InstallBacalhauRunScript(
	ctx context.Context,
	sshConfig sshutils.SSHConfiger,
) error

func (*ClusterDeployer) ProvisionBacalhauCluster

func (cd *ClusterDeployer) ProvisionBacalhauCluster(ctx context.Context) error

func (*ClusterDeployer) ProvisionBacalhauNode added in v0.0.3

func (cd *ClusterDeployer) ProvisionBacalhauNode(
	ctx context.Context,
	sshConfig sshutils.SSHConfiger,
	machine models.Machiner,
	bacalhauSettings []models.BacalhauSettings,
) error

ProvisionBacalhauNode provisions a Bacalhau node on the specified machine. It performs a series of steps to configure, install, and verify the Bacalhau service.

Parameters:

  • ctx: The context for controlling the function's lifecycle.
  • machine: The machine on which the Bacalhau node will be provisioned.
  • nodeType: The type of the node, e.g., "compute".
  • orchestratorIP: The IP address of the orchestrator, required if nodeType is "compute".

Returns:

  • error: An error if any step in the provisioning process fails.

The function performs the following steps:

  1. Creates an SSH configuration for the machine.
  2. Sets the service state to updating.
  3. Validates the orchestrator IP if the node type is "compute".
  4. Sets up node configuration metadata.
  5. Installs the Bacalhau service.
  6. Installs the Bacalhau run script.
  7. Sets up the Bacalhau service.
  8. Verifies the Bacalhau deployment.
  9. Applies Bacalhau configurations.
  10. Executes any custom scripts.
  11. Restarts the Bacalhau service to ensure everything is functioning correctly.

If any step fails, the function handles the deployment error and returns the error. Upon successful completion, it logs the success, updates the service state to succeeded, and marks the machine as complete.

func (*ClusterDeployer) ProvisionMachine added in v0.0.9

func (cd *ClusterDeployer) ProvisionMachine(
	ctx context.Context,
	sshConfig sshutils.SSHConfiger,
	machine models.Machiner,
) error

func (*ClusterDeployer) ProvisionOrchestrator

func (cd *ClusterDeployer) ProvisionOrchestrator(ctx context.Context, machineName string) error

func (*ClusterDeployer) ProvisionWorker

func (cd *ClusterDeployer) ProvisionWorker(
	ctx context.Context,
	machineName string,
) error

func (*ClusterDeployer) SetSSHClient

func (cd *ClusterDeployer) SetSSHClient(client sshutils.SSHClienter)

func (*ClusterDeployer) SetupBacalhauService

func (cd *ClusterDeployer) SetupBacalhauService(
	ctx context.Context,
	sshConfig sshutils.SSHConfiger,
) error

func (*ClusterDeployer) SetupNodeConfigMetadata

func (cd *ClusterDeployer) SetupNodeConfigMetadata(
	ctx context.Context,
	machine models.Machiner,
	sshConfig sshutils.SSHConfiger,
) error

func (*ClusterDeployer) VerifyBacalhauDeployment

func (cd *ClusterDeployer) VerifyBacalhauDeployment(
	ctx context.Context,
	sshConfig sshutils.SSHConfiger,
	orchestratorIP string,
) error

func (*ClusterDeployer) WaitForAllMachinesToReachState

func (cd *ClusterDeployer) WaitForAllMachinesToReachState(
	ctx context.Context,
	resourceType string,
	state models.MachineResourceState,
) error

type RawMachine

type RawMachine struct {
	Location   string           `yaml:"location"`
	Parameters RawMachineParams `yaml:"parameters,omitempty"`
}

type RawMachineParams

type RawMachineParams struct {
	Count           int    `yaml:"count,omitempty"`
	Type            string `yaml:"type,omitempty"`
	Orchestrator    bool   `yaml:"orchestrator,omitempty"`
	DiskSizeGB      int    `yaml:"disk_size_gb,omitempty"`
	DiskImageURL    string `yaml:"disk_image_url,omitempty"`
	DiskImageFamily string `yaml:"disk_image_family,omitempty"`
}

Jump to

Keyboard shortcuts

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