Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Swarm support #333

Merged
merged 26 commits into from
Jan 31, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
270ca65
Query for labeled services as well
m90 Jan 25, 2024
8ef7fa0
Try scaling down services
m90 Jan 25, 2024
511b79b
Scale services back up
m90 Jan 25, 2024
978e900
Use progress tool from Docker CLI
m90 Jan 26, 2024
f14b796
In test, label both services
m90 Jan 26, 2024
b785560
Clean up error and log messages
m90 Jan 26, 2024
fee8cb2
Document scale-up/down approach in docs
m90 Jan 26, 2024
95e9e99
Downgrade Docker CLI to match client
m90 Jan 26, 2024
f449717
Document services stats
m90 Jan 26, 2024
94aa333
Do not rely on PreviousSpec for storing desired replica count
m90 Jan 27, 2024
78a89c1
Log warnings from Docker when updating services
m90 Jan 27, 2024
538a069
Check whether container and service labels collide
m90 Jan 27, 2024
bf1d13b
Document script behavior on label collision
m90 Jan 27, 2024
bb37b8b
Add additional check if all containers have been removed
m90 Jan 27, 2024
7ad6fc9
Scale services concurrently
m90 Jan 27, 2024
09cc1f5
Move docker interaction code into own file
m90 Jan 27, 2024
26bbc66
Factor out code for service updating
m90 Jan 27, 2024
2bc94d8
Time out after five minutes of not reaching desired container count
m90 Jan 27, 2024
542d1fa
Inline handling of in-swarm container level restart
m90 Jan 27, 2024
409496a
Timer is more suitable for timeout race
m90 Jan 27, 2024
9acd6dc
Timeout when scaling down services should be configurable
m90 Jan 28, 2024
4639b21
Choose better filename
m90 Jan 28, 2024
57e7f2a
Reflect changes in naming
m90 Jan 28, 2024
7d489a9
Rename and deprecate BACKUP_STOP_CONTAINER_LABEL
m90 Jan 29, 2024
87ea8d0
Improve logging
m90 Jan 29, 2024
b13f189
Further simplify logging
m90 Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Further simplify logging
m90 committed Jan 29, 2024
commit b13f189ecac8a4293c461c9117096e3968fd9d0f
38 changes: 17 additions & 21 deletions cmd/backup/stop_restart.go
Original file line number Diff line number Diff line change
@@ -170,26 +170,23 @@ func (s *script) stopContainersAndServices() (func() error, error) {
}
}

s.logger.Info(
fmt.Sprintf(
"Stopping %d out of %d running container(s) as they were labeled %s.",
len(containersToStop),
len(allContainers),
filterMatchLabel,
),
)
if isDockerSwarm {
s.logger.Info(
fmt.Sprintf(
"Stopping %d out of %d running container(s) and scaling down %d out of %d active service(s) as they were labeled %s.",
len(containersToStop),
len(allContainers),
"Scaling down %d out of %d active service(s) as they were labeled %s.",
len(servicesToScaleDown),
len(allServices),
filterMatchLabel,
),
)
} else {
s.logger.Info(
fmt.Sprintf(
"Stopping %d out of %d running container(s) as they were labeled %s.",
len(containersToStop),
len(allContainers),
filterMatchLabel,
),
)
}

var stoppedContainers []types.Container
@@ -320,21 +317,20 @@ func (s *script) stopContainersAndServices() (func() error, error) {
errors.Join(allErrors...),
)
}

s.logger.Info(
fmt.Sprintf(
"Restarted %d container(s).",
len(stoppedContainers),
),
)
if isDockerSwarm {
s.logger.Info(
fmt.Sprintf(
"Restarted %d container(s) and %d service(s).",
len(stoppedContainers),
"Scaled %d service(s) back up.",
len(scaledDownServices),
),
)
} else {
s.logger.Info(
fmt.Sprintf(
"Restarted %d container(s).",
len(stoppedContainers),
),
)
}

return nil