infra

package
v0.12.13 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Overview

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Package infra is to manage multi-cloud infra

Index

Constants

This section is empty.

Variables

View Source
var GlobalAgent = &NodeStatusAgent{
	workerCh: make(chan StatusEntry, 200),
	workers:  20,
}

GlobalAgent is the process-wide NodeStatusAgent singleton.

Functions

func AddCommandStatusInfo added in v0.11.10

func AddCommandStatusInfo(nsId, infraId, nodeId, xRequestId, commandRequested, commandExecuted string) (int, error)

AddCommandStatusInfo adds a new command status record to VM's command history

func AddNLBNodes added in v0.12.6

func AddNLBNodes(nsId string, infraId string, resourceId string, u *model.NLBAddRemoveNodeReq) (model.NLBInfo, error)

AddNLBNodes accepts Node addition request, adds Node to NLB, and returns an updated TB NLB object

func AnalyzeProvisioningRisk added in v0.11.3

func AnalyzeProvisioningRisk(specId string, cspImageName string) (riskLevel string, riskMessage string, err error)

AnalyzeProvisioningRisk analyzes the risk of provisioning failure based on historical data

func AnalyzeProvisioningRiskDetailed added in v0.11.3

func AnalyzeProvisioningRiskDetailed(specId string, cspImageName string) (*model.RiskAnalysis, error)

AnalyzeProvisioningRiskDetailed provides comprehensive risk analysis with separate spec and image risk assessment

func AttachDetachDataDisk

func AttachDetachDataDisk(nsId string, infraId string, nodeId string, command string, dataDiskId string, force bool) (model.NodeInfo, error)

AttachDetachDataDisk is func to attach/detach DataDisk to/from Node

func BenchmarkAction

func BenchmarkAction(nsId string, infraId string, action string, option string) (model.BenchmarkInfoArray, error)

BenchmarkAction is func to action Benchmark

func BuildAgnosticImage added in v0.11.14

func BuildAgnosticImage(nsId string, req model.BuildAgnosticImageReq) (model.BuildAgnosticImageResult, error)

BuildAgnosticImage creates an Infra, executes post commands, creates snapshots, and optionally cleans up This is a complete workflow for building agnostic (CSP-independent) custom images

func BuildLatencyOrderByClause added in v0.11.9

func BuildLatencyOrderByClause(param *[]model.ParameterKeyVal) (string, error)

BuildLatencyOrderByClause generates ORDER BY clause for latency-based sorting

func BuildLocationOrderByClause added in v0.11.9

func BuildLocationOrderByClause(param *[]model.ParameterKeyVal) (string, error)

BuildLocationOrderByClause generates ORDER BY clause for location-based sorting

func CallGetMonitoringAsync

func CallGetMonitoringAsync(wg *sync.WaitGroup, nsID string, infraID string, nodeID string, nodeIP string, method string, metric string, cmd string, returnResult *[]model.MonResultSimple)

CallGetMonitoringAsync makes asynchronous HTTP call to CB-Dragonfly for monitoring data and appends the result to the provided result array

func CallMilkyway

func CallMilkyway(wg *sync.WaitGroup, nodeList []string, nsId string, infraId string, nodeId string, nodeIp string, action string, option string, results *model.BenchmarkInfoArray)

CallMilkyway is func to call milkyway agents

func CallMonitoringAsync

func CallMonitoringAsync(wg *sync.WaitGroup, nsID string, infraID string, infraServiceType string, nodeID string, givenUserName string, method string, cmd string, returnResult *[]model.SshCmdResult)

CallMonitoringAsync is func to call CB-Dragonfly monitoring framework

func CancelActiveCommandsForNode added in v0.12.6

func CancelActiveCommandsForNode(nodeId string) int

CancelActiveCommandsForNode cancels all active command executions for a specific Node This is called when a Node is being terminated to immediately stop SSH sessions It also updates the command status to Cancelled in kvstore Returns the number of cancelled executions

func CancelInfraCommand added in v0.12.6

func CancelInfraCommand(nsId, infraId, nodeId, xRequestId string, index int, reason string) (*model.CancelTaskResponse, error)

CancelInfraCommand cancels a running command by updating its status to Cancelled It also attempts to cancel the in-memory task if still running If nodeId is provided, cancels only that specific VM's command If nodeId is empty, cancels all VMs with the given xRequestId

func CheckAllowedTransition

func CheckAllowedTransition(nsId string, infraId string, nodeId model.OptionalParameter, action string) error

CheckAllowedTransition is func to check status transition is acceptable

func CheckConnectivity

func CheckConnectivity(host string, port string) error

CheckConnectivity func checks if given port is open and ready

func CheckDragonflyEndpoint

func CheckDragonflyEndpoint() error

Module for checking CB-Dragonfly endpoint (call get config)

func CheckInfra added in v0.12.6

func CheckInfra(nsId string, infraId string) (bool, error)

CheckInfra func is to check given infraId is duplicated with existing

func CheckInfraDynamicReq added in v0.12.6

CheckInfraDynamicReq is func to check request info to create Infra obeject and deploy requested VMs in a dynamic way

func CheckInfraPolicy added in v0.12.6

func CheckInfraPolicy(nsId string, infraId string) (bool, error)

func CheckK8sClusterDynamicReq added in v0.10.0

CheckK8sClusterDynamicReq is func to check request info to create K8sCluster obeject and deploy requested Nodes in a dynamic way

func CheckNLB

func CheckNLB(nsId string, infraId string, resourceId string) (bool, error)

CheckNLB returns the existence of the TB NLB object in bool form.

func CheckNode added in v0.12.6

func CheckNode(nsId string, infraId string, nodeId string) (bool, error)

func CheckNodeGroup added in v0.12.6

func CheckNodeGroup(nsId string, infraId string, nodeGroupId string) (bool, error)

CheckNodeGroup func is to check given nodeGroupId is duplicated with existing

func CheckVpnHealth added in v0.12.6

func CheckVpnHealth(ctx context.Context, nsId, infraId, vpnId string, req *model.VpnHealthCheckRequest) (model.VpnHealthCheckResponse, error)

CheckVpnHealth performs a bidirectional ping-based health check on a site-to-site VPN by finding Nodes in the Infra that match the VPN's two sites and running ping tests in both directions.

func CleanupCommandLogSession added in v0.12.3

func CleanupCommandLogSession(xRequestId string)

CleanupCommandLogSession forces cleanup of a session (e.g., on server shutdown)

func CleanupCorruptedProvisioningLogs added in v0.11.3

func CleanupCorruptedProvisioningLogs() error

func CleanupInterruptedCommands added in v0.12.3

func CleanupInterruptedCommands() error

CleanupInterruptedCommands marks all "Handling" or "Queued" commands as "Interrupted" This should be called during system startup to handle commands that were interrupted by a system restart while SSH sessions were still active

func ClearAllCommandStatusInfo added in v0.11.10

func ClearAllCommandStatusInfo(nsId, infraId, nodeId string) (int, error)

ClearAllCommandStatusInfo deletes all command status records for a VM

func ControlInfraAsync added in v0.12.6

