Skip to content

Commit

Permalink
Fix handling of coco / hub replicas restart
Browse files Browse the repository at this point in the history
Hub upgrade was restarting the existing instance, which is fine for cases where
the user didn't set any replica for it. Coco's upgrade was scaling to
the number of replicas passed as parameters, which doesn't work if the
user didn't set any and has running instances.

This merges both: if no replica is set, just restart the enabled ones.
Otherwise scale to whatever the user provided.
  • Loading branch information
cbosdo committed Nov 13, 2024
1 parent dd46b29 commit 3862097
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions mgradm/shared/coco/coco.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func Upgrade(
return err
}

if !cocoFlags.IsChanged {
return systemd.RestartInstantiated(podman.ServerAttestationService)
}
return systemd.ScaleService(cocoFlags.Replicas, podman.ServerAttestationService)
}

Expand Down
7 changes: 4 additions & 3 deletions mgradm/shared/hub/xmlrpcapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ func EnableHubXmlrpc(systemd podman.Systemd, replicas int) error {
if err := systemd.ScaleService(replicas, podman.HubXmlrpcService); err != nil {
return utils.Errorf(err, L("cannot enable service"))
}
} else {
log.Info().Msg(L("Not starting Hub XML-RPC API service"))
}
return nil
}
Expand All @@ -95,7 +93,10 @@ func Upgrade(
return err
}

return systemd.RestartInstantiated(podman.HubXmlrpcService)
if !hubXmlrpcFlags.IsChanged {
return systemd.RestartInstantiated(podman.HubXmlrpcService)
}
return systemd.ScaleService(hubXmlrpcFlags.Replicas, podman.HubXmlrpcService)
}

// generateHubXmlrpcSystemdService creates the Hub XMLRPC systemd files.
Expand Down

0 comments on commit 3862097

Please sign in to comment.