From b799b7518e8a062696a0b12af561e15e40f12b49 Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Mon, 17 Mar 2025 20:32:14 +1000 Subject: [PATCH] feat(compose): add TODO to address deployment idempotency --- internal/cli/client/container.go | 1 + internal/cli/client/strategy.go | 2 ++ internal/compose/service.go | 3 +++ internal/machine/api/pb/docker.proto | 2 ++ 4 files changed, 8 insertions(+) diff --git a/internal/cli/client/container.go b/internal/cli/client/container.go index 6b17ded7..8ff7c125 100644 --- a/internal/cli/client/container.go +++ b/internal/cli/client/container.go @@ -40,6 +40,7 @@ func (cli *Client) CreateContainer( } containerName := fmt.Sprintf("%s-%s", spec.Name, suffix) + // TODO: calculate the spec hash and set it as a label to detect changes in the service spec. config := &container.Config{ Cmd: spec.Container.Command, Hostname: containerName, diff --git a/internal/cli/client/strategy.go b/internal/cli/client/strategy.go index 05a3fb87..2b4e907d 100644 --- a/internal/cli/client/strategy.go +++ b/internal/cli/client/strategy.go @@ -97,6 +97,8 @@ func (s *RollingStrategy) planReplicated( // Skip containers that are not running. continue } + // TODO: determine if the spec has changed by comparing the hashes. + // Refactor all the spec comparison logic below. cs, err := c.Container.ServiceSpec() if err == nil { runningSpecs[c.Container.ID] = cs diff --git a/internal/compose/service.go b/internal/compose/service.go index 0c18541f..0413ecd9 100644 --- a/internal/compose/service.go +++ b/internal/compose/service.go @@ -7,6 +7,9 @@ import ( ) func ServiceSpecFromCompose(name string, service types.ServiceConfig) (api.ServiceSpec, error) { + // TODO: resolve the image to a digest and supported platforms using an image resolver that broadcasts requests + // to all machines in the cluster. + // TODO: configure placement filter based on the supported platforms of the image. spec := api.ServiceSpec{ Container: api.ContainerSpec{ Command: service.Command, diff --git a/internal/machine/api/pb/docker.proto b/internal/machine/api/pb/docker.proto index 5f01a431..35f5a22e 100644 --- a/internal/machine/api/pb/docker.proto +++ b/internal/machine/api/pb/docker.proto @@ -15,6 +15,8 @@ service Docker { rpc ListContainers(ListContainersRequest) returns (ListContainersResponse); rpc RemoveContainer(RemoveContainerRequest) returns (google.protobuf.Empty); rpc PullImage(PullImageRequest) returns (stream JSONMessage); + // TODO: implement InspectImageFromRegistry to resolve image name to digest and supported platforms using + // the configured Docker auth. } message CreateContainerRequest {