fish

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: 28 Imported by: 0

Documentation

Overview

Package fish core defines all the internals of the Fish processes

Index

Constants

View Source
const ElectionRoundTime = 30

ElectionRoundTime defines how long the voting round will take in seconds - so cluster nodes will be able to interchange their responses

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Directory string `json:"directory"` // Where to store database and other useful data (if relative - to CWD)

	APIAddress        string         `json:"api_address"`         // Where to serve Web UI, API & Meta API
	ProxySocksAddress string         `json:"proxy_socks_address"` // Where to serve SOCKS5 proxy for the allocated resources
	ProxySSHAddress   string         `json:"proxy_ssh_address"`   // Where to serve SSH proxy for the allocated resources
	NodeAddress       string         `json:"node_address"`        // What is the external address of the node
	CPULimit          uint16         `json:"cpu_limit"`           // How many CPU threads Node allowed to use (serve API, ...)
	MemTarget         util.HumanSize `json:"mem_target"`          // What's the target memory utilization by the Node (GC target where it becomes more aggressive)
	ClusterJoin       []string       `json:"cluster_join"`        // The node addresses to join the cluster

	TLSKey   string `json:"tls_key"`    // TLS PEM private key (if relative - to directory)
	TLSCrt   string `json:"tls_crt"`    // TLS PEM public certificate (if relative - to directory)
	TLSCaCrt string `json:"tls_ca_crt"` // TLS PEM certificate authority certificate (if relative - to directory)

	NodeName        string   `json:"node_name"`        // Last resort in case you need to override the default host node name
	NodeLocation    string   `json:"node_location"`    // Specify cluster node location for multi-dc configurations
	NodeIdentifiers []string `json:"node_identifiers"` // The list of node identifiers which could be used to find the right Node for Resource

	NodeSSHKey string `json:"ssh_key"` // The SSH RSA identity private key for the fish node (if relative - to directory)

	DefaultResourceLifetime string `json:"default_resource_lifetime"` // Sets the lifetime of the resource which will be used if label definition one is not set

	// Configuration for the node drivers, if defined - only the listed plugins will be loaded
	// Each configuration could instantinate the same driver multiple times by adding instance name
	// separated from driver by slash symbol (like "<driver>/prod" - will create "prod" instance).
	Drivers []ConfigDriver `json:"drivers"`
}

Config defines Fish node configuration

func (*Config) ReadConfigFile

func (c *Config) ReadConfigFile(cfgPath string) error

ReadConfigFile needed to read the config file

type ConfigDriver

type ConfigDriver struct {
	Name string            `json:"name"`
	Cfg  util.UnparsedJSON `json:"cfg"`
}

ConfigDriver helper to store driver config without parsing it right away

type Fish

type Fish struct {

	// Signal to stop the fish
	Quit chan os.Signal
	// contains filtered or unexported fields
}

Fish structure is used to store the node internal state

func New

func New(db *gorm.DB, cfg *Config) (*Fish, error)

New creates new Fish node

func (*Fish) ApplicationCreate

func (f *Fish) ApplicationCreate(a *types.Application) error

ApplicationCreate makes new Applciation

func (*Fish) ApplicationFind

func (f *Fish) ApplicationFind(filter *string) (as []types.Application, err error)

ApplicationFind lists Applications by filter

func (*Fish) ApplicationGet

func (f *Fish) ApplicationGet(uid types.ApplicationUID) (a *types.Application, err error)

ApplicationGet returns Application by UID

func (*Fish) ApplicationIsAllocated

func (f *Fish) ApplicationIsAllocated(appUID types.ApplicationUID) (err error)

ApplicationIsAllocated returns if specific Application is allocated

func (*Fish) ApplicationListGetStatusNew

func (f *Fish) ApplicationListGetStatusNew() (as []types.Application, err error)

ApplicationListGetStatusNew returns new Applications

func (*Fish) ApplicationStateCreate