func ControlInfraAsync(nsId string, infraId string, action string, force bool) error

ControlInfraAsync is func to control Infra async

func ControlNodeAsync added in v0.12.6

func ControlNodeAsync(wg *sync.WaitGroup, nsId string, infraId string, nodeId string, action string, results chan<- model.ControlNodeResult)

ControlNodeAsync is func to control VM async

func ControlNodesInParallel added in v0.12.6

func ControlNodesInParallel(nsId, infraId string, nodeList []string, action string, force bool) error

ControlNodesInParallel controls VMs with hierarchical rate limiting Level 1: CSPs are processed in parallel Level 2: Within each CSP, regions are processed with semaphore (maxConcurrentRegionsPerCSP) Level 3: Within each region, VMs are processed with semaphore (maxConcurrentNodesPerRegion)

func ConvertInfraInfoToInfraStatusInfo added in v0.12.6

func ConvertInfraInfoToInfraStatusInfo(infraInfo model.InfraInfo) model.InfraStatusInfo

ensureNodeStatusInfoComplete ensures all Nodes from NodeInfo are represented in InfraStatus.Node This handles cases where Node status fetch might have failed or Node is newly created ConvertInfraInfoToInfraStatusInfo converts InfraInfo to InfraStatusInfo (partial conversion for basic fields)

func ConvertNodeInfoFieldsToNodeStatusInfo added in v0.12.6

func ConvertNodeInfoFieldsToNodeStatusInfo(nodeStatus *model.NodeStatusInfo, nodeInfo model.NodeInfo)

ConvertNodeInfoFieldsToNodeStatusInfo converts NodeInfo fields into existing NodeStatusInfo NodeInfo is considered the trusted source, so all relevant fields are converted

func ConvertNodeInfoFieldsToNodeStatusInfoList added in v0.12.6

func ConvertNodeInfoFieldsToNodeStatusInfoList(nodeStatusList []model.NodeStatusInfo, nodeInfoList []model.NodeInfo)

ConvertNodeInfoFieldsToNodeStatusInfoList converts NodeInfo fields into corresponding NodeStatusInfo list

func ConvertNodeInfoListToNodeStatusInfoList added in v0.12.6

func ConvertNodeInfoListToNodeStatusInfoList(nodeInfoList []model.NodeInfo) []model.NodeStatusInfo

ConvertNodeInfoListToNodeStatusInfoList converts a slice of NodeInfo to NodeStatusInfo for Infra status operations

func ConvertNodeInfoToNodeStatusInfo added in v0.12.6

func ConvertNodeInfoToNodeStatusInfo(nodeInfo model.NodeInfo) model.NodeStatusInfo

ConvertNodeInfoToNodeStatusInfo converts NodeInfo to NodeStatusInfo for Infra status operations

func CoreGetBenchmark

func CoreGetBenchmark(nsId string, infraId string, action string, host string) (*model.BenchmarkInfoArray, error)

CoreGetBenchmark is func to get Benchmark

func CreateInfra added in v0.12.6

func CreateInfra(ctx context.Context, nsId string, req *model.InfraReq, option string, isReqFromDynamic bool) (*model.InfraInfo, error)

CreateInfra is func to create Infra object and deploy requested VMs (register CSP native VM with option=register)

func CreateInfraDynamic added in v0.12.6

func CreateInfraDynamic(ctx context.Context, nsId string, req *model.InfraDynamicReq, deployOption string) (*model.InfraInfo, error)

CreateInfraDynamic is func to create Infra obeject and deploy requested VMs in a dynamic way

func CreateInfraDynamicFromTemplate added in v0.12.6

func CreateInfraDynamicFromTemplate(ctx context.Context, nsId string, templateId string, applyReq *model.TemplateApplyReq, option string) (*model.InfraInfo, error)

CreateInfraDynamicFromTemplate creates an Infra from a template with overrides

func CreateInfraGroupNode added in v0.12.6

func CreateInfraGroupNode(ctx context.Context, nsId string, infraId string, nodeRequest *model.CreateNodeGroupReq, newNodeGroup bool) (*model.InfraInfo, error)

CreateInfraGroupNode is func to create Infra groupNode

func CreateInfraNodeGroupDynamic added in v0.12.6

func CreateInfraNodeGroupDynamic(ctx context.Context, nsId string, infraId string, req *model.CreateNodeGroupDynamicReq) (*model.InfraInfo, error)

CreateInfraNodeGroupDynamic is func to create requested VM in a dynamic way and add it to Infra

func CreateInfraPolicy added in v0.12.6

func CreateInfraPolicy(nsId string, infraId string, u *model.InfraPolicyReq) (model.InfraPolicyInfo, error)

CreateInfraPolicy create model.InfraPolicyInfo object in DB according to user's requirements.

func CreateInfraSnapshot added in v0.12.6

func CreateInfraSnapshot(nsId string, infraId string, snapshotReq model.SnapshotReq) (model.InfraSnapshotResult, error)

CreateInfraSnapshot creates snapshots for the first running Node in each nodegroup of an Infra in parallel Snapshots are created with provider-specific semaphores to safely limit concurrent requests per CSP

func CreateK8sClusterDynamic added in v0.10.0

func CreateK8sClusterDynamic(ctx context.Context, nsId string, dReq *model.K8sClusterDynamicReq, deployOption string, skipVersionCheck bool) (*model.K8sClusterInfo, error)

CreateK8sClusterDynamic is func to create K8sCluster obeject and deploy requested K8sCluster and NodeGroup in a dynamic way

func CreateK8sMultiClusterDynamic added in v0.11.22

func CreateK8sMultiClusterDynamic(ctx context.Context, nsId string, multiReq *model.K8sMultiClusterDynamicReq, deployOption string, skipVersionCheck bool) (*model.K8sMultiClusterInfo, error)

CreateK8sMultiClusterDynamic creates multiple K8sClusters in parallel

func CreateK8sNodeGroupDynamic added in v0.10.2

func CreateK8sNodeGroupDynamic(ctx context.Context, nsId string, k8sClusterId string, dReq *model.K8sNodeGroupDynamicReq) (*model.K8sClusterInfo, error)

CreateK8sNodeGroupDynamic is func to create K8sNodeGroup obeject and deploy requested K8sNodeGroup in a dynamic way

func CreateMcSwNlb

func CreateMcSwNlb(nsId string, infraId string, req *model.NLBReq, option string) (model.McNlbInfo, error)

CreateMcSwNlb func create a special purpose Infra for NLB and depoly and setting SW NLB

func CreateNLB

func CreateNLB(nsId string, infraId string, u *model.NLBReq, option string) (model.NLBInfo, error)

CreateNLB accepts nlb creation request, creates and returns an TB nlb object

func CreateNode added in v0.12.6

func CreateNode(ctx context.Context, wg *sync.WaitGroup, nsId string, infraId string, nodeInfoData *model.NodeInfo, option string) error

CreateNode is func to create VM (option = "register" for register existing VM)

func CreateNodeGroupReqStructLevelValidation added in v0.12.6

