castai

package
v0.0.0-...-dc8362b Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelNodeID               = "provisioner.cast.ai/node-id"
	LabelManagedBy            = "provisioner.cast.ai/managed-by"
	LabelValueManagedByCASTAI = "cast.ai"

	// UnknownActionType is returned by ClusterAction.GetType when the action is not recognized.
	UnknownActionType = "Unknown"
)

Variables

This section is empty.

Functions

func NewRestyClient

func NewRestyClient(url, key, ca string, level logrus.Level, binVersion *config.ClusterControllerVersion, defaultTimeout time.Duration) (*resty.Client, error)

NewRestyClient configures a default instance of the resty.Client used to do HTTP requests.

Types

type AckClusterActionRequest

type AckClusterActionRequest struct {
	Error *string `json:"error"`
}

type ActionChartRollback

type ActionChartRollback struct {
	Namespace   string `json:"namespace"`
	ReleaseName string `json:"releaseName"`
	Version     string `json:"version"`
}

type ActionChartUninstall

type ActionChartUninstall struct {
	Namespace   string `json:"namespace"`
	ReleaseName string `json:"releaseName"`
}

type ActionChartUpsert

type ActionChartUpsert struct {
	Namespace            string            `json:"namespace"`
	ReleaseName          string            `json:"releaseName"`
	ValuesOverrides      map[string]string `json:"valuesOverrides,omitempty"`
	ChartSource          ChartSource       `json:"chartSource"`
	CreateNamespace      bool              `json:"createNamespace"`
	ResetThenReuseValues bool              `json:"resetThenReuseValues,omitempty"`
}

type ActionCheckNodeDeleted

type ActionCheckNodeDeleted struct {
	NodeName string `json:"nodeName"`
	NodeID   string `json:"nodeId"`
}

type ActionCheckNodeStatus

type ActionCheckNodeStatus struct {
	NodeName           string                       `json:"nodeName"`
	NodeID             string                       `json:"nodeId"`
	NodeStatus         ActionCheckNodeStatus_Status `json:"nodeStatus,omitempty"`
	WaitTimeoutSeconds *int32                       `json:"waitTimeoutSeconds,omitempty"`
}

type ActionCheckNodeStatus_Status

type ActionCheckNodeStatus_Status string
const (
	ActionCheckNodeStatus_READY   ActionCheckNodeStatus_Status = "NodeStatus_READY"
	ActionCheckNodeStatus_DELETED ActionCheckNodeStatus_Status = "NodeStatus_DELETED"
)

type ActionCreate

type ActionCreate struct {
	GroupVersionResource `json:",inline"`
	Object               map[string]interface{} `json:"object,omitempty"`
}

type ActionCreateEvent

type ActionCreateEvent struct {
	Reporter  string             `json:"reportingComponent"`
	ObjectRef v1.ObjectReference `json:"objectReference"`
	EventTime time.Time          `json:"eventTime"`
	EventType string             `json:"eventType"`
	Reason    string             `json:"reason"`
	Action    string             `json:"action"`
	Message   string             `json:"message"`
}

type ActionDelete

type ActionDelete struct {
	ID ObjectID `json:"id"`
}

type ActionDeleteNode

type ActionDeleteNode struct {
	NodeName string `json:"nodeName"`
	NodeID   string `json:"nodeId"`
}

type ActionDisconnectCluster

type ActionDisconnectCluster struct{}

type ActionDrainNode

type ActionDrainNode struct {
	NodeName            string `json:"nodeName"`
	NodeID              string `json:"nodeId"`
	DrainTimeoutSeconds int    `json:"drainTimeoutSeconds"`
	Force               bool   `json:"force"`
}

type ActionEvictPod

type ActionEvictPod struct {
	Namespace string `json:"namespace"`
	PodName   string `json:"podName"`
}

type ActionPatch

type ActionPatch struct {
	ID        ObjectID `json:"id"`
	PatchType string   `json:"patchType"`
	Patch     string   `json:"patch"`
}

type ActionPatchNode

type ActionPatchNode struct {
	NodeName      string            `json:"nodeName"`
	NodeID        string            `json:"nodeId"`
	Labels        map[string]string `json:"labels"`
	Taints        []NodeTaint       `json:"taints"`
	Annotations   map[string]string `json:"annotations"`
	Unschedulable *bool             `json:"unschedulable"`
	// Capacity allows advertising extended resources for a Node.
	// More info: https://kubernetes.io/docs/tasks/administer-cluster/extended-resource-node/
	Capacity v1.ResourceList `json:"capacity"`
}

type CastAIClient