func (f *Fish) ApplicationStateCreate(as *types.ApplicationState) error

ApplicationStateCreate makes new ApplicationState

func (*Fish) ApplicationStateGet

func (f *Fish) ApplicationStateGet(uid types.ApplicationStateUID) (as *types.ApplicationState, err error)

ApplicationStateGet returns specific ApplicationState

func (*Fish) ApplicationStateGetByApplication

func (f *Fish) ApplicationStateGetByApplication(appUID types.ApplicationUID) (as *types.ApplicationState, err error)

ApplicationStateGetByApplication returns ApplicationState by ApplicationUID

func (*Fish) ApplicationStateIsActive

func (*Fish) ApplicationStateIsActive(status types.ApplicationStatus) bool

ApplicationStateIsActive returns false if Status in ERROR, DEALLOCATE or DEALLOCATED state

func (*Fish) ApplicationStateList

func (f *Fish) ApplicationStateList() (ass []types.ApplicationState, err error)

ApplicationStateList returns list of ApplicationStates

func (*Fish) ApplicationTaskCreate added in v0.6.0

func (f *Fish) ApplicationTaskCreate(at *types.ApplicationTask) error

ApplicationTaskCreate makes a new ApplicationTask

func (*Fish) ApplicationTaskFindByApplication added in v0.6.0

func (f *Fish) ApplicationTaskFindByApplication(uid types.ApplicationUID, filter *string) (at []types.ApplicationTask, err error)

ApplicationTaskFindByApplication allows to find all the ApplicationTasks by ApplciationUID

func (*Fish) ApplicationTaskGet added in v0.6.0

func (f *Fish) ApplicationTaskGet(uid types.ApplicationTaskUID) (at *types.ApplicationTask, err error)

ApplicationTaskGet returns the ApplicationTask by ApplicationTaskUID

func (*Fish) ApplicationTaskListByApplicationAndWhen added in v0.6.0

func (f *Fish) ApplicationTaskListByApplicationAndWhen(appUID types.ApplicationUID, when types.ApplicationStatus) (at []types.ApplicationTask, err error)

ApplicationTaskListByApplicationAndWhen returns list of ApplicationTasks by ApplicationUID and When it need to be executed

func (*Fish) ApplicationTaskSave added in v0.6.0

func (f *Fish) ApplicationTaskSave(at *types.ApplicationTask) error

ApplicationTaskSave stores the ApplicationTask

func (*Fish) Close

func (f *Fish) Close()

Close tells the node that the Fish execution need to be stopped

func (*Fish) GetLocationName

func (f *Fish) GetLocationName() types.LocationName

GetLocationName returns node location

func (*Fish) GetNode added in v0.7.0

func (f *Fish) GetNode() *types.Node

GetNode returns Fish node spec

func (*Fish) GetNodeUID

func (f *Fish) GetNodeUID() types.ApplicationUID

GetNodeUID returns node UID

func (*Fish) Init

func (f *Fish) Init() error

Init initializes the Fish node

func (*Fish) LabelCreate

func (f *Fish) LabelCreate(l *types.Label) error

LabelCreate makes new Label

func (*Fish) LabelDelete

func (f *Fish) LabelDelete(uid types.LabelUID) error

LabelDelete deletes the Label by UID

func (*Fish) LabelFind

func (f *Fish) LabelFind(filter *string) (labels []types.Label, err error)

LabelFind returns list of Labels that fits filter

func (*Fish) LabelGet

func (f *Fish) LabelGet(uid types.LabelUID) (label *types.Label, err error)

LabelGet returns Label by UID

func (*Fish) LocationCreate

func (f *Fish) LocationCreate(l *types.Location) error

LocationCreate makes new Location

func (*Fish) LocationDelete

func (f *Fish) LocationDelete(name types.LocationName) error

LocationDelete removes location

func (*Fish) LocationFind

func (f *Fish) LocationFind(filter *string) (ls []types.Location, err error)

LocationFind returns list of Locations fits filter