func CreateNodeGroupReqStructLevelValidation(sl validator.StructLevel)

CreateNodeGroupReqStructLevelValidation is func to validate fields in model.CreateNodeGroupReqStruct

func CreateNodeObject added in v0.12.6

func CreateNodeObject(wg *sync.WaitGroup, nsId string, infraId string, nodeInfoData *model.NodeInfo) error

CreateNodeObject is func to add VM to Infra

func CreateNodeSnapshot added in v0.12.6

func CreateNodeSnapshot(nsId string, infraId string, nodeId string, snapshotReq model.SnapshotReq) (model.ImageInfo, error)

CreateNodeSnapshot is func to create Node snapshot

func CreateNodesInParallel added in v0.12.6

func CreateNodesInParallel(ctx context.Context, nsId, infraId string, nodeInfoList []*model.NodeInfo, option string) error

CreateNodesInParallel creates VMs with hierarchical rate limiting Level 1: CSPs are processed in parallel Level 2: Within each CSP, regions are processed with semaphore (maxConcurrentRegionsPerCSP) Level 3: Within each region, VMs are processed with semaphore (maxConcurrentNodesPerRegion)

func CreateSystemInfraDynamic added in v0.12.6

func CreateSystemInfraDynamic(option string) (*model.InfraInfo, error)

CreateSystemInfraDynamic is func to create Infra obeject and deploy requested VMs in a dynamic way

func DFMonAgentInstallReqStructLevelValidation

func DFMonAgentInstallReqStructLevelValidation(sl validator.StructLevel)

func DelAllInfra added in v0.12.6

func DelAllInfra(nsId string, option string) (string, error)

DelAllInfra is func to delete all Infra objects in parallel

func DelAllInfraPolicy added in v0.12.6

func DelAllInfraPolicy(nsId string) (string, error)

DelAllInfraPolicy deletes all model.InfraPolicyInfo objects.

func DelAllNLB

func DelAllNLB(nsId string, infraId string, subString string, forceFlag string) (model.IdList, error)

DelAllNLB deletes all TB NLB object of given nsId

func DelInfra added in v0.12.6

func DelInfra(nsId string, infraId string, option string) (model.IdList, error)

DelInfra is func to delete Infra object

func DelInfraNode added in v0.12.6

func DelInfraNode(nsId string, infraId string, nodeId string, option string) error

DelInfraNode is func to delete Node object

func DelInfraPolicy added in v0.12.6

func DelInfraPolicy(nsId string, infraId string) error

DelInfraPolicy deletes model.InfraPolicyInfo object by infraId.

func DelNLB

func DelNLB(nsId string, infraId string, resourceId string, forceFlag string) error

DelNLB deletes the TB NLB object

func DeleteCommandStatusInfo added in v0.11.10

func DeleteCommandStatusInfo(nsId, infraId, nodeId string, index int) error

DeleteCommandStatusInfo deletes a specific command status record

func DeleteCommandStatusInfoByCriteria added in v0.11.10

func DeleteCommandStatusInfoByCriteria(nsId, infraId, nodeId string, filter *model.CommandStatusFilter) (int, error)

DeleteCommandStatusInfoByCriteria deletes multiple command status records by criteria

func DeleteProvisioningLog added in v0.11.3

func DeleteProvisioningLog(specId string) error

DeleteProvisioningLog deletes provisioning log for a specific spec ID

func DeregisterInfraNode added in v0.12.6

func DeregisterInfraNode(nsId string, infraId string, nodeId string) error

DeregisterInfraNode deregisters Node from Spider and TB without deleting the actual CSP resource This function only removes the Node mapping from Spider and TB internal storage The actual CSP Node resource remains intact and can be re-registered later

func DownloadFileFromInfraNode added in v0.12.6

func DownloadFileFromInfraNode(nsId string, infraId string, nodeId string, sourcePath string) ([]byte, string, error)

DownloadFileFromInfraNode downloads a file from a specific Node in Infra by SCP through bastion hosts

func ExtractAndCreateTemplate added in v0.12.3

func ExtractAndCreateTemplate(nsId string, infraId string, templateName string) (model.InfraDynamicTemplateInfo, error)

ExtractAndCreateTemplate extracts an Infra configuration and creates a template from it

func ExtractInfraDynamicReqFromInfraInfo added in v0.12.6

func ExtractInfraDynamicReqFromInfraInfo(nsId string, infraId string) (*model.InfraDynamicReq, error)

ExtractInfraDynamicReqFromInfraInfo reconstructs an InfraDynamicReq from a running Infra's info. This returns a dynamic creation request (resources like vNet, subnet, SG, sshKey are auto-created) so that users can easily clone or recreate a similar Infra configuration.

func FetchNodeStatus added in v0.12.6

func FetchNodeStatus(nsId string, infraId string, nodeId string) (model.NodeStatusInfo, error)

FetchNodeStatus is func to fetch Node status (call to CSPs)

func FindTbNodeByCspId added in v0.12.6

func FindTbNodeByCspId(nsId string, infraId string, nodeCspResourceId string) (model.NodeInfo, error)

func GenNLBKey

func GenNLBKey(nsId string, infraId string, resourceId string) string

GenNLBKey is func to generate a key from NLB id

func GetAllInfraPolicyObject added in v0.12.6

func GetAllInfraPolicyObject(nsId string) ([]model.InfraPolicyInfo, error)

GetAllInfraPolicyObject returns all model.InfraPolicyInfo objects.

func GetAssetsSummary added in v0.12.6

func GetAssetsSummary(nsId string) (model.AssetsSummaryResponse, error)

GetAssetsSummary returns provider-level summary of spec/image assets for a namespace.

func GetAvailableDataDisks

func GetAvailableDataDisks(nsId string, infraId string, nodeId string, option string) (any, error)

func GetBastionNodes

func GetBastionNodes(nsId string, infraId string, targetNodeId string) ([]model.BastionNode, error)

GetBastionNodes func retrieves bastion nodes for a given VM

func GetCommandStatusInfo added in v0.11.10

func GetCommandStatusInfo(nsId, infraId, nodeId string, index int) (*model.CommandStatusInfo, error)

GetCommandStatusInfo retrieves a specific command status record

func GetHandlingCommandCount added in v0.11.10

func GetHandlingCommandCount(nsId, infraId, nodeId string) (int, error)

GetHandlingCommandCount returns the count of currently handling commands for a VM This function is optimized for frequent polling and avoids unnecessary processing

func GetInfraAccessInfo added in v0.12.6

func GetInfraAccessInfo(nsId string, infraId string, option string) (*model.InfraAccessInfo, error)

GetInfraAccessInfo is func to retrieve Infra Access information

func GetInfraActiveCommands added in v0.12.6

func GetInfraActiveCommands(nsId, infraId string, statusFilter []model.CommandExecutionStatus) (*model.ExecutionTaskListResponse, error)

GetInfraActiveCommands returns command execution tasks for an Infra Each VM's command is returned as a separate task for individual tracking and cancellation

func GetInfraAssociatedResources added in v0.12.6

func GetInfraAssociatedResources(nsId string, infraId string) (model.InfraAssociatedResourceList, error)

