feat: self-update of master and agents (#15)
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
// Version is the protocol version this build speaks. Agents send it in
|
||||
// Hello. Phase-1 agents do not send the field, which reads as 0.
|
||||
const Version = 3
|
||||
const Version = 4
|
||||
|
||||
// MinJobVersion is the lowest agent protocol version the master sends jobs to.
|
||||
const MinJobVersion = 2
|
||||
@@ -26,6 +26,26 @@ const MinJobVersion = 2
|
||||
// with a digest.
|
||||
const MinPinnedRefVersion = 3
|
||||
|
||||
// MinSelfUpdateVersion is the lowest agent protocol version the master sends a
|
||||
// job for the agent's own Compose service to. Older agents neither run the
|
||||
// update in a helper container nor resume it after restarting.
|
||||
const MinSelfUpdateVersion = 4
|
||||
|
||||
// SelfUpdateLabelPrefix starts the names of the labels on the helper
|
||||
// container that finishes an agent's self-update. The new agent finds the
|
||||
// helper by them, and the inventory skips containers that carry them.
|
||||
const SelfUpdateLabelPrefix = "se.shcizo.package-updater.self-update."
|
||||
|
||||
// Labels on a self-update helper container.
|
||||
const (
|
||||
LabelSelfUpdateJob = SelfUpdateLabelPrefix + "job"
|
||||
LabelSelfUpdateRef = SelfUpdateLabelPrefix + "ref"
|
||||
LabelSelfUpdateStarted = SelfUpdateLabelPrefix + "started"
|
||||
LabelSelfUpdateProject = SelfUpdateLabelPrefix + "project"
|
||||
LabelSelfUpdateService = SelfUpdateLabelPrefix + "service"
|
||||
LabelSelfUpdateOutput = SelfUpdateLabelPrefix + "output"
|
||||
)
|
||||
|
||||
// MaxJobOutput caps the job output an agent keeps and the master stores, in
|
||||
// bytes. Only the tail is kept. With JSON escaping (worst case 6 bytes per
|
||||
// byte) a JobResult carrying this much output still fits the 1 MiB read limit.
|
||||
@@ -141,6 +161,10 @@ type JobStart struct {
|
||||
SwarmClusterID string `json:"swarm_cluster_id,omitempty"`
|
||||
SwarmService string `json:"swarm_service,omitempty"`
|
||||
Ref string `json:"ref"`
|
||||
// Self says the service is the agent's own. The agent runs such a job
|
||||
// after every other queued job; whether it needs a helper container is
|
||||
// decided by the agent itself.
|
||||
Self bool `json:"self,omitempty"`
|
||||
}
|
||||
|
||||
// JobProgress carries output produced since the previous JobProgress for the
|
||||
|
||||
Reference in New Issue
Block a user