func (*Fish) LocationGet

func (f *Fish) LocationGet(name types.LocationName) (l *types.Location, err error)

LocationGet returns Location by it's unique name

func (*Fish) LocationSave

func (f *Fish) LocationSave(l *types.Location) error

LocationSave stores the Location

func (*Fish) MaintenanceSet added in v0.7.0

func (f *Fish) MaintenanceSet(value bool)

MaintenanceSet sets/unsets the maintenance mode which will not allow to accept the additional Applications

func (*Fish) NewUID

func (f *Fish) NewUID() uuid.UUID

NewUID Creates new UID with 6 starting bytes of Node UID as prefix

func (*Fish) NodeActiveList

func (f *Fish) NodeActiveList() (ns []types.Node, err error)

NodeActiveList lists all the nodes in the cluster

func (*Fish) NodeCreate

func (f *Fish) NodeCreate(n *types.Node) error

NodeCreate makes new Node

func (*Fish) NodeFind

func (f *Fish) NodeFind(filter *string) (ns []types.Node, err error)

NodeFind returns list of Nodes that fits filter

func (*Fish) NodeGet

func (f *Fish) NodeGet(name string) (node *types.Node, err error)

NodeGet returns Node by it's unique name

func (*Fish) NodePing

func (f *Fish) NodePing(node *types.Node) error

NodePing updates Node and shows that it's active

func (*Fish) NodeSave

func (f *Fish) NodeSave(node *types.Node) error

NodeSave stores Node

func (*Fish) ResourceAccessCreate added in v0.7.4

func (f *Fish) ResourceAccessCreate(r *types.ResourceAccess) error

ResourceAccessCreate makes new ResourceAccess

func (*Fish) ResourceAccessDelete added in v0.7.4

func (f *Fish) ResourceAccessDelete(uid types.ResourceAccessUID) error

ResourceAccessDelete removes ResourceAccess by UID

func (*Fish) ResourceAccessDeleteByResource added in v0.7.4

func (f *Fish) ResourceAccessDeleteByResource(resourceUID types.ResourceUID) error

ResourceAccessDeleteByResource removes ResourceAccess by ResourceUID

func (*Fish) ResourceAccessSingleUsePassword added in v0.7.4

func (f *Fish) ResourceAccessSingleUsePassword(username string, password string) (ra *types.ResourceAccess, err error)

ResourceAccessSingleUsePassword retrieves the password from the database *AND* deletes it. Users must issue another curl call to request a new access password.

func (*Fish) ResourceCreate

func (f *Fish) ResourceCreate(r *types.Resource) error

ResourceCreate makes new Resource

func (*Fish) ResourceDelete

func (f *Fish) ResourceDelete(uid types.ResourceUID) error

ResourceDelete removes Resource

func (*Fish) ResourceFind

func (f *Fish) ResourceFind(filter *string) (rs []types.Resource, err error)

ResourceFind lists Resources that fits filter

func (*Fish) ResourceGet

func (f *Fish) ResourceGet(uid types.ResourceUID) (res *types.Resource, err error)

ResourceGet returns Resource by it's UID

func (*Fish) ResourceGetByApplication

func (f *Fish) ResourceGetByApplication(appUID types.ApplicationUID) (res *types.Resource, err error)

ResourceGetByApplication returns Resource by ApplicationUID

func (*Fish) ResourceGetByIP

func (f *Fish) ResourceGetByIP(ip string) (res *types.Resource, err error)

ResourceGetByIP returns Resource by it's IP address

func (*Fish) ResourceListNode

func (f *Fish) ResourceListNode(nodeUID types.NodeUID) (rs []types.Resource, err error)

ResourceListNode returns list of resources for provided NodeUID

func (*Fish) ResourceSave

func (f *Fish) ResourceSave(res *types.Resource) error

ResourceSave stores Resource

func (*Fish) ResourceServiceMappingByApplicationAndDest added in v0.7.5