GetInfraAssociatedResources returns a list of associated resource IDs for given Infra info

func GetInfraClusterInfo added in v0.12.6

func GetInfraClusterInfo(nsId string, infraId string, clusterId string) (*model.InfraClusterInfo, error)

GetInfraClusterInfo returns a single implicit cluster view synthesized at query-time.

func GetInfraHandlingCommandCount added in v0.12.6

func GetInfraHandlingCommandCount(nsId, infraId string) (map[string]int, int, error)

GetInfraHandlingCommandCount returns the count of currently handling commands across all VMs in an Infra This function is optimized for Infra-level monitoring

func GetInfraInfo added in v0.12.6

func GetInfraInfo(nsId string, infraId string) (*model.InfraInfo, error)

GetInfraInfo is func to return Infra information with the current status update

func GetInfraNodeAccessInfo added in v0.12.6

func GetInfraNodeAccessInfo(nsId string, infraId string, nodeId string, option string) (*model.InfraNodeAccessInfo, error)

GetInfraNodeAccessInfo is func to retrieve Infra Access information

func GetInfraNodeCurrentStatus added in v0.12.6

func GetInfraNodeCurrentStatus(nsId string, infraId string, nodeId string) (*model.NodeStatusInfo, error)

GetInfraNodeCurrentStatus is func to Get InfraNode Current Status from CSP API (real-time)

func GetInfraNodeStatus added in v0.12.6

func GetInfraNodeStatus(nsId string, infraId string, nodeId string, fetchFromCSP bool) (*model.NodeStatusInfo, error)

GetInfraNodeStatus is func to Get InfraNode Status with option to control CSP API fetch

func GetInfraObject added in v0.12.6

func GetInfraObject(nsId string, infraId string) (model.InfraInfo, bool, error)

GetInfraObject is func to retrieve Infra object from database (no current status update)

func GetInfraPolicyObject added in v0.12.6

func GetInfraPolicyObject(nsId string, infraId string) (model.InfraPolicyInfo, error)

GetInfraPolicyObject returns model.InfraPolicyInfo object.

func GetInfraStatus added in v0.12.6

func GetInfraStatus(nsId string, infraId string) (*model.InfraStatusInfo, error)

GetInfraStatus is func to Get Infra Status

func GetLatency

func GetLatency(src string, dest string) (float64, error)

GetLatency func get latency between given two regions

func GetMcNlbAccess

func GetMcNlbAccess(nsId string, infraId string) (*model.InfraAccessInfo, error)

GetMcNlbAccess returns the requested TB G-NLB access info (currently Infra)

func GetMonitoringData

func GetMonitoringData(nsId string, infraId string, metric string) (model.MonResultSimpleResponse, error)

GetMonitoringData retrieves monitoring data from CB-Dragonfly for all Nodes in an Infra Returns a consolidated response with metrics for each Node

func GetNLB

func GetNLB(nsId string, infraId string, resourceId string) (model.NLBInfo, error)

GetNLB returns the requested TB NLB object

func GetNLBHealth

func GetNLBHealth(nsId string, infraId string, nlbId string) (model.NLBHealthInfo, error)

GetNLBHealth queries the health status of NLB to CB-Spider, and returns it to user

func GetNodeCurrentPublicIp added in v0.12.6

func GetNodeCurrentPublicIp(nsId string, infraId string, nodeId string) (model.NodeStatusInfo, error)

GetNodeCurrentPublicIp is func to get Node public IP

func GetNodeGroup added in v0.12.6

func GetNodeGroup(nsId string, infraId string, nodeGroupId string) (model.NodeGroupInfo, error)

GetNodeGroup is func to return list of NodeGroups in a given Infra

func GetNodeIdNameInDetail added in v0.12.6

func GetNodeIdNameInDetail(nsId string, infraId string, nodeId string) (*model.IdNameInDetailInfo, error)

GetNodeIdNameInDetail is func to get ID and Name details

func GetNodeIp added in v0.12.6

func GetNodeIp(nsId string, infraId string, nodeId string) (string, string, int, error)

GetNodeIp is func to get Node IP to return PublicIP, PrivateIP, SSHPort

func GetNodeObject added in v0.12.6

func GetNodeObject(nsId string, infraId string, nodeId string) (model.NodeInfo, error)

GetNodeObject is func to get Node object

func GetNodeSpecId added in v0.12.6

func GetNodeSpecId(nsId string, infraId string, nodeId string) string

GetNodeSpecId is func to get Node SpecId

func GetNodeSshHostKey added in v0.12.6

func GetNodeSshHostKey(nsId string, infraId string, nodeId string) (model.SshHostKeyInfo, error)

GetNodeSshHostKey returns the stored SSH host key information for a Node

func GetNodeSshKey added in v0.12.6

func GetNodeSshKey(nsId string, infraId string, nodeId string) (string, string, string, error)

GetNodeSshKey is func to get Node SshKey. Returns username, verifiedUsername, privateKey

func GetNodeTemplate added in v0.12.6

func GetNodeTemplate(nsId string, infraId string, algo string) (model.NodeInfo, error)

GetNodeTemplate is func to get Node template

func GetProvisioningLog added in v0.11.3

func GetProvisioningLog(specId string) (*model.ProvisioningLog, error)

GetProvisioningLog retrieves provisioning log for a specific spec ID

func HandleInfraAction added in v0.12.6

func HandleInfraAction(nsId string, infraId string, action string, force bool) (string, error)

HandleInfraAction is func to handle actions to Infra

func HandleInfraNodeAction added in v0.12.6

func HandleInfraNodeAction(nsId string, infraId string, nodeId string, action string, force bool) (string, error)

HandleInfraNodeAction is func to Get InfraNode Action

func InfraReqStructLevelValidation added in v0.12.6

func InfraReqStructLevelValidation(sl validator.StructLevel)

InfraReqStructLevelValidation is func to validate fields in InfraReqStruct

func InspectResources

func InspectResources(connConfig string, resourceType string) (model.InspectResource, error)

InspectResources returns the state list of TB Resource objects of given connConfig and resourceType

func InspectResourcesOverview

func InspectResourcesOverview() (model.InspectResourceAllResult, error)

InspectResourcesOverview func is to check all resources in CB-TB and CSPs

func InstallBenchmarkAgentToInfra added in v0.12.6

func InstallBenchmarkAgentToInfra(nsId string, infraId string, req *model.InfraCmdReq, option string) ([]model.SshCmdResult, error)

InstallBenchmarkAgentToInfra is func to install milkyway agents in Infra

func InstallMonitorAgentToInfra added in v0.12.6

func InstallMonitorAgentToInfra(nsId string, infraId string, infraServiceType string, req *model.InfraCmdReq) (model.AgentInstallContentWrapper, error)

func ListCommandStatusInfo added in v0.11.10

func ListCommandStatusInfo(nsId, infraId, nodeId string, filter *model.CommandStatusFilter) (*model.CommandStatusListResponse, error)

ListCommandStatusInfo retrieves command status records with filtering

func ListInfraClusterInfo added in v0.12.6

