native

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package native implements driver

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SuPath      string `json:"su_path"`      // Path to the su (login as user) binary
	SudoPath    string `json:"sudo_path"`    // Path to the sudo (privilege escalation) binary
	ShPath      string `json:"sh_path"`      // Path to the sh (simple user shell) binary
	TarPath     string `json:"tar_path"`     // Path to the tar (unpacking images) binary
	MountPath   string `json:"mount_path"`   // Path to the mount (list of mounted volumes) binary
	ChownPath   string `json:"chown_path"`   // Path to the chown (change file/dir ownership) binary
	ChmodPath   string `json:"chmod_path"`   // Path to the chmod (change file/dir access) binary
	KillallPath string `json:"killall_path"` // Path to the killall (send signals to multiple processes) binary
	RmPath      string `json:"rm_path"`      // Path to the rm (cleanup after execution) binary

	ImagesPath    string `json:"images_path"`    // Where to store/look the environment images
	WorkspacePath string `json:"workspace_path"` // Where to place the env disks

	DsclPath          string `json:"dscl_path"`          // Path to the dscl (macos user control) binary
	HdiutilPath       string `json:"hdiutil_path"`       // Path to the hdiutil (macos images create/mount/umount) binary
	MdutilPath        string `json:"mdutil_path"`        // Path to the mdutil (macos disable indexing for disks) binary
	CreatehomedirPath string `json:"createhomedir_path"` // Path to the createhomedir (macos create/prefill user directory) binary

	// Alter allows you to control how much resources will be used:
	// * Negative (<0) value will alter the total resource count before provisioning so you will be
	//   able to save some resources for the host system (recommended -2 for CPU and -10 for RAM
	//   for disk caching)
	// * Positive (>0) is also available, but you're going to put more load on the scheduler
	//   Please be careful here - noone wants the workload to fail allocation because of that...
	CPUAlter int `json:"cpu_alter"` // 0 do nothing, <0 reduces number available CPUs, >0 increases it (dangerous)
	RAMAlter int `json:"ram_alter"` // 0 do nothing, <0 reduces amount of available RAM (GB), >0 increases it (dangerous)

	// Overbook options allows tenants to reuse the resources
	// It will be used only when overbook is allowed by the tenants. It works by just adding those
	// amounts to the existing total before checking availability. For example if you have 16CPU
	// and want to run 2 tenants with requirement of 14 CPUs each - you can put 12 in CPUOverbook -
	// to have virtually 28 CPUs. 3rd will not be running because 2 tenants will eat all 28 virtual
	// CPUs. Same applies to the RamOverbook.
	CPUOverbook uint `json:"cpu_overbook"` // How much CPUs could be reused by multiple tenants
	RAMOverbook uint `json:"ram_overbook"` // How much RAM (GB) could be reused by multiple tenants

	DownloadUser     string `json:"download_user"`     // The user will be used to auth in download operations
	DownloadPassword string `json:"download_password"` // The password will be used to auth in download operations
}

Config - node driver configuration

func (*Config) Apply

func (c *Config) Apply(config []byte) (err error)

Apply takes json and applies it to the config structure

func (*Config) Validate

func (c *Config) Validate() (err error)

Validate makes sure the config have the required defaults & that the required fields are set

type Driver

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

Driver implements drivers.ResourceDriver interface

func (*Driver) Allocate

func (d *Driver) Allocate(def types.LabelDefinition, metadata map[string]any) (*types.Resource, error)

Allocate workload environment with the provided images

It automatically download the required images, unpack them and runs the workload. Using metadata to pass the env to the entry point of the image.

func (*Driver) AvailableCapacity

func (d *Driver) AvailableCapacity(nodeUsage types.Resources, req types.LabelDefinition) int64

AvailableCapacity allows Fish to ask the driver about it's capacity (free slots) of a specific definition

func (*Driver) Deallocate

func (d *Driver) Deallocate(res *types.Resource) error

Deallocate the resource

func (*Driver) GetTask

func (d *Driver) GetTask(name, options string) drivers.ResourceDriverTask

GetTask returns task struct by name

func (*Driver) IsRemote

func (*Driver) IsRemote() bool

IsRemote needed to detect the out-of-node resources managed by this driver

func (*Driver) Name

func (*Driver) Name() string

Name returns name of the driver

func (*Driver) Prepare

func (d *Driver) Prepare(config []byte) error

Prepare initializes the driver

func (*Driver) Status

func (*Driver) Status(res *types.Resource) (string, error)

Status shows status of the resource

func (*Driver) ValidateDefinition

func (*Driver) ValidateDefinition(def types.LabelDefinition) error

ValidateDefinition checks LabelDefinition is ok

type EnvData

type EnvData struct {
	Disks map[string]string // Map with disk_name = mount_path
}

EnvData is used to provide some data to the entry/metadata values which could contain templates

type Factory added in v0.7.3

type Factory struct{}

Factory implements drivers.ResourceDriverFactory interface

func (*Factory) Name added in v0.7.3

func (*Factory) Name() string

Name shows name of the driver factory

func (*Factory) NewResourceDriver added in v0.7.3

func (*Factory) NewResourceDriver() drivers.ResourceDriver

NewResourceDriver creates new resource driver

type Options

type Options struct {
	Images []drivers.Image `json:"images"` // Optional list of image dependencies, they will be unpacked in order
	//TODO: Setup  string          `json:"setup"`  // Optional path to the executable, it will be started before the Entry with escalated privileges
	Entry  string   `json:"entry"`  // Optional path to the executable, it will be running as workload (default: init.sh / init.ps1)
	Groups []string `json:"groups"` // Optional user groups user should have, first one is primary (default: staff)
}

Options for label definition

Example:

images:
  - url: https://artifact-storage/aquarium/image/native/macos-VERSION/macos-VERSION.tar.xz
    sum: sha256:1234567890abcdef1234567890abcdef1
    tag: ws  # The same as a name of disk in Label resource definition
  - url: https://artifact-storage/aquarium/image/native/macos_amd64-ci-VERSION/macos_amd64-ci-VERSION.tar.xz
    sum: sha256:1234567890abcdef1234567890abcdef2
    tag: ws
entry: "{{ .Disks.ws }}/init.sh"  # CWD is user home
groups:
  - staff
  - importantgroup

func (*Options) Apply

func (o *Options) Apply(options util.UnparsedJSON) error

Apply takes json and applies it to the options structure

func (*Options) Validate

func (o *Options) Validate() error

Validate makes sure the options have the required defaults & that the required fields are set Note: there is no mandatory options, because in theory the native env could be pre-created

Jump to

Keyboard shortcuts

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