selfupgrade

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	NodeUpgradePending    = "pending"
	NodeUpgradeRunning    = "upgrading"
	NodeUpgradeSucceeded  = "succeeded"
	NodeUpgradeFailed     = "failed"
	NodeUpgradeRolledBack = "rolled_back"
	NodeUpgradeOffline    = "offline"
	NodeUpgradeSkipped    = "skipped"

	ProxyUpdated = "updated"
	ProxySkipped = "skipped"
	ProxyFailed  = "failed"
	// ProxyRolledBack 表示 jar 已随控制面回滚恢复为备份。/ ProxyRolledBack means jars were restored with the control plane rollback.
	ProxyRolledBack = "rolled_back"

	ProxyRestartRestarted  = "restarted"
	ProxyRestartNotRunning = "not_running"
	ProxyRestartRolledBack = "rolled_back"
	ProxyRestartFailed     = "failed"
	ProxyRestartSkipped    = "skipped"
)

节点升级状态 / per-node upgrade status

View Source
const (
	CodeCheckFail            = "check_fail"
	CodeAlreadyLatest        = "already_latest"
	CodeDownloadPartial      = "download_partial"
	CodeBadOfflineImport     = "bad_offline_import"
	CodeForbiddenNonAdmin    = "forbidden_non_admin"
	CodeStepFailControlPlane = "step_fail_control_plane"
	CodeStepFailAgent        = "step_fail_agent"
	CodeStepFailProxy        = "step_fail_proxy"
	CodeVerifyFail           = "verify_fail"
	CodeConcurrentUpgrade    = "concurrent_upgrade"
	CodeDiskFull             = "disk_full"
	CodeCancelled            = "cancelled"
	CodeNotStaged            = "not_staged"
	CodeNetworkUnreachable   = "network_unreachable"
	CodeInvalidRequest       = "invalid_request"
)

Typed error codes returned to API clients. / 返回给 API 客户端的错误码。

View Source
const (
	RestartStrategyStandalone = "standalone"
	RestartStrategySystemd    = "systemd"
	RestartStrategySupervisor = "supervisor"
	RestartStrategyPM2        = "pm2"
	RestartStrategyHook       = "hook"
	RestartStrategyDocker     = "docker"

	// RestartHookEnv 指定自定义重启命令(经 sh -c 执行),优先于自动检测。
	// RestartHookEnv names a custom restart command (run via sh -c) that wins over auto-detection.
	RestartHookEnv = "STX_SELF_UPGRADE_RESTART_CMD"
	// RestartTimeoutEnv 覆盖新进程就绪等待时间(Go duration)。/ RestartTimeoutEnv overrides the readiness timeout.
	RestartTimeoutEnv = "STX_SELF_UPGRADE_RESTART_TIMEOUT"
	// FrontendPIDFileEnv 显式指定前端进程 pid 文件。/ FrontendPIDFileEnv points at the frontend pid file explicitly.
	FrontendPIDFileEnv = "STX_FRONTEND_PID_FILE"

	// WatchdogCommand 是隐藏的 CLI 子命令名,由旧二进制以独立会话运行,负责拉起/校验/回滚。
	// WatchdogCommand is the hidden CLI sub-command the old binary runs detached to start/verify/roll back.
	WatchdogCommand = "__self-upgrade-restart"
)

控制面重启策略 / control plane restart strategies