func ListInfraClusterInfo(nsId string, infraId string) ([]model.InfraClusterInfo, error)

ListInfraClusterInfo returns implicit cluster views synthesized at query-time from Infra Nodes. No persistent cluster object is created or maintained.

func ListInfraId added in v0.12.6

func ListInfraId(nsId string) ([]string, error)

ListInfraId is func to list Infra ID

func ListInfraInfo added in v0.12.6

func ListInfraInfo(nsId string, option string) ([]model.InfraInfo, error)

ListInfraInfo is func to get all Infra objects

func ListInfraNodeInfo added in v0.12.6

func ListInfraNodeInfo(nsId string, infraId string) ([]model.NodeInfo, error)

ListInfraNodeInfo is func to Get all Node Info objects in Infra

func ListInfraPolicyId added in v0.12.6

func ListInfraPolicyId(nsId string) []string

ListInfraPolicyId returns a list of Ids for all model.InfraPolicyInfo objects .

func ListInfraStatus added in v0.12.6

func ListInfraStatus(nsId string) ([]model.InfraStatusInfo, error)

ListInfraStatus is func to get Infra status all

func ListNLB

func ListNLB(nsId string, infraId string, filterKey string, filterVal string) (any, error)

ListNLB returns the list of TB NLB objects of given nsId

func ListNLBId

func ListNLBId(nsId string, infraId string) ([]string, error)

ListNLBId returns the list of TB NLB object IDs of given nsId

func ListNodeByFilter added in v0.12.6

func ListNodeByFilter(nsId string, infraId string, filterKey string, filterVal string) ([]string, error)

ListNodeByFilter is func to get list Nodes in an Infra by a filter consist of Key and Value

func ListNodeByLabel added in v0.12.6

func ListNodeByLabel(nsId string, infraId string, labelKey string) ([]string, error)

ListNodeByLabel is a function to list Node IDs by label

func ListNodeByNodeGroup added in v0.12.6

func ListNodeByNodeGroup(nsId string, infraId string, groupId string) ([]string, error)

ListNodeByNodeGroup is func to get Node list with a NodeGroup label in a specified Infra

func ListNodeGroupId added in v0.12.6

func ListNodeGroupId(nsId string, infraId string) ([]string, error)

ListNodeGroupId is func to return list of NodeGroups in a given Infra

func ListNodeId added in v0.12.6

func ListNodeId(nsId string, infraId string) ([]string, error)

ListNodeId is func to list Node IDs

func NLBReqStructLevelValidation added in v0.11.9

func NLBReqStructLevelValidation(sl validator.StructLevel)

NLBReqStructLevelValidation is a function to validate 'model.NLBReq' object.

func OrchestrationController

func OrchestrationController()

OrchestrationController is responsible for executing Infra automation policy. OrchestrationController will be periodically involked by a time.NewTicker in main.go.

func ProvisionDataDisk

func ProvisionDataDisk(ctx context.Context, nsId string, infraId string, nodeId string, u *model.DataDiskNodeReq) (model.NodeInfo, error)

ProvisionDataDisk is func to provision DataDisk to Node (create and attach to Node)

func PublishCommandEvent added in v0.12.3

func PublishCommandEvent(xRequestId string, event model.CommandStreamEvent)

PublishCommandEvent publishes an event to all subscribers of a given xRequestId. Events are also stored in the ring buffer for late-joining subscribers.

func RecommendK8sNode added in v0.10.0

func RecommendK8sNode(ctx context.Context, nsId string, plan model.RecommendSpecReq) ([]model.SpecInfo, error)

RecommendK8sNode is func to recommend a node for K8sCluster

func RecommendNodeCost added in v0.12.6

func RecommendNodeCost(nsId string, specList *[]model.SpecInfo) ([]model.SpecInfo, error)

RecommendNodeCost func prioritize specs based on given Cost

func RecommendNodeLatency added in v0.12.6

func RecommendNodeLatency(nsId string, specList *[]model.SpecInfo, param *[]model.ParameterKeyVal) ([]model.SpecInfo, error)

RecommendNodeLatency func prioritize specs by latency based on given Infra (fair)

func RecommendNodeLocation added in v0.12.6

func RecommendNodeLocation(nsId string, specList *[]model.SpecInfo, param *[]model.ParameterKeyVal) ([]model.SpecInfo, error)

RecommendNodeLocation func prioritize specs based on given location

func RecommendNodePerformance added in v0.12.6

func RecommendNodePerformance(nsId string, specList *[]model.SpecInfo) ([]model.SpecInfo, error)

RecommendNodePerformance func prioritize specs based on given Performance condition

func RecommendNodeRandom added in v0.12.6

func RecommendNodeRandom(nsId string, specList *[]model.SpecInfo) ([]model.SpecInfo, error)

RecommendNodeRandom func prioritize specs randomly

func RecommendSpec added in v0.11.4

func RecommendSpec(ctx context.Context, nsId string, plan model.RecommendSpecReq) ([]model.SpecInfo, error)

RecommendSpec is func to recommend a Node It automatically filters specs by the credential holder's available providers, unless the caller has already specified a providerName filter.

func RecommendSpecOptions added in v0.11.9

func RecommendSpecOptions(nsId string) (*model.RecommendSpecRequestOptions, error)

RecommendSpecOptions returns available options for RecommendSpec API

func RecordProvisioningEvent added in v0.11.3

func RecordProvisioningEvent(event *model.ProvisioningEvent) error

RecordProvisioningEvent records a provisioning event (success or failure) to the log

func RecordProvisioningEventsFromInfra added in v0.12.6

func RecordProvisioningEventsFromInfra(nsId string, infraInfo *model.InfraInfo) error

RecordProvisioningEventsFromInfra analyzes Infra creation result and records provisioning events

func RegisterCspNativeResources

func RegisterCspNativeResources(ctx context.Context, nsId string, connConfig string, infraNamePrefix string, option string, infraFlag string) (model.RegisterResourceResult, error)

RegisterCspNativeResources registers specified CSP native resources from a target connection.

func RegisterCspNativeResourcesAll

func RegisterCspNativeResourcesAll(ctx context.Context, nsId string, infraNamePrefix string, option string, infraFlag string) (model.RegisterResourceAllResult, error)

RegisterCspNativeResourcesAll registers all CSP-native resources into CB-TB using hierarchical rate limiting: global cap → per-CSP cap → per-connection processing. Results are collected via a channel to avoid data races.

func RemoteCommandToInfra added in v0.12.6

func RemoteCommandToInfra(nsId string, infraId string, nodeGroupId string, nodeId string, labelSelector string, req *model.InfraCmdReq, xRequestId string) ([]model.SshCmdResult, error)

RemoteCommandToInfra is func to command to all Nodes in Infra by SSH It now supports user-configurable timeout via InfraCmdReq.TimeoutMinutes Returns the task ID in x-task-id for tracking and cancellation

func RemoveBastionNodes

func RemoveBastionNodes(nsId string, infraId string, bastionNsId string, bastionInfraId string, bastionNodeId string) (string, error)

