chore: refactor schedulers to work with cluster state snapshot, VolumeScheduler updates state with scheduled volumes

This commit is contained in:
Pavel Sviderski
2025-04-22 20:34:54 +10:00
parent e5957d9d6b
commit fcf164dda1
9 changed files with 120 additions and 85 deletions
+5 -1
View File
@@ -38,7 +38,11 @@ func (cli *Client) RunService(ctx context.Context, spec api.ServiceSpec) (api.Ru
// Create missing named Docker volumes for the service.
if len(spec.MountedDockerVolumes()) > 0 {
volumeScheduler, err := scheduler.NewVolumeSchedulerWithClient(ctx, cli, []api.ServiceSpec{spec})
state, err := scheduler.InspectClusterState(ctx, cli)
if err != nil {
return resp, fmt.Errorf("inspect cluster state: %w", err)
}
volumeScheduler, err := scheduler.NewVolumeScheduler(state, []api.ServiceSpec{spec})
if err != nil {
return resp, fmt.Errorf("init volume scheduler: %w", err)
}