View Source
const (
	StatusIdle      = "idle"
	StatusChecking  = "checking"
	StatusAvailable = "available"
	StatusUpToDate  = "up_to_date"
	StatusStaging   = "staging"
	StatusStaged    = "staged"
	StatusUpgrading = "upgrading"
	StatusSucceeded = "succeeded"
	StatusFailed    = "failed"
	StatusCancelled = "cancelled"

	AssetPending = "pending"
	AssetLoading = "loading"
	AssetReady   = "ready"
	AssetFailed  = "failed"
	AssetSkipped = "skipped"

	StepPending   = "pending"
	StepRunning   = "running"
	StepSucceeded = "succeeded"
	StepFailed    = "failed"
	StepCancelled = "cancelled"
	StepSkipped   = "skipped"
	// StepPartial 表示步骤完成但部分节点未成功(见 agent_nodes)。
	// StepPartial means the step finished but some nodes did not succeed (see agent_nodes).
	StepPartial = "partial"

	StepControlPlane = "control_plane"
	StepAgent        = "agent"
	StepProxy        = "proxy"
	StepVerify       = "verify"
	// StepRestart 重启 STX 自身进程(控制面、随包前端);不触碰 SeaTunnel。
	// StepRestart restarts STX's own processes (control plane, bundled frontend); SeaTunnel is never touched.
	StepRestart = "restart"

	// ExecModeApply 真实应用升级;ExecModeDryRun 仅演练、不做任何变更。
	// ExecModeApply really applies the upgrade; ExecModeDryRun only rehearses and changes nothing.
	ExecModeApply  = "apply"
	ExecModeDryRun = "dry_run"

	// 进程重启状态 / process restart status
	RestartPending     = "pending"
	RestartRunning     = "restarting"
	RestartSucceeded   = "restarted"
	RestartRolledBack  = "rolled_back"
	RestartFailed      = "failed"
	RestartSkipped     = "skipped"
	RestartNotRunning  = "not_running"
	RestartWouldDoThis = "planned"

	ModeOnline  = "online"
	ModeOffline = "offline"
)

Phase / Status enums.

Variables

View Source
var (
	ErrCheckFail            = errors.New(CodeCheckFail)
	ErrNetworkUnreachable   = errors.New(CodeNetworkUnreachable)
	ErrAlreadyLatest        = errors.New(CodeAlreadyLatest)
	ErrDownloadPartial      = errors.New(CodeDownloadPartial)
	ErrBadOfflineImport     = errors.New(CodeBadOfflineImport)
	ErrForbiddenNonAdmin    = errors.New(CodeForbiddenNonAdmin)
	ErrStepFailControlPlane = errors.New(CodeStepFailControlPlane)
	ErrStepFailAgent        = errors.New(CodeStepFailAgent)
	ErrStepFailProxy        = errors.New(CodeStepFailProxy)
	ErrVerifyFail           = errors.New(CodeVerifyFail)
	ErrConcurrentUpgrade    = errors.New(CodeConcurrentUpgrade)
	ErrDiskFull             = errors.New(CodeDiskFull)
	ErrCancelled            = errors.New(CodeCancelled)
	ErrNotStaged            = errors.New(CodeNotStaged)
	// ErrInvalidRequest 表示请求参数非法(如 target_version 不是合法版本)。
	// ErrInvalidRequest marks malformed request input such as an invalid target_version.
	ErrInvalidRequest = errors.New(CodeInvalidRequest)
)

Functions

func ErrInvalid

func ErrInvalid() error

func ErrorCode

func ErrorCode(err error) string

ErrorCode extracts a stable code from an error. / 从错误中提取稳定错误码。

func IsRunningInDocker

func IsRunningInDocker() bool

IsRunningInDocker detects if the current process is running inside a Docker/container environment. IsRunningInDocker 检测当前进程是否运行在 Docker/容器环境中。

func RunRestartWatchdog

func RunRestartWatchdog(planPath string) error

RunRestartWatchdog 是隐藏子命令 __self-upgrade-restart 的入口,由旧二进制在独立会话中运行:

  1. 等待旧控制面退出(进程管理器策略下由管理器负责停止并重启);
  2. 独立部署时以相同 argv/env/cwd/输出拉起新二进制;
  3. 等待新进程写入就绪标记(版本 = 目标版本)且健康接口返回 200;
  4. 失败时恢复备份二进制并以同样方式拉起旧版本,结果记为 rolled_back;
  5. 成功后重启随包前端(失败则恢复旧前端目录);
  6. 把结果写入 restart-result.json,由存活的控制面收尾任务与历史。

它只操作 STX 自身的控制面与前端进程,从不触碰 SeaTunnel/Hazelcast。

RunRestartWatchdog is the entry of the hidden __self-upgrade-restart sub-command, run detached by the old binary:

  1. wait for the old control plane to exit (process managers stop and restart it themselves);
  2. in standalone deployments start the new binary with the same argv/env/cwd/output;
  3. wait for the ready marker (version = target) and a 200 from the health endpoint;
  4. on failure restore the backup binary, start the old version the same way and report rolled_back;
  5. after success restart the bundled frontend (restoring the old frontend dir if it fails);
  6. write restart-result.json for the surviving control plane to finish the task and history.