RemoveBastionNodes func removes existing bastion nodes info. bastionNsId and bastionInfraId narrow the match to a specific bastion identity; pass empty strings to match by bastionNodeId alone (legacy / cleanup on VM deletion).

func RemoveNLBNodes added in v0.12.6

func RemoveNLBNodes(nsId string, infraId string, resourceId string, u *model.NLBAddRemoveNodeReq) error

RemoveNLBNodes accepts VM removal request, removes VMs from NLB, and returns an error if occurs.

func ResetNodeSshHostKey added in v0.12.6

func ResetNodeSshHostKey(nsId string, infraId string, nodeId string) error

ResetNodeSshHostKey resets the stored SSH host key for a Node This should be called when the user trusts a new host key after verification failure

func ReviewInfraDynamicReq added in v0.12.6

func ReviewInfraDynamicReq(ctx context.Context, nsId string, req *model.InfraDynamicReq, deployOption string) (*model.ReviewInfraDynamicReqInfo, error)

ReviewInfraDynamicReq is func to review and validate Infra dynamic request comprehensively

func ReviewSingleNodeGroupDynamicReq added in v0.12.6

func ReviewSingleNodeGroupDynamicReq(ctx context.Context, nsId string, req *model.CreateNodeGroupDynamicReq) (*model.ReviewNodeGroupDynamicReqInfo, error)

ReviewSingleNodeGroupDynamicReq reviews and validates a single VM dynamic request and returns comprehensive review information

func ReviewSpecImagePair added in v0.12.0

func ReviewSpecImagePair(ctx context.Context, specId, imageId, rootDiskType, zone string) (*model.SpecImagePairReviewResult, error)

ReviewSpecImagePair reviews spec and image pair compatibility for provisioning.

rootDiskType and zone are OPTIONAL refinements for the availability check:

  • rootDiskType: empty or "default" means "no specific disk category"; the checker reports stock across all categories supported in the region. A specific value (e.g., "cloud_essd") narrows the check to that exact disk so the UI can flag a combination that will fail at provisioning.
  • zone: empty means "all zones in the region"; a specific zone scopes the result to that single zone (so SuggestedSystemDisk reflects it).

func RunAllBenchmarks

func RunAllBenchmarks(nsId string, infraId string, host string) (*model.BenchmarkInfoArray, error)

RunAllBenchmarks is func to get all Benchmarks

func RunLatencyBenchmark

func RunLatencyBenchmark(nsId string, infraId string, host string) (*model.BenchmarkInfoArray, error)

RunLatencyBenchmark is func to get Infra benchmark for network latency

func RunRemoteCommand

func RunRemoteCommand(nsId string, infraId string, nodeId string, givenUserName string, cmds []string) (map[int]string, map[int]string, error)

RunRemoteCommand is the legacy function for backward compatibility It calls RunRemoteCommandWithContext with a background context (no timeout) Deprecated: Use RunRemoteCommandWithContext for new implementations

func RunRemoteCommandAsync

func RunRemoteCommandAsync(wg *sync.WaitGroup, nsId string, infraId string, nodeId string, givenUserName string, cmd []string, returnResult *[]model.SshCmdResult)

RunRemoteCommandAsync is func to execute a SSH command to a Node (async call)

func RunRemoteCommandAsyncWithStatus added in v0.11.10

func RunRemoteCommandAsyncWithStatus(wg *sync.WaitGroup, nsId string, infraId string, nodeId string, givenUserName string, cmd []string, cmdIndex int, returnResult *[]model.SshCmdResult)

RunRemoteCommandAsyncWithStatus is func to execute a SSH command to a Node (async call) with command status tracking Deprecated: Use runRemoteCommandWithContextAndStatus instead, which supports context-based cancellation

func RunRemoteCommandWithContext added in v0.12.3

func RunRemoteCommandWithContext(ctx context.Context, nsId string, infraId string, nodeId string, givenUserName string, cmds []string) (map[int]string, map[int]string, error)

RunRemoteCommandWithContext executes SSH commands to a Node with context-based timeout and cancellation This is the enhanced version that properly propagates context for cancellation support

func SaveProvisioningLog added in v0.11.3

func SaveProvisioningLog(provisioningLog *model.ProvisioningLog) error

SaveProvisioningLog saves or updates provisioning log for a specific spec ID

func ScaleOutInfraNodeGroup added in v0.12.6

func ScaleOutInfraNodeGroup(ctx context.Context, nsId string, infraId string, nodeGroupId string, numNodesToAdd int) (*model.InfraInfo, error)

ScaleOutInfraNodeGroup is func to create Infra groupNode

func SetBastionNodes

func SetBastionNodes(nsId string, infraId string, targetNodeId string, bastionNsId string, bastionInfraId string, bastionNodeId string) (string, error)

SetBastionNodes func sets bastion nodes

func SetMonitoringAgentStatusInstalled

func SetMonitoringAgentStatusInstalled(nsId string, infraId string, nodeId string) error

SetMonitoringAgentStatusInstalled is func to Set Monitoring Agent Status Installed

func SubscribeCommandEvents added in v0.12.3

func SubscribeCommandEvents(xRequestId string) (<-chan model.CommandStreamEvent, func())

SubscribeCommandEvents subscribes to events for a given xRequestId. It returns a channel of events and a cleanup function that MUST be called when done. If the session already has events in the ring buffer, they are replayed first.

func TbInfraCmdReqStructLevelValidation added in v0.12.6

func TbInfraCmdReqStructLevelValidation(sl validator.StructLevel)

TbInfraCmdReqStructLevelValidation is func to validate fields in model.InfraCmdReq

func TransferFileAndCmdToInfra added in v0.12.6

func TransferFileAndCmdToInfra(nsId string, infraId string, nodeGroupId string, nodeId string, fileData []byte, fileName string, targetPath string, command string) (model.InfraFileTransferAndCmdResult, error)

TransferFileAndCmdToInfra transfers a file to all VMs in Infra and optionally runs a shell command on each Node where the file transfer succeeded.

func TransferFileToInfra added in v0.12.6

func TransferFileToInfra(nsId string, infraId string, nodeGroupId string, nodeId string, fileData []byte, fileName string, targetPath string) ([]model.SshCmdResult, error)

TransferFileToInfra is a function to transfer a file to all VMs in Infra by SSH through bastion hosts

func TrimIP

func TrimIP(sshAccessPoint string) (string, error)

func UpdateCommandStatusInfo added in v0.11.10

func UpdateCommandStatusInfo(nsId, infraId, nodeId string, index int, status model.CommandExecutionStatus, resultSummary, errorMessage, stdout, stderr string) error

UpdateCommandStatusInfo updates an existing command status record

func UpdateInfraInfo added in v0.12.6

func UpdateInfraInfo(nsId string, infraInfoData model.InfraInfo)

UpdateInfraInfo is func to update Infra Info (without Node info in Infra)

func UpdateInfraPolicyInfo added in v0.12.6

func UpdateInfraPolicyInfo(nsId string, infraPolicyInfoData model.InfraPolicyInfo)

UpdateInfraPolicyInfo updates model.InfraPolicyInfo object in DB.