func (f *Fish) ResourceServiceMappingByApplicationAndDest(appUID types.ApplicationUID, dest string) string

ResourceServiceMappingByApplicationAndDest is trying to find the ResourceServiceMapping record with Application and Location if possible. The application in priority, location - secondary priority, if no such records found - default will be used.

func (*Fish) ServiceMappingCreate

func (f *Fish) ServiceMappingCreate(sm *types.ServiceMapping) error

ServiceMappingCreate makes new ServiceMapping

func (*Fish) ServiceMappingDelete

func (f *Fish) ServiceMappingDelete(uid types.ServiceMappingUID) error

ServiceMappingDelete removes ServiceMapping

func (*Fish) ServiceMappingFind

func (f *Fish) ServiceMappingFind(filter *string) (sms []types.ServiceMapping, err error)

ServiceMappingFind returns list of ServiceMappings that fits the filter

func (*Fish) ServiceMappingGet

func (f *Fish) ServiceMappingGet(uid types.ServiceMappingUID) (sm *types.ServiceMapping, err error)

ServiceMappingGet returns ServiceMapping by UID

func (*Fish) ServiceMappingSave

func (f *Fish) ServiceMappingSave(sm *types.ServiceMapping) error

ServiceMappingSave stores ServiceMapping

func (*Fish) ShutdownDelaySet added in v0.7.0

func (f *Fish) ShutdownDelaySet(delay time.Duration)

ShutdownDelaySet set of how much time to wait before executing the node shutdown operation

func (*Fish) ShutdownSet added in v0.7.0

func (f *Fish) ShutdownSet(value bool)

ShutdownSet tells node it need to execute graceful shutdown operation

func (*Fish) UserAuth

func (f *Fish) UserAuth(name string, password string) *types.User

UserAuth returns User if name and password are correct

func (*Fish) UserCreate

func (f *Fish) UserCreate(u *types.User) error

UserCreate makes new User

func (*Fish) UserDelete

func (f *Fish) UserDelete(name string) error

UserDelete removes User

func (*Fish) UserFind

func (f *Fish) UserFind(filter *string) (us []types.User, err error)

UserFind returns list of users that fits the filter

func (*Fish) UserGet

func (f *Fish) UserGet(name string) (u *types.User, err error)

UserGet returns User by unique name

func (*Fish) UserNew

func (f *Fish) UserNew(name string, password string) (string, *types.User, error)

UserNew makes new User

func (*Fish) UserSave

func (f *Fish) UserSave(u *types.User) error

UserSave stores User

func (*Fish) VoteCreate

func (f *Fish) VoteCreate(v *types.Vote) error

VoteCreate makes new Vote

func (*Fish) VoteCurrentRoundGet

func (f *Fish) VoteCurrentRoundGet(appUID types.ApplicationUID) uint16

VoteCurrentRoundGet returns the current round of voting based on the known Votes

func (*Fish) VoteFind

func (f *Fish) VoteFind(filter *string) (vs []types.Vote, err error)

VoteFind returns list of Votes that fits filter

func (*Fish) VoteGet

func (f *Fish) VoteGet(uid types.VoteUID) (v *types.Vote, err error)

VoteGet returns Vote by it's UID

func (*Fish) VoteGetElectionWinner

func (f *Fish) VoteGetElectionWinner(appUID types.ApplicationUID, round uint16) (v *types.Vote, err error)

VoteGetElectionWinner returns Vote that won the election

func (*Fish) VoteGetNodeApplication

func (f *Fish) VoteGetNodeApplication(nodeUID types.NodeUID, appUID types.ApplicationUID) (v *types.Vote, err error)

VoteGetNodeApplication returns latest Vote by Node and Application

func (*Fish) VoteListGetApplicationRound

func (f *Fish) VoteListGetApplicationRound(appUID types.ApplicationUID, round uint16) (vs []types.Vote, err error)

VoteListGetApplicationRound returns Votes for the specified round

Jump to

Keyboard shortcuts

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