It only operates on STX's own control plane and frontend processes, never on SeaTunnel/Hazelcast.

Types

type AgentFleet

type AgentFleet interface {
	// ListNodes 返回所有已安装 Agent 的节点(含离线)。/ ListNodes returns every host with an installed Agent, including offline ones.
	ListNodes(ctx context.Context) ([]FleetNode, error)
	// Node 返回单个节点的最新连接信息。/ Node returns the latest connection info of one host.
	Node(ctx context.Context, hostID uint) (FleetNode, bool)
	// TransferFile 让 Agent 通过现有 DownloadPackage 流拉取文件,返回 Agent 上的路径。
	// TransferFile has the Agent pull a file over the existing DownloadPackage stream and returns its path on the Agent.
	TransferFile(ctx context.Context, agentID, key, localPath, checksum string) (string, error)
	// SendUpgradeCommand 发送 UPGRADE 子命令并返回成功输出。/ SendUpgradeCommand sends an UPGRADE sub-command and returns its output.
	SendUpgradeCommand(ctx context.Context, agentID string, params map[string]string, timeout time.Duration) (string, error)
}

AgentFleet 抽象 CP 对已连接 Agent 的访问(由 router 适配 agent.Manager 与 host.Service)。 AgentFleet abstracts the control plane's access to Agents (adapted from agent.Manager and host.Service by the router).

type AgentNodeUpgrade

type AgentNodeUpgrade struct {
	HostID         uint   `json:"host_id"`
	HostName       string `json:"host_name"`
	IPAddress      string `json:"ip_address,omitempty"`
	AgentID        string `json:"agent_id,omitempty"`
	FromVersion    string `json:"from_version,omitempty"`
	TargetVersion  string `json:"target_version"`
	CurrentVersion string `json:"current_version,omitempty"`
	Status         string `json:"status"`
	Message        string `json:"message,omitempty"`
	ProxyStatus    string `json:"proxy_status,omitempty"`
	ProxyMessage   string `json:"proxy_message,omitempty"`
	// ProxyRestart 是该节点运行中 stx-java-proxy 的重启结果:restarted | not_running | rolled_back | failed | skipped。
	// ProxyRestart is the restart result of the node's running stx-java-proxy.
	ProxyRestart        string     `json:"proxy_restart,omitempty"`
	ProxyRestartMessage string     `json:"proxy_restart_message,omitempty"`
	UpdatedAt           *time.Time `json:"updated_at,omitempty"`
}

AgentNodeUpgrade 是单节点 Agent/Proxy 升级状态。/ AgentNodeUpgrade is the Agent/Proxy upgrade status of one node.

type AgentVersionInfo

type AgentVersionInfo struct {
	HostID    uint   `json:"host_id"`
	HostName  string `json:"host_name"`
	IPAddress string `json:"ip_address,omitempty"`
	Version   string `json:"version"`
	Online    bool   `json:"online"`
	UpToDate  bool   `json:"up_to_date"`
}

AgentVersionInfo 是状态页展示的节点 Agent 版本。/ AgentVersionInfo is a node's Agent version shown on the status page.

type AssetSpec

type AssetSpec struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
	Glob        bool   `json:"glob"`
}

AssetSpec describes one staged release asset. / 描述一项预置资产。

func DefaultAssetCatalog

func DefaultAssetCatalog() []AssetSpec

DefaultAssetCatalog returns the release assets this console upgrade expects. DefaultAssetCatalog 返回控制台自升级期望的发版资产清单。

type AssetState

type AssetState struct {
	AssetSpec
	Status   string `json:"status"`
	Size     int64  `json:"size,omitempty"`
	Path     string `json:"path,omitempty"`
	Message  string `json:"message,omitempty"`
	Progress int    `json:"progress,omitempty"`
}

AssetState is the runtime state of one asset. / 单项资产运行时状态。

type CheckRequest

type CheckRequest struct {
	SimulateFailure string `json:"simulate_failure,omitempty"`
	ForceLatest     string `json:"force_latest,omitempty"`
}

CheckRequest optionally injects a failure for local smoke tests. CheckRequest 可注入失败码,便于本地冒烟。