func UpdateMonitoringAgentStatusManually

func UpdateMonitoringAgentStatusManually(nsId string, infraId string, nodeId string, targetStatus string) error

UpdateMonitoringAgentStatusManually is func to Update Monitoring Agent Installation Status Manually

func UpdateNodeInfo added in v0.12.6

func UpdateNodeInfo(nsId string, infraId string, nodeInfoData model.NodeInfo)

UpdateNodeInfo is func to update Node Info

func UpdateNodePublicIp added in v0.12.6

func UpdateNodePublicIp(nsId string, infraId string, nodeInfoData model.NodeInfo) error

UpdateNodePublicIp is func to update Node public IP

func UpdateNodeSshKey added in v0.12.6

func UpdateNodeSshKey(nsId string, infraId string, nodeId string, verifiedUserName string) error

UpdateNodeSshKey is func to update Node SshKey

func ValidateInfraDynamicReq added in v0.12.6

func ValidateInfraDynamicReq(ctx context.Context, nsId string, req *model.InfraDynamicReq, deployOption string) (*model.ReviewInfraDynamicReqInfo, error)

ValidateInfraDynamicReq is func to validate Infra dynamic request before actual provisioning

func ValidateProvisioningLogIntegrity added in v0.11.3

func ValidateProvisioningLogIntegrity(specId string) error

ValidateProvisioningLogIntegrity checks and repairs provisioning log data integrity

func VerifySshUserName

func VerifySshUserName(nsId string, infraId string, nodeId string, nodeIp string, sshPort int, givenUserName string) (string, string, error)

VerifySshUserName is func to verify SSH username

Types

type CreatedResource added in v0.11.2

type CreatedResource struct {
	Type string `json:"type"` // "vnet", "sshkey", "securitygroup"
	Id   string `json:"id"`   // Resource ID
}

CreatedResource represents a resource created during dynamic Infra provisioning

type JobStatus added in v0.11.16

type JobStatus string

JobStatus represents the current status of a scheduled job

const (
	// JobStatusRunning indicates the job is actively running
	JobStatusRunning JobStatus = "Running"
	// JobStatusStopped indicates the job has been stopped
	JobStatusStopped JobStatus = "Stopped"
	// JobStatusExecuting indicates the job is currently executing a task
	JobStatusExecuting JobStatus = "Executing"
	// JobStatusScheduled indicates the job is scheduled and waiting for the next execution time
	JobStatusScheduled JobStatus = "Scheduled"
)

type JobType added in v0.11.16

type JobType string

JobType represents the type of scheduled job

const (
	// JobTypeRegisterCspResources represents CSP resource registration job
	JobTypeRegisterCspResources JobType = "registerCspResources"
	// JobTypeRegisterCspResourcesAll represents all CSP resources registration job
	JobTypeRegisterCspResourcesAll JobType = "registerCspResourcesAll"
)

type NodeControlInfo added in v0.12.6

type NodeControlInfo struct {
	NodeId       string
	ProviderName string
	RegionName   string
}

NodeControlInfo represents Node control information with grouping details

type NodeCreateInfo added in v0.12.6

type NodeCreateInfo struct {
	NodeInfo     *model.NodeInfo
	ProviderName string
	RegionName   string
}

NodeCreateInfo represents Node creation information with grouping details

type NodeGroupStatusInfo added in v0.12.6

type NodeGroupStatusInfo struct {
	NodeId       string
	ProviderName string
	RegionName   string
}

NodeGroupStatusInfo represents Node grouping information for rate limiting

type NodeReqWithCreatedResources added in v0.12.6

type NodeReqWithCreatedResources struct {
	VmReq            *model.CreateNodeGroupReq `json:"nodeReq"`
	CreatedResources []CreatedResource         `json:"createdResources"`
}

NodeReqWithCreatedResources contains Node request and list of created resources for rollback

type NodeStatusAgent added in v0.12.9

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

NodeStatusAgent is the background daemon that periodically refreshes Node statuses from CB-Spider and keeps StatusStore up to date.

Design:

  • A scan loop (1 s tick) finds nodes whose NextPollAt has passed and sends them to a worker pool via a buffered channel.
  • Workers call FetchNodeStatus (which writes results through to StatusStore).
  • Per-CSP+region rate.Limiters prevent Spider / CSP API throttling.
  • Nodes locked by an active lifecycle operation (AcquireLock) are skipped until the operation completes (ReleaseLock) or the lock TTL expires.

func (*NodeStatusAgent) AcquireLock added in v0.12.9

func (a *NodeStatusAgent) AcquireLock(nsId, infraId, nodeId, status, targetAction string)

AcquireLock marks a node as operation-locked so the daemon skips polling it. status is the transitional state to record (e.g. StatusCreating, StatusSuspending). targetAction is the operation being performed (e.g. ActionCreate, ActionSuspend). Call before issuing any blocking Spider operation (POST /vm, suspend, resume, …).

func (*NodeStatusAgent) Promote added in v0.12.9

func (a *NodeStatusAgent) Promote(nsId, infraId, nodeId string, priority PollPriority)

Promote bumps a node's priority and schedules it for an immediate re-poll. Useful after an operation completes to confirm the final state quickly.

func (*NodeStatusAgent) ReleaseLock added in v0.12.9

func (a *NodeStatusAgent) ReleaseLock(nsId, infraId, nodeId string)

ReleaseLock clears the operation lock so the daemon resumes normal polling. Call after the blocking Spider operation returns (success or error).

func (*NodeStatusAgent) Start added in v0.12.9

func (a *NodeStatusAgent) Start(ctx context.Context)

Start launches the scan loop, worker pool, and batch sweeper. Blocks until ctx is cancelled (call in a goroutine).

func (*NodeStatusAgent) StartupScan added in v0.12.9

func (a *NodeStatusAgent) StartupScan()

StartupScan loads all Nodes from the KV store into StatusStore and schedules them for polling. Running (stable) nodes are spread over the first poll interval to avoid a burst of Spider calls immediately at startup. Nodes with a pending TargetAction (stuck since the last restart) are logged as warnings and queued for immediate polling; operators can run action=reconcile if they remain stuck.

type PollPriority added in v0.12.9

type PollPriority int

PollPriority determines how frequently NodeStatusAgent polls a node.

const (
	PollSkip    PollPriority = iota // no polling (Terminated, Failed, stable Suspended, operation-locked)
	PollRecover                     // Undefined → 10 min
	PollNormal                      // Running → 5 min
	PollHigh                        // Transitional (Suspending/Resuming/Rebooting/Terminating) → 15 s
	PollUrgent                      // Operation lock TTL expired → 5 s
)

type ScheduledJob added in v0.11.16