type CastAIClient interface {
	GetActions(ctx context.Context, k8sVersion string) ([]*ClusterAction, error)
	AckAction(ctx context.Context, actionID string, req *AckClusterActionRequest) error
	SendLog(ctx context.Context, e *LogEntry) error
}

CastAIClient lists functions used by actions package.

type ChartSource

type ChartSource struct {
	RepoURL string `json:"repoUrl"`
	Name    string `json:"name"`
	Version string `json:"version"`
}

func (*ChartSource) Validate

func (c *ChartSource) Validate() error

type Client

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

Client talks to Cast AI. It can poll and acknowledge actions and also inject logs.

func NewClient

func NewClient(log *logrus.Logger, rest *resty.Client, clusterID string) *Client

NewClient returns new Client for communicating with Cast AI.

func (*Client) AckAction

func (c *Client) AckAction(ctx context.Context, actionID string, req *AckClusterActionRequest) error

func (*Client) GetActions

func (c *Client) GetActions(ctx context.Context, k8sVersion string) ([]*ClusterAction, error)

func (*Client) SendLog

func (c *Client) SendLog(ctx context.Context, e *LogEntry) error

type ClusterAction

type ClusterAction struct {
	ID                      string                   `json:"id"`
	ActionDeleteNode        *ActionDeleteNode        `json:"actionDeleteNode,omitempty"`
	ActionDrainNode         *ActionDrainNode         `json:"actionDrainNode,omitempty"`
	ActionPatchNode         *ActionPatchNode         `json:"actionPatchNode,omitempty"`
	ActionCreateEvent       *ActionCreateEvent       `json:"actionCreateEvent,omitempty"`
	ActionChartUpsert       *ActionChartUpsert       `json:"actionChartUpsert,omitempty"`
	ActionChartUninstall    *ActionChartUninstall    `json:"actionChartUninstall,omitempty"`
	ActionChartRollback     *ActionChartRollback     `json:"actionChartRollback,omitempty"`
	ActionDisconnectCluster *ActionDisconnectCluster `json:"actionDisconnectCluster,omitempty"`
	ActionCheckNodeDeleted  *ActionCheckNodeDeleted  `json:"actionCheckNodeDeleted,omitempty"`
	ActionCheckNodeStatus   *ActionCheckNodeStatus   `json:"actionCheckNodeStatus,omitempty"`
	ActionEvictPod          *ActionEvictPod          `json:"actionEvictPod,omitempty"`
	ActionPatch             *ActionPatch             `json:"actionPatch,omitempty"`
	ActionCreate            *ActionCreate            `json:"actionCreate,omitempty"`
	ActionDelete            *ActionDelete            `json:"actionDelete,omitempty"`
	CreatedAt               time.Time                `json:"createdAt"`
	DoneAt                  *time.Time               `json:"doneAt,omitempty"`
	Error                   *string                  `json:"error,omitempty"`
}

func (*ClusterAction) Data

func (c *ClusterAction) Data() interface{}

func (*ClusterAction) GetType

func (c *ClusterAction) GetType() string

GetType tries to deduct the type of the action based on its data. In case this fails, UnknownActionType is returned.

func (*ClusterAction) IsValid

func (c *ClusterAction) IsValid() bool

IsValid checks if the action is OK to use. If this value is nil, most likely current version of cluster controller does not know about the action type and cannot execute it. It can also be a case of invalid data from server, but we cannot distinguish between the two at the moment.

type GetClusterActionsResponse

type GetClusterActionsResponse struct {
	Items []*ClusterAction `json:"items"`
}

type GroupVersionResource

type GroupVersionResource struct {
	Group    string `json:"group"`
	Version  string `json:"version"`
	Resource string `json:"resource"`
}

func (GroupVersionResource) String

func (r GroupVersionResource) String() string

type LogEntry

type LogEntry struct {
	Level   string        `json:"level"`
	Time    time.Time     `json:"time"`
	Message string        `json:"message"`
	Fields  logrus.Fields `json:"fields"`
}

type LogEvent

type LogEvent struct {
	Level   string        `json:"level"`
	Time    time.Time     `json:"time"`
	Message string        `json:"message"`
	Fields  logrus.Fields `json:"fields"`
}

type NodeTaint

type NodeTaint struct {
	Effect string `json:"effect"`
	Key    string `json:"key"`
	Value  string `json:"value"`
}

type ObjectID

type ObjectID struct {
	GroupVersionResource `json:",inline"`
	Namespace            *string `json:"namespace"`
	Name                 string  `json:"name"`
}

Directories

Path Synopsis
Package mock_castai is a generated GoMock package.
Package mock_castai is a generated GoMock package.

Jump to

Keyboard shortcuts

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