type CheckResult

type CheckResult struct {
	CurrentVersion  string `json:"current_version"`
	LatestVersion   string `json:"latest_version"`
	UpdateAvailable bool   `json:"update_available"`
	ReleaseURL      string `json:"release_url,omitempty"`
	CheckedAt       string `json:"checked_at"`
	Message         string `json:"message,omitempty"`
	ErrorCode       string `json:"error_code,omitempty"`
	// StagedVersion 是检查后仍保留的已预置版本(可能与 LatestVersion 不同)。
	// StagedVersion is the staged version kept after the check (may differ from LatestVersion).
	StagedVersion string `json:"staged_version,omitempty"`
	// StagePreserved 表示本次检查保留了已预置包,可直接执行升级。
	// StagePreserved reports that this check kept the staged package, so execution can proceed.
	StagePreserved bool `json:"stage_preserved,omitempty"`
}

CheckResult is the outcome of a version check. / 版本检查结果。

type ExecuteRequest

type ExecuteRequest struct {
	SimulateFailure string `json:"simulate_failure,omitempty"`
	// Mode 显式选择 "apply"(真实应用:替换并重启控制面、Agent、proxy、随包前端)或 "dry_run"(演练,不做任何变更)。
	// 省略时回退到旧字段 apply;两者都省略时为 dry_run(安全默认)。
	// Mode explicitly selects "apply" (really replace and restart the control plane, Agents, proxies and bundled
	// frontend) or "dry_run" (rehearse, change nothing). When omitted the legacy apply flag decides; when both are
	// omitted the request is a dry run (safe default).
	Mode string `json:"mode,omitempty"`
	// Apply 是旧字段,等价于 mode=apply;与 mode 冲突时报错。
	// Apply is the legacy flag, equivalent to mode=apply; conflicting with mode is rejected.
	Apply bool `json:"apply,omitempty"`
}

ExecuteRequest starts the upgrade from local packages only. ExecuteRequest 仅从本地预置包开升。

func (ExecuteRequest) ResolveMode

func (r ExecuteRequest) ResolveMode() (string, error)

ResolveMode 返回本次执行的显式模式。/ ResolveMode returns the explicit execution mode of the request.

type FleetNode

type FleetNode struct {
	HostID      uint
	HostName    string
	IPAddress   string
	AgentID     string
	Version     string
	OS          string
	Arch        string
	Online      bool
	ConnectedAt time.Time
	// InstallDirs 是该节点上 SeaTunnel 集群节点的安装目录,用于定位运行中的 stx-java-proxy 状态目录。
	// InstallDirs are the SeaTunnel install dirs of cluster nodes on this host, used to find running stx-java-proxy state.
	InstallDirs []string
}

FleetNode 是一个已安装 Agent 的节点。/ FleetNode is a host with an installed Agent.

type Handler

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

Handler exposes self-upgrade HTTP APIs. / Handler 暴露自升级 HTTP API。

func NewHandler

func NewHandler(service *Service) *Handler

NewHandler creates a handler. / 创建处理器。

func (*Handler) CancelStage

func (h *Handler) CancelStage(c *gin.Context)

CancelStage cancels staging. / 取消预置。

func (*Handler) CancelTask

func (h *Handler) CancelTask(c *gin.Context)

CancelTask cancels a task. / 取消任务。

func (*Handler) Check

func (h *Handler) Check(c *gin.Context)

Check handles version check. / 处理版本检查。

func (*Handler) Execute

func (h *Handler) Execute(c *gin.Context)

Execute starts upgrade from local packages. / 从本地包开升。

func (*Handler) GetHistory

func (h *Handler) GetHistory(c *gin.Context)

GetHistory returns self-upgrade execution history. GetHistory 返回自升级执行历史列表。

func (*Handler) GetStage

func (h *Handler) GetStage(c *gin.Context)

GetStage returns staging snapshot. / 返回预置快照。

func (*Handler) GetStatus

func (h *Handler) GetStatus(c *gin.Context)

GetStatus returns aggregate status. / 返回聚合状态。

func (*Handler) GetTask

func (h *Handler) GetTask(c *gin.Context)

GetTask returns a task. / 返回任务。

func (*Handler) ImportOffline