type ScheduledJob struct {
	// Job identification
	JobId     string    `json:"jobId"`
	JobType   JobType   `json:"jobType"`
	NsId      string    `json:"nsId"`
	CreatedAt time.Time `json:"createdAt"`

	// Job configuration
	IntervalSeconds  int  `json:"intervalSeconds"`  // Interval between executions in seconds
	ExecutionTimeout int  `json:"executionTimeout"` // Max execution time in seconds (0 = use default)
	Enabled          bool `json:"enabled"`

	// Job-specific parameters
	ConnectionName  string `json:"connectionName,omitempty"`  // (Deprecated) For registerCspResources
	Provider        string `json:"provider,omitempty"`        // For registerCspResources
	Region          string `json:"region,omitempty"`          // For registerCspResources
	Zone            string `json:"zone,omitempty"`            // For registerCspResources
	InfraNamePrefix string `json:"infraNamePrefix,omitempty"` // For registerCspResources
	Option          string `json:"option,omitempty"`          // For registerCspResources
	InfraFlag       string `json:"infraFlag,omitempty"`       // For registerCspResources

	// Job status
	Status              JobStatus `json:"status"`
	LastExecutedAt      time.Time `json:"lastExecutedAt"`
	NextExecutionAt     time.Time `json:"nextExecutionAt"`
	ExecutionCount      int       `json:"executionCount"`
	SuccessCount        int       `json:"successCount"`        // Total successful executions
	FailureCount        int       `json:"failureCount"`        // Total failed executions
	ConsecutiveFailures int       `json:"consecutiveFailures"` // Current consecutive failures
	LastError           string    `json:"lastError,omitempty"`
	LastResult          string    `json:"lastResult,omitempty"`
	AutoDisabled        bool      `json:"autoDisabled"` // Whether job was auto-disabled due to failures
	// contains filtered or unexported fields
}

ScheduledJob represents a scheduled recurring job

func (*ScheduledJob) GetStatus added in v0.11.16

func (job *ScheduledJob) GetStatus() model.ScheduleJobStatus

GetStatus returns the current status of the job (thread-safe)

type SchedulerManager added in v0.11.16

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

SchedulerManager manages all scheduled jobs

func GetSchedulerManager added in v0.11.16

func GetSchedulerManager() *SchedulerManager

GetSchedulerManager returns the singleton scheduler manager instance

func (*SchedulerManager) CreateScheduledJob added in v0.11.16

func (sm *SchedulerManager) CreateScheduledJob(req model.ScheduleJobRequest) (*ScheduledJob, error)

CreateScheduledJob creates a new scheduled job

func (*SchedulerManager) GetScheduledJob added in v0.11.16

func (sm *SchedulerManager) GetScheduledJob(jobId string) (*ScheduledJob, error)

GetScheduledJob retrieves a scheduled job by ID

func (*SchedulerManager) ListScheduledJobs added in v0.11.16

func (sm *SchedulerManager) ListScheduledJobs() []*ScheduledJob

ListScheduledJobs returns all scheduled jobs Jobs are not scoped to namespaces, so all jobs are returned

func (*SchedulerManager) StopAllScheduledJobs added in v0.11.16

func (sm *SchedulerManager) StopAllScheduledJobs() (int, error)

StopAllScheduledJobs stops all scheduled jobs in the system Jobs are not scoped to namespaces, so all jobs in the system are deleted

func (*SchedulerManager) StopScheduledJob added in v0.11.16

func (sm *SchedulerManager) StopScheduledJob(jobId string) error

StopScheduledJob stops a scheduled job

func (*SchedulerManager) UpdateScheduledJob added in v0.11.16

func (sm *SchedulerManager) UpdateScheduledJob(jobId string, req model.UpdateScheduleJobRequest) (*ScheduledJob, error)

UpdateScheduledJob updates job configuration

type SshHostKeyMismatchError added in v0.12.2

type SshHostKeyMismatchError struct {
	NodeId              string
	StoredKeyType       string
	StoredFingerprint   string
	ReceivedKeyType     string
	ReceivedFingerprint string
}

SshHostKeyMismatchError represents an SSH host key verification failure This error occurs when the stored host key doesn't match the server's current host key

func (*SshHostKeyMismatchError) Error added in v0.12.2

func (e *SshHostKeyMismatchError) Error() string

type StatusEntry added in v0.12.9

type StatusEntry struct {
	// Status fields — updated on each CSP poll
	Status        string
	NativeStatus  string
	PublicIP      string
	TargetStatus  string
	TargetAction  string
	SystemMessage string
	LastUpdated   time.Time // last time Status was refreshed from CSP; zero = never

	// Daemon scheduling
	NextPollAt time.Time
	Priority   PollPriority

	// Operation lock.
	// Zero value = not locked.
	// When set and within operationLockTTL, the daemon skips this node because
	// a blocking lifecycle operation (Create, Suspend, …) owns its state.
	OperationLockedAt time.Time

	// Node identity — needed by the polling goroutine
	NsId             string
	InfraId          string
	NodeId           string
	ConnectionName   string
	CspResourceName  string
	CspResourceId    string // CSP-native instance ID (e.g., "i-014fa6ede6ada0b2c"), used by batch SDK sweeper
	ProviderName     string
	Region           string
	CredentialHolder string // credential owner, used as context key for SDK calls

	// Node metadata — static fields from NodeInfo stored here so that
	// fetchNodeStatusWithCache can serve cache hits without a KV round-trip.
	Name           string
	PrivateIP      string
	SSHPort        int
	CreatedTime    string
	Location       model.Location
	MonAgentStatus string
}

StatusEntry is the in-memory representation of a Node's current state maintained by NodeStatusAgent. Fields are safe to read via StatusStore.Get.

func (*StatusEntry) IsFresh added in v0.12.9

func (e *StatusEntry) IsFresh() bool

IsFresh reports whether the entry is still within its acceptable staleness window and can be served without a live CSP call.

func (*StatusEntry) IsLockTTLExpired added in v0.12.9

func (e *StatusEntry) IsLockTTLExpired() bool

IsLockTTLExpired reports a potential goroutine leak: the lock TTL has elapsed but TargetAction is still non-complete.

func (*StatusEntry) IsOperationLocked added in v0.12.9

func (e *StatusEntry) IsOperationLocked() bool

IsOperationLocked reports whether a live operation lock holds this node.

type StatusStore added in v0.12.9

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

StatusStore is the in-memory status cache for all Nodes. It is safe for concurrent use.

func (*StatusStore) Delete added in v0.12.9

func (s *StatusStore) Delete(nsId, infraId, nodeId string)

Delete removes the StatusEntry for the node.

func (*StatusStore) Get added in v0.12.9

func (s *StatusStore) Get(nsId, infraId, nodeId string) (StatusEntry, bool)

Get returns a copy of the StatusEntry for the node. ok is false if not found.

func (*StatusStore) Set added in v0.12.9

func (s *StatusStore) Set(nsId, infraId, nodeId string, e StatusEntry)

Set stores a StatusEntry for a node, replacing any existing entry.

func (*StatusStore) Snapshot added in v0.12.9

func (s *StatusStore) Snapshot() []StatusEntry

Snapshot returns a copy of all current entries.

func (*StatusStore) Update added in v0.12.9

func (s *StatusStore) Update(nsId, infraId, nodeId string, fn func(*StatusEntry))

Update applies fn to the StatusEntry for the node in place, creating it if absent.

Jump to

Keyboard shortcuts

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