server

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 31 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigK8s

func ConfigK8s(ctx context.Context, namespace string, name string) (values map[string]string, err kv.Error)

ConfigK8s is used to pull the values from a named config map in k8s

This function will return an empty map and and error value on failure.

func InitiateK8s

func InitiateK8s(ctx context.Context, namespace string, cfgMap string, readyC chan struct{}, staleMsg time.Duration, logger *log.Logger, errorC chan kv.Error)

initiateK8s runs until either ctx is Done or the listener is running successfully

func IsAliveK8s

func IsAliveK8s() (err kv.Error)

IsAliveK8s is used to extract any kv.in the state of the k8s client api connection.

A nil returned indicates k8s is working and in use, otherwise a descriptive error is returned.

func K8sUpdateSecret

func K8sUpdateSecret(config string, secret string, content []byte) (err kv.Error)

func ListenK8s

func ListenK8s(ctx context.Context, namespace string, globalMap string, podMap string, updateC chan<- K8sStateUpdate, errC chan<- kv.Error, logger *log.Logger) (err kv.Error)

ListenK8s will register a listener to watch for pod specific configMaps in k8s and will relay state changes to a channel, the global state map should exist at the bare minimum. A state change in either map superseded any previous state.

This is a blocking function that will return either upon an error in API calls to the cluster API or when the ctx is Done().

func ListenK8sConfigMaps added in v0.0.3

func ListenK8sConfigMaps(ctx context.Context, namespace string, updateC chan<- K8sConfigUpdate, errC chan<- kv.Error, logger *log.Logger) (err kv.Error)

ListenK8sConfigMaps will register a listener to watch for k8s config maps updates in a specified namespace and will relay these changes to a channel.

This is a blocking function that will return either upon an error in API calls to the cluster API or when the ctx is Done().

func MonitorK8s

func MonitorK8s(ctx context.Context, errC chan<- kv.Error)

MonitorK8s is used to send appropriate errors into an error reporting channel on a regular basis if the k8s connectivity state changes

func StartTelemetry

func StartTelemetry(ctx context.Context, logger *log.Logger, nodeName string, serviceName string, apiKey string, dataset string) (newCtx context.Context, err kv.Error)

Types

type ConfigListeners added in v0.0.3

type ConfigListeners struct {
	Master chan K8sConfigUpdate

	sync.Mutex
	// contains filtered or unexported fields
}

ConfigListeners are used to handle the broadcasting of cluster events when Kubernetes is being used

func K8sConfigUpdates added in v0.0.3

func K8sConfigUpdates() (l *ConfigListeners)

func NewConfigBroadcast added in v0.0.3

func NewConfigBroadcast(ctx context.Context, errorC chan<- kv.Error) (l *ConfigListeners)

NewConfigBroadcast is used to instantiate a Kubernetes config maps update broadcaster

func (*ConfigListeners) Add added in v0.0.3

func (l *ConfigListeners) Add(listen chan<- K8sConfigUpdate) (id xid.ID, err kv.Error)

Add is used when a running thread wishes to add a channel to the broadcaster on which Kubernetes config maps updates will be received

func (*ConfigListeners) Delete added in v0.0.3

func (l *ConfigListeners) Delete(id xid.ID)

Delete is used when a running thread wishes to drop a channel from the broadcaster on which Kubernetes events will be received

type K8sConfigUpdate added in v0.0.3

type K8sConfigUpdate struct {
	NameSpace string
	Name      string
	State     map[string]string
}

K8sConfigUpdate encapsulates an update for some config map in the scope of server run-time environment.

type K8sStateUpdate

type K8sStateUpdate struct {
	Name  string
	State types.K8sState
}

K8sStateUpdate encapsulates the known kubernetes state within which the server finds itself.

type Resource

type Resource struct {
	Cpus     uint   `json:"cpus"`
	Gpus     uint   `json:"gpus"`
	Hdd      string `json:"hdd"`
	Ram      string `json:"ram"`
	GpuMem   string `json:"gpuMem"`
	GpuCount uint   `json:"gpuCount"`
}

Resource describes the needed resources for a runner task in a data structure that can be marshalled as json

func (*Resource) Clone

func (rsc *Resource) Clone() (r *Resource)

Clone will deep copy a resource and return the copy

func (*Resource) Fit

func (rsc *Resource) Fit(r *Resource) (didFit bool, err kv.Error)

Fit determines is a supplied resource description acting as a request can be satisfied by the receiver resource

Asks the question does rsc fit into r

func (Resource) String

func (rsc Resource) String() (serialized string)

type Resources

type Resources struct{}

Resources is a receiver for resource related methods used to describe machine level capabilities

func (*Resources) FetchMachineResources

func (*Resources) FetchMachineResources() (rsc *Resource)

FetchMachineResources extracts the current system state in terms of memory etc and coverts this into the resource specification used to pass machine characteristics around.

Jump to

Keyboard shortcuts

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