func (h *Handler) ImportOffline(c *gin.Context)

ImportOffline handles multipart offline import. / 处理离线导入。

func (*Handler) StartDownload

func (h *Handler) StartDownload(c *gin.Context)

StartDownload starts online staging. / 启动联网预置。

type ProcessRestart

type ProcessRestart struct {
	// Component: control_plane | frontend
	Component string `json:"component"`
	// Strategy: standalone | systemd | supervisor | pm2 | hook | none
	Strategy string     `json:"strategy,omitempty"`
	Status   string     `json:"status"`
	Message  string     `json:"message,omitempty"`
	OldPID   int        `json:"old_pid,omitempty"`
	NewPID   int        `json:"new_pid,omitempty"`
	At       *time.Time `json:"at,omitempty"`
}

ProcessRestart 是一个 STX 自身进程的重启结果。/ ProcessRestart is the restart result of one STX-owned process.

type Response

type Response struct {
	ErrorMsg  string      `json:"error_msg"`
	ErrorCode string      `json:"error_code,omitempty"`
	Data      interface{} `json:"data"`
}

Response is the common envelope. / 统一响应信封。

type RestartPlanInfo

type RestartPlanInfo struct {
	ControlPlaneStrategy string `json:"control_plane_strategy"`
	ControlPlaneDetail   string `json:"control_plane_detail,omitempty"`
	// FrontendDetected 表示检测到随包的 Next standalone 前端进程,会一并重启。
	// FrontendDetected reports a bundled Next standalone frontend process that is restarted too.
	FrontendDetected bool   `json:"frontend_detected"`
	FrontendStrategy string `json:"frontend_strategy,omitempty"`
	// RestartsAgents / RestartsProxies 恒为 true:Agent 换二进制后原地重启,运行中的 stx-java-proxy 换 jar 后重启。
	// RestartsAgents / RestartsProxies are always true: Agents restart in place after the swap, running proxies after the jar swap.
	RestartsAgents  bool `json:"restarts_agents"`
	RestartsProxies bool `json:"restarts_proxies"`
	// SeaTunnelAffected 恒为 false:自升级从不停止、重启或改动 SeaTunnel/Hazelcast 进程与作业。
	// SeaTunnelAffected is always false: self-upgrade never stops, restarts or modifies SeaTunnel/Hazelcast processes or jobs.
	SeaTunnelAffected bool `json:"seatunnel_affected"`
}

RestartPlanInfo 告诉确认框真实应用时会重启哪些进程。/ RestartPlanInfo tells the confirm dialog which processes an apply restarts.

type RolloutOptions

type RolloutOptions struct {
	Concurrency      int
	CommandTimeout   time.Duration
	ReconnectTimeout time.Duration
	PollInterval     time.Duration
}

RolloutOptions 控制 Agent 下发节奏。/ RolloutOptions tunes the Agent rollout.

type Service

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

Service orchestrates STX console self-upgrade. / Service 编排 STX 控制台自升级。

func NewService

func NewService(dataDir string) *Service

NewService creates a self-upgrade service rooted at dataDir/self-upgrade. NewService 在 dataDir/self-upgrade 下创建自升级服务。

func (*Service) CancelStage

func (s *Service) CancelStage() error

CancelStage cancels an in-flight staging operation. / 取消进行中的预置。

func (*Service) CancelTask

func (s *Service) CancelTask(taskID string) error

CancelTask cancels the active task when cancellable. / 在可取消时取消活跃任务。

func (*Service) Check

func (s *Service) Check(ctx context.Context, req CheckRequest) (*CheckResult, error)

Check probes for a newer release. / 检查是否有新版本。

func (*Service) Execute

func (s *Service) Execute(ctx context.Context, req ExecuteRequest) (*TaskState, error)

Execute starts the upgrade using local staged packages only. Execute 仅使用本地预置包执行升级。

func (*Service) GetTask

func (s *Service) GetTask(taskID string) (*TaskState, error)

GetTask returns a task by id. / 按 id 返回任务。

func (*Service) HandleAgentReady

func (s *Service) HandleAgentReady(ctx context.Context, hostID uint)

HandleAgentReady 在 Agent 重连就绪后调用:若该节点在待补升级列表中,则在后台补升级(含 proxy jar)。 HandleAgentReady runs after an Agent reconnects: if the node is queued for catch-up, upgrade it in the background (including proxy jars).

func (*Service) ImportOffline

func (s *Service) ImportOffline(filename string, r io.Reader, simulateFailure string) (*StageState, error)

ImportOffline 校验并预置上传的离线包。 ImportOffline validates and stages an uploaded archive or asset set.

func (*Service) ListHistory

func (s *Service) ListHistory() []UpgradeHistoryRecord

ListHistory 返回自升级执行历史记录列表(倒序排列,最新在最前)。 ListHistory returns self-upgrade execution history records (descending order, latest first).

func (*Service) RestartPlanPreview

func (s *Service) RestartPlanPreview() *RestartPlanInfo

RestartPlanPreview 返回确认框展示的重启计划(只读)。/ RestartPlanPreview returns the read-only restart plan for the confirm dialog.

func (*Service) SetAgentFleet

func (s *Service) SetAgentFleet(f AgentFleet)

SetAgentFleet 注入 Agent 访问能力;未注入时 Agent 步骤只能更新控制面本地 lib 并如实报告。 SetAgentFleet injects Agent access; without it the Agent step can only refresh the control plane's local lib and says so.

func (*Service) SetRolloutOptions

func (s *Service) SetRolloutOptions(o RolloutOptions)

SetRolloutOptions 覆盖下发参数(测试用)。/ SetRolloutOptions overrides rollout tuning (tests).

func (*Service) StageSnapshot

func (s *Service) StageSnapshot() StageState

StageSnapshot returns current staging state. / 返回当前预置状态。

func (*Service) StartDownload

func (s *Service) StartDownload(ctx context.Context, req StageDownloadRequest) (*TaskState, error)

StartDownload stages assets from the network (or mock). / 联网预置资产。

func (*Service) Status

func (s *Service) Status() StatusResponse

Status returns the aggregate console status. / 返回聚合状态。

type StageDownloadRequest

type StageDownloadRequest struct {
	TargetVersion   string `json:"target_version,omitempty"`
	SimulateFailure string `json:"simulate_failure,omitempty"`
}

StageDownloadRequest starts online staging. / 启动联网预置。

type StageState

type StageState struct {
	Mode          string       `json:"mode,omitempty"`
	Status        string       `json:"status"`
	Progress      int          `json:"progress"`
	TargetVersion string       `json:"target_version,omitempty"`
	Assets        []AssetState `json:"assets"`
	Message       string       `json:"message,omitempty"`
	ErrorCode     string       `json:"error_code,omitempty"`
	Cancellable   bool         `json:"cancellable"`
}

StageState tracks asset staging. / 预置进度。

type StatusResponse

type StatusResponse struct {
	CurrentVersion  string       `json:"current_version"`
	GitCommit       string       `json:"git_commit,omitempty"`
	BuildTime       string       `json:"build_time,omitempty"`
	LatestVersion   string       `json:"latest_version,omitempty"`
	UpdateAvailable bool         `json:"update_available"`
	Checked         bool         `json:"checked"`
	OverallStatus   string       `json:"overall_status"`
	Stage           StageState   `json:"stage"`
	ActiveTask      *TaskState   `json:"active_task,omitempty"`
	LastCheck       *CheckResult `json:"last_check,omitempty"`
	MockMode        bool         `json:"mock_mode"`
	// DeploymentType distinguishes container vs host deployments ("docker" | "host").
	// DeploymentType 区分容器化与物理宿主机部署 ("docker" | "host")。
	DeploymentType string `json:"deployment_type"`
	// DockerComposeUpgradeCmd provides the suggested container upgrade command.
	// DockerComposeUpgradeCmd 提供推荐的容器升级命令。
	DockerComposeUpgradeCmd string `json:"docker_compose_upgrade_cmd,omitempty"`
	// Architecture reflects the host operating system and CPU architecture.
	// Architecture 反映当前宿主机操作系统与架构 (如 linux/arm64)。
	Architecture string `json:"architecture"`
	// Agents 列出各节点当前 Agent 版本及是否与控制面一致。
	// Agents lists each node's current Agent version and whether it matches the control plane.
	Agents []AgentVersionInfo `json:"agents,omitempty"`
	// AgentsOutdated 是版本与控制面不一致的 Agent 数量。
	// AgentsOutdated counts Agents whose version differs from the control plane.
	AgentsOutdated int `json:"agents_outdated"`
	// RestartPlan 描述真实应用时会重启的 STX 进程(SeaTunnel 不受影响)。
	// RestartPlan describes the STX processes an apply restarts (SeaTunnel is unaffected).
	RestartPlan *RestartPlanInfo `json:"restart_plan,omitempty"`
}

