fix: fail global deployment if no matchine machines found, improve caddy deploy output in particular

This commit is contained in:
Pavel Sviderski
2025-02-17 20:31:37 +10:00
parent e13408d79f
commit 98e1bdc9b5
3 changed files with 31 additions and 5 deletions
+9
View File
@@ -13,6 +13,8 @@ import (
// Strategy defines how a service should be deployed or updated. Different implementations can provide various
// deployment patterns such as rolling updates, blue/green deployments, etc.
type Strategy interface {
// Type returns the type of the deployment strategy, e.g. "rolling", "blue-green".
Type() string
// Plan returns the operation to reconcile the service to the desired state.
// If the service does not exist (new deployment), svc will be nil.
Plan(ctx context.Context, cli *Client, svc *api.Service, spec api.ServiceSpec) (Plan, error)
@@ -25,6 +27,10 @@ type RollingStrategy struct {
MachineFilter MachineFilter
}
func (s *RollingStrategy) Type() string {
return "rolling"
}
func (s *RollingStrategy) Plan(
ctx context.Context, cli *Client, svc *api.Service, spec api.ServiceSpec,
) (Plan, error) {
@@ -81,6 +87,9 @@ func (s *RollingStrategy) planGlobal(
machines = slices.DeleteFunc(machines, func(m *pb.MachineMember) bool {
return !s.MachineFilter(m.Machine)
})
if len(machines) == 0 {
return plan, ErrNoMatchingMachines
}
}
// TODO: figure out how to return a warning if there are machines down. Embed the machinesDown in the plan?