StatusResponse is the aggregate console status. / 控制台聚合状态。

type StepState

type StepState struct {
	Code      string     `json:"code"`
	Label     string     `json:"label"`
	Status    string     `json:"status"`
	Message   string     `json:"message,omitempty"`
	Error     string     `json:"error,omitempty"`
	StartedAt *time.Time `json:"started_at,omitempty"`
	EndedAt   *time.Time `json:"ended_at,omitempty"`
}

StepState is one upgrade execution step. / 升级执行步骤。

type TaskState

type TaskState struct {
	ID            string      `json:"id"`
	Kind          string      `json:"kind"` // stage | execute
	Status        string      `json:"status"`
	TargetVersion string      `json:"target_version,omitempty"`
	CurrentStep   string      `json:"current_step,omitempty"`
	FailureStep   string      `json:"failure_step,omitempty"`
	FailureReason string      `json:"failure_reason,omitempty"`
	ErrorCode     string      `json:"error_code,omitempty"`
	Steps         []StepState `json:"steps,omitempty"`
	// AgentNodes 是各 Worker 节点 Agent/Proxy 的升级状态。
	// AgentNodes is the per-node Agent/Proxy upgrade status.
	AgentNodes []AgentNodeUpgrade `json:"agent_nodes,omitempty"`
	// ExecutionMode 是 apply 或 dry_run;DryRun 便于直接判断。
	// ExecutionMode is apply or dry_run; DryRun is a convenience flag.
	ExecutionMode string `json:"execution_mode,omitempty"`
	DryRun        bool   `json:"dry_run"`
	// Restarts 是控制面与随包前端的重启结果。/ Restarts holds control plane and bundled frontend restart results.
	Restarts    []ProcessRestart `json:"restarts,omitempty"`
	Cancellable bool             `json:"cancellable"`
	StartedAt   *time.Time       `json:"started_at,omitempty"`
	CompletedAt *time.Time       `json:"completed_at,omitempty"`
}

TaskState is an execute/stage task snapshot. / 执行或预置任务快照。

type UpgradeHistoryRecord

type UpgradeHistoryRecord struct {
	ID             string      `json:"id"`
	StartedAt      time.Time   `json:"started_at"`
	CompletedAt    time.Time   `json:"completed_at"`
	DurationMs     int64       `json:"duration_ms"`
	FromVersion    string      `json:"from_version"`
	TargetVersion  string      `json:"target_version"`
	Mode           string      `json:"mode"`            // online | offline
	DeploymentType string      `json:"deployment_type"` // host | docker
	Status         string      `json:"status"`          // succeeded | failed | rolled_back
	FailureStep    string      `json:"failure_step,omitempty"`
	FailureReason  string      `json:"failure_reason,omitempty"`
	ErrorCode      string      `json:"error_code,omitempty"`
	Steps          []StepState `json:"steps,omitempty"`
	// AgentNodes 是各节点 Agent/Proxy 的升级结果(离线节点重连后补升级会回写)。
	// AgentNodes is the per-node Agent/Proxy result (updated when offline nodes catch up after reconnecting).
	AgentNodes []AgentNodeUpgrade `json:"agent_nodes,omitempty"`
	// ExecutionMode 是 apply 或 dry_run(旧记录为空)。/ ExecutionMode is apply or dry_run (empty for older records).
	ExecutionMode string           `json:"execution_mode,omitempty"`
	DryRun        bool             `json:"dry_run"`
	Restarts      []ProcessRestart `json:"restarts,omitempty"`
}

UpgradeHistoryRecord 记录一次完成或失败的自升级历史。 UpgradeHistoryRecord records a completed, failed, or rolled back upgrade attempt.

Jump to

Keyboard shortcuts

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