commit docker-compose for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package docker-compose for openSUSE:Factory checked in at 2023-06-30 19:59:37 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/docker-compose (Old) and /work/SRC/openSUSE:Factory/.docker-compose.new.13546 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "docker-compose" Fri Jun 30 19:59:37 2023 rev:23 rq:1096073 version:2.19.1 Changes: -------- --- /work/SRC/openSUSE:Factory/docker-compose/docker-compose.changes 2023-06-21 22:41:15.254874923 +0200 +++ /work/SRC/openSUSE:Factory/.docker-compose.new.13546/docker-compose.changes 2023-06-30 19:59:55.466018965 +0200 @@ -1,0 +2,13 @@ +Fri Jun 30 04:43:25 UTC 2023 - kastl@b1-systems.de + +- Update to version 2.19.1: + * ci: upgrade compose-go to v1.15.1 (#10757) + * up: fix race condition on network connect + * Updated documentation files for my contribution + * Fix capitalization error in sentence by adding an uppercase + letter at beginning + * fix typos + * watch: add warning when a path is already used by a bind mount + volume (#10741) + +------------------------------------------------------------------- Old: ---- compose-2.19.0.obscpio New: ---- compose-2.19.1.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ docker-compose.spec ++++++ --- /var/tmp/diff_new_pack.LQzkZU/_old 2023-06-30 19:59:57.070028506 +0200 +++ /var/tmp/diff_new_pack.LQzkZU/_new 2023-06-30 19:59:57.074028530 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: docker-compose -Version: 2.19.0 +Version: 2.19.1 Release: 0 Summary: Define and run multi-container applications with Docker License: Apache-2.0 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.LQzkZU/_old 2023-06-30 19:59:57.114028768 +0200 +++ /var/tmp/diff_new_pack.LQzkZU/_new 2023-06-30 19:59:57.122028815 +0200 @@ -3,7 +3,7 @@ <param name="url">https://github.com/docker/compose</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">v2.19.0</param> + <param name="revision">v2.19.1</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> @@ -17,7 +17,7 @@ <param name="compression">gz</param> </service> <service name="go_modules" mode="disabled"> - <param name="archive">compose-2.19.0.obscpio</param> + <param name="archive">compose-2.19.1.obscpio</param> </service> </services> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.LQzkZU/_old 2023-06-30 19:59:57.142028934 +0200 +++ /var/tmp/diff_new_pack.LQzkZU/_new 2023-06-30 19:59:57.146028958 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/docker/compose</param> - <param name="changesrevision">db24023884cbd9657c5c64b80ea27da38e9c4cc7</param></service></servicedata> + <param name="changesrevision">c496c230710d299834cf2586d0f75066dc60d06c</param></service></servicedata> (No newline at EOF) ++++++ compose-2.19.0.obscpio -> compose-2.19.1.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/docs/reference/compose_run.md new/compose-2.19.1/docs/reference/compose_run.md --- old/compose-2.19.0/docs/reference/compose_run.md 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/docs/reference/compose_run.md 2023-06-29 22:50:10.000000000 +0200 @@ -36,7 +36,7 @@ Runs a one-time command against a service. -the following command starts the `web` service and runs `bash` as its command: +The following command starts the `web` service and runs `bash` as its command: ```console $ docker compose run web bash diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/docs/reference/docker_compose_run.yaml new/compose-2.19.1/docs/reference/docker_compose_run.yaml --- old/compose-2.19.0/docs/reference/docker_compose_run.yaml 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/docs/reference/docker_compose_run.yaml 2023-06-29 22:50:10.000000000 +0200 @@ -3,7 +3,7 @@ long: |- Runs a one-time command against a service. - the following command starts the `web` service and runs `bash` as its command: + The following command starts the `web` service and runs `bash` as its command: ```console $ docker compose run web bash diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/go.mod new/compose-2.19.1/go.mod --- old/compose-2.19.0/go.mod 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/go.mod 2023-06-29 22:50:10.000000000 +0200 @@ -6,7 +6,7 @@ github.com/AlecAivazis/survey/v2 v2.3.7 github.com/Microsoft/go-winio v0.6.1 github.com/buger/goterm v1.0.4 - github.com/compose-spec/compose-go v1.15.0 + github.com/compose-spec/compose-go v1.15.1 github.com/containerd/console v1.0.3 github.com/containerd/containerd v1.7.2 github.com/cucumber/godog v0.0.0-00010101000000-000000000000 // replaced; see replace for the actual version used diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/go.sum new/compose-2.19.1/go.sum --- old/compose-2.19.0/go.sum 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/go.sum 2023-06-29 22:50:10.000000000 +0200 @@ -131,8 +131,8 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+gqO04wryn5h75LSazbRlnya1k= github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE= -github.com/compose-spec/compose-go v1.15.0 h1:rv3TTgbS3U4Y8sRTngrcxDmpbz+fq26wTqHculSCi6s= -github.com/compose-spec/compose-go v1.15.0/go.mod h1:3yngGBGfls6FHGQsg4B1z6gz8ej9SOvmAJtxCwgbcnc= +github.com/compose-spec/compose-go v1.15.1 h1:0yaEt6/66dLN0bNWYDTj0CDx626uCdQ9ipJVIJx8O8M= +github.com/compose-spec/compose-go v1.15.1/go.mod h1:3yngGBGfls6FHGQsg4B1z6gz8ej9SOvmAJtxCwgbcnc= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/pkg/compose/convergence.go new/compose-2.19.1/pkg/compose/convergence.go --- old/compose-2.19.0/pkg/compose/convergence.go 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/pkg/compose/convergence.go 2023-06-29 22:50:10.000000000 +0200 @@ -29,7 +29,6 @@ "github.com/containerd/containerd/platforms" moby "github.com/docker/docker/api/types" containerType "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/network" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -233,7 +232,13 @@ name := getContainerName(project.Name, service, number) i := i eg.Go(func() error { - container, err := c.service.createContainer(ctx, project, service, name, number, false, true, false) + opts := createOptions{ + AutoRemove: false, + AttachStdin: false, + UseNetworkAliases: true, + Labels: mergeLabels(service.Labels, service.CustomLabels), + } + container, err := c.service.createContainer(ctx, project, service, name, number, opts) updated[actual+i] = container return err }) @@ -399,12 +404,11 @@ } func (s *composeService) createContainer(ctx context.Context, project *types.Project, service types.ServiceConfig, - name string, number int, autoRemove bool, useNetworkAliases bool, attachStdin bool) (container moby.Container, err error) { + name string, number int, opts createOptions) (container moby.Container, err error) { w := progress.ContextWriter(ctx) eventName := "Container " + name w.Event(progress.CreatingEvent(eventName)) - container, err = s.createMobyContainer(ctx, project, service, name, number, nil, - autoRemove, useNetworkAliases, attachStdin, w, mergeLabels(service.Labels, service.CustomLabels)) + container, err = s.createMobyContainer(ctx, project, service, name, number, nil, opts, w) if err != nil { return } @@ -429,9 +433,13 @@ } name := getContainerName(project.Name, service, number) tmpName := fmt.Sprintf("%s_%s", replaced.ID[:12], name) - created, err = s.createMobyContainer(ctx, project, service, tmpName, number, inherited, - false, true, false, w, - mergeLabels(service.Labels, service.CustomLabels).Add(api.ContainerReplaceLabel, replaced.ID)) + opts := createOptions{ + AutoRemove: false, + AttachStdin: false, + UseNetworkAliases: true, + Labels: mergeLabels(service.Labels, service.CustomLabels).Add(api.ContainerReplaceLabel, replaced.ID), + } + created, err = s.createMobyContainer(ctx, project, service, tmpName, number, inherited, opts, w) if err != nil { return created, err } @@ -484,19 +492,18 @@ return nil } -func (s *composeService) createMobyContainer(ctx context.Context, //nolint:gocyclo +func (s *composeService) createMobyContainer(ctx context.Context, project *types.Project, service types.ServiceConfig, name string, number int, inherit *moby.Container, - autoRemove, useNetworkAliases, attachStdin bool, + opts createOptions, w progress.Writer, - labels types.Labels, ) (moby.Container, error) { var created moby.Container - containerConfig, hostConfig, networkingConfig, err := s.getCreateOptions(ctx, project, service, number, inherit, - autoRemove, attachStdin, labels) + cfgs, err := s.getCreateConfigs(ctx, project, service, number, inherit, opts) + if err != nil { return created, err } @@ -514,18 +521,7 @@ plat = &p } - links, err := s.getLinks(ctx, project.Name, service, number) - if err != nil { - return created, err - } - if networkingConfig != nil { - for k, s := range networkingConfig.EndpointsConfig { - s.Links = links - networkingConfig.EndpointsConfig[k] = s - } - } - - response, err := s.apiClient().ContainerCreate(ctx, containerConfig, hostConfig, networkingConfig, plat, name) + response, err := s.apiClient().ContainerCreate(ctx, cfgs.Container, cfgs.Host, cfgs.Network, plat, name) if err != nil { return created, err } @@ -548,29 +544,19 @@ Networks: inspectedContainer.NetworkSettings.Networks, }, } - for _, netName := range service.NetworksByPriority() { - netwrk := project.Networks[netName] - cfg := service.Networks[netName] - aliases := []string{getContainerName(project.Name, service, number)} - if useNetworkAliases { - aliases = append(aliases, service.Name) - if cfg != nil { - aliases = append(aliases, cfg.Aliases...) - } - } - if val, ok := created.NetworkSettings.Networks[netwrk.Name]; ok { - if shortIDAliasExists(created.ID, val.Aliases...) { - continue - } - err = s.apiClient().NetworkDisconnect(ctx, netwrk.Name, created.ID, false) - if err != nil { + + // the highest-priority network is the primary and is included in the ContainerCreate API + // call via container.NetworkMode & network.NetworkingConfig + // any remaining networks are connected one-by-one here after creation (but before start) + serviceNetworks := service.NetworksByPriority() + if len(serviceNetworks) > 1 { + for _, networkKey := range serviceNetworks[1:] { + mobyNetworkName := project.Networks[networkKey].Name + epSettings := createEndpointSettings(project, service, number, networkKey, cfgs.Links, opts.UseNetworkAliases) + if err := s.apiClient().NetworkConnect(ctx, mobyNetworkName, created.ID, epSettings); err != nil { return created, err } } - err = s.connectContainerToNetwork(ctx, created.ID, netwrk.Name, cfg, links, aliases...) - if err != nil { - return created, err - } } err = s.injectSecrets(ctx, project, service, created.ID) @@ -635,43 +621,6 @@ return links, nil } -func shortIDAliasExists(containerID string, aliases ...string) bool { - for _, alias := range aliases { - if alias == containerID[:12] { - return true - } - } - return false -} - -func (s *composeService) connectContainerToNetwork(ctx context.Context, id string, netwrk string, cfg *types.ServiceNetworkConfig, links []string, aliases ...string) error { - var ( - ipv4Address string - ipv6Address string - ipam *network.EndpointIPAMConfig - ) - if cfg != nil { - ipv4Address = cfg.Ipv4Address - ipv6Address = cfg.Ipv6Address - ipam = &network.EndpointIPAMConfig{ - IPv4Address: ipv4Address, - IPv6Address: ipv6Address, - LinkLocalIPs: cfg.LinkLocalIPs, - } - } - err := s.apiClient().NetworkConnect(ctx, netwrk, id, &network.EndpointSettings{ - Aliases: aliases, - IPAddress: ipv4Address, - GlobalIPv6Address: ipv6Address, - Links: links, - IPAMConfig: ipam, - }) - if err != nil { - return err - } - return nil -} - func (s *composeService) isServiceHealthy(ctx context.Context, containers Containers, fallbackRunning bool) (bool, error) { for _, c := range containers { container, err := s.apiClient().ContainerInspect(ctx, c.ID) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/pkg/compose/create.go new/compose-2.19.1/pkg/compose/create.go --- old/compose-2.19.0/pkg/compose/create.go 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/pkg/compose/create.go 2023-06-29 22:50:10.000000000 +0200 @@ -48,6 +48,20 @@ "github.com/docker/compose/v2/pkg/utils" ) +type createOptions struct { + AutoRemove bool + AttachStdin bool + UseNetworkAliases bool + Labels types.Labels +} + +type createConfigs struct { + Container *container.Config + Host *container.HostConfig + Network *network.NetworkingConfig + Links []string +} + func (s *composeService) Create(ctx context.Context, project *types.Project, options api.CreateOptions) error { return progress.RunWithTitle(ctx, func(ctx context.Context) error { return s.create(ctx, project, options) @@ -166,18 +180,16 @@ return nil } -func (s *composeService) getCreateOptions(ctx context.Context, +func (s *composeService) getCreateConfigs(ctx context.Context, p *types.Project, service types.ServiceConfig, number int, inherit *moby.Container, - autoRemove, attachStdin bool, - labels types.Labels, -) (*container.Config, *container.HostConfig, *network.NetworkingConfig, error) { - - labels, err := s.prepareLabels(labels, service, number) + opts createOptions, +) (createConfigs, error) { + labels, err := s.prepareLabels(opts.Labels, service, number) if err != nil { - return nil, nil, nil, err + return createConfigs{}, err } var ( @@ -196,11 +208,6 @@ stdinOpen = service.StdinOpen ) - binds, mounts, err := s.buildContainerVolumes(ctx, *p, service, inherit) - if err != nil { - return nil, nil, nil, err - } - proxyConfig := types.MappingWithEquals(s.configFile().ParseProxyConfig(s.apiClient().DaemonHost(), nil)) env := proxyConfig.OverrideBy(service.Environment) @@ -211,8 +218,8 @@ ExposedPorts: buildContainerPorts(service), Tty: tty, OpenStdin: stdinOpen, - StdinOnce: attachStdin && stdinOpen, - AttachStdin: attachStdin, + StdinOnce: opts.AttachStdin && stdinOpen, + AttachStdin: opts.AttachStdin, AttachStderr: true, AttachStdout: true, Cmd: runCmd, @@ -228,20 +235,7 @@ StopTimeout: ToSeconds(service.StopGracePeriod), } - portBindings := buildContainerPortBindingOptions(service) - - resources := getDeployResources(service) - - if service.NetworkMode == "" { - service.NetworkMode = getDefaultNetworkMode(p, service) - } - - var networkConfig *network.NetworkingConfig - for _, id := range service.NetworksByPriority() { - networkConfig = s.createNetworkConfig(p, service, id) - break - } - + // VOLUMES/MOUNTS/FILESYSTEMS tmpfs := map[string]string{} for _, t := range service.Tmpfs { if arr := strings.SplitN(t, ":", 2); len(arr) > 1 { @@ -250,39 +244,47 @@ tmpfs[arr[0]] = "" } } - - var logConfig container.LogConfig - if service.Logging != nil { - logConfig = container.LogConfig{ - Type: service.Logging.Driver, - Config: service.Logging.Options, - } + binds, mounts, err := s.buildContainerVolumes(ctx, *p, service, inherit) + if err != nil { + return createConfigs{}, err } - var volumesFrom []string for _, v := range service.VolumesFrom { if !strings.HasPrefix(v, "container:") { - return nil, nil, nil, fmt.Errorf("invalid volume_from: %s", v) + return createConfigs{}, fmt.Errorf("invalid volume_from: %s", v) } volumesFrom = append(volumesFrom, v[len("container:"):]) } + // NETWORKING links, err := s.getLinks(ctx, p.Name, service, number) if err != nil { - return nil, nil, nil, err + return createConfigs{}, err } + networkMode, networkingConfig := defaultNetworkSettings(p, service, number, links, opts.UseNetworkAliases) + portBindings := buildContainerPortBindingOptions(service) + // MISC + resources := getDeployResources(service) + var logConfig container.LogConfig + if service.Logging != nil { + logConfig = container.LogConfig{ + Type: service.Logging.Driver, + Config: service.Logging.Options, + } + } securityOpts, unconfined, err := parseSecurityOpts(p, service.SecurityOpt) if err != nil { - return nil, nil, nil, err + return createConfigs{}, err } + hostConfig := container.HostConfig{ - AutoRemove: autoRemove, + AutoRemove: opts.AutoRemove, Binds: binds, Mounts: mounts, CapAdd: strslice.StrSlice(service.CapAdd), CapDrop: strslice.StrSlice(service.CapDrop), - NetworkMode: container.NetworkMode(service.NetworkMode), + NetworkMode: networkMode, Init: service.Init, IpcMode: container.IpcMode(service.Ipc), CgroupnsMode: container.CgroupnsMode(service.Cgroup), @@ -317,12 +319,28 @@ hostConfig.ReadonlyPaths = []string{} } - return &containerConfig, &hostConfig, networkConfig, nil + cfgs := createConfigs{ + Container: &containerConfig, + Host: &hostConfig, + Network: networkingConfig, + Links: links, + } + return cfgs, nil } -func (s *composeService) createNetworkConfig(p *types.Project, service types.ServiceConfig, networkID string) *network.NetworkingConfig { - net := p.Networks[networkID] - config := service.Networks[networkID] +func getAliases(project *types.Project, service types.ServiceConfig, serviceIndex int, networkKey string, useNetworkAliases bool) []string { + aliases := []string{getContainerName(project.Name, service, serviceIndex)} + if useNetworkAliases { + aliases = append(aliases, service.Name) + if cfg := service.Networks[networkKey]; cfg != nil { + aliases = append(aliases, cfg.Aliases...) + } + } + return aliases +} + +func createEndpointSettings(p *types.Project, service types.ServiceConfig, serviceIndex int, networkKey string, links []string, useNetworkAliases bool) *network.EndpointSettings { + config := service.Networks[networkKey] var ipam *network.EndpointIPAMConfig var ( ipv4Address string @@ -337,15 +355,12 @@ LinkLocalIPs: config.LinkLocalIPs, } } - return &network.NetworkingConfig{ - EndpointsConfig: map[string]*network.EndpointSettings{ - net.Name: { - Aliases: getAliases(service, config), - IPAddress: ipv4Address, - IPv6Gateway: ipv6Address, - IPAMConfig: ipam, - }, - }, + return &network.EndpointSettings{ + Aliases: getAliases(p, service, serviceIndex, networkKey, useNetworkAliases), + Links: links, + IPAddress: ipv4Address, + IPv6Gateway: ipv6Address, + IPAMConfig: ipam, } } @@ -404,17 +419,39 @@ return labels, nil } -func getDefaultNetworkMode(project *types.Project, service types.ServiceConfig) string { +// defaultNetworkSettings determines the container.NetworkMode and corresponding network.NetworkingConfig (nil if not applicable). +func defaultNetworkSettings( + project *types.Project, + service types.ServiceConfig, + serviceIndex int, + links []string, + useNetworkAliases bool, +) (container.NetworkMode, *network.NetworkingConfig) { + if service.NetworkMode != "" { + return container.NetworkMode(service.NetworkMode), nil + } + if len(project.Networks) == 0 { - return "none" + return "none", nil } + var networkKey string if len(service.Networks) > 0 { - name := service.NetworksByPriority()[0] - return project.Networks[name].Name + networkKey = service.NetworksByPriority()[0] + } else { + networkKey = "default" + } + mobyNetworkName := project.Networks[networkKey].Name + epSettings := createEndpointSettings(project, service, serviceIndex, networkKey, links, useNetworkAliases) + networkConfig := &network.NetworkingConfig{ + EndpointsConfig: map[string]*network.EndpointSettings{ + mobyNetworkName: epSettings, + }, } - - return project.Networks["default"].Name + // From the Engine API docs: + // > Supported standard values are: bridge, host, none, and container:<name|id>. + // > Any other value is taken as a custom network's name to which this container should connect to. + return container.NetworkMode(mobyNetworkName), networkConfig } func getRestartPolicy(service types.ServiceConfig) container.RestartPolicy { @@ -1002,14 +1039,6 @@ } } -func getAliases(s types.ServiceConfig, c *types.ServiceNetworkConfig) []string { - aliases := []string{s.Name} - if c != nil { - aliases = append(aliases, c.Aliases...) - } - return aliases -} - func (s *composeService) ensureNetwork(ctx context.Context, n *types.NetworkConfig) error { if n.External.External { return s.resolveExternalNetwork(ctx, n) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/pkg/compose/create_test.go new/compose-2.19.1/pkg/compose/create_test.go --- old/compose-2.19.0/pkg/compose/create_test.go 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/pkg/compose/create_test.go 2023-06-29 22:50:10.000000000 +0200 @@ -22,6 +22,8 @@ "sort" "testing" + "gotest.tools/v3/assert/cmp" + "github.com/docker/compose/v2/pkg/api" composetypes "github.com/compose-spec/compose-go/types" @@ -203,7 +205,7 @@ assert.Equal(t, mounts[2].Target, "\\\\.\\pipe\\docker_engine") } -func TestGetDefaultNetworkMode(t *testing.T) { +func TestDefaultNetworkSettings(t *testing.T) { t.Run("returns the network with the highest priority when service has multiple networks", func(t *testing.T) { service := composetypes.ServiceConfig{ Name: "myService", @@ -231,7 +233,10 @@ }), } - assert.Equal(t, getDefaultNetworkMode(&project, service), "myProject_myNetwork2") + networkMode, networkConfig := defaultNetworkSettings(&project, service, 1, nil, true) + assert.Equal(t, string(networkMode), "myProject_myNetwork2") + assert.Check(t, cmp.Len(networkConfig.EndpointsConfig, 1)) + assert.Check(t, cmp.Contains(networkConfig.EndpointsConfig, "myProject_myNetwork2")) }) t.Run("returns default network when service has no networks", func(t *testing.T) { @@ -256,7 +261,10 @@ }), } - assert.Equal(t, getDefaultNetworkMode(&project, service), "myProject_default") + networkMode, networkConfig := defaultNetworkSettings(&project, service, 1, nil, true) + assert.Equal(t, string(networkMode), "myProject_default") + assert.Check(t, cmp.Len(networkConfig.EndpointsConfig, 1)) + assert.Check(t, cmp.Contains(networkConfig.EndpointsConfig, "myProject_default")) }) t.Run("returns none if project has no networks", func(t *testing.T) { @@ -270,6 +278,28 @@ }, } - assert.Equal(t, getDefaultNetworkMode(&project, service), "none") + networkMode, networkConfig := defaultNetworkSettings(&project, service, 1, nil, true) + assert.Equal(t, string(networkMode), "none") + assert.Check(t, cmp.Nil(networkConfig)) + }) + + t.Run("returns defined network mode if explicitly set", func(t *testing.T) { + service := composetypes.ServiceConfig{ + Name: "myService", + NetworkMode: "host", + } + project := composetypes.Project{ + Name: "myProject", + Services: []composetypes.ServiceConfig{service}, + Networks: composetypes.Networks(map[string]composetypes.NetworkConfig{ + "default": { + Name: "myProject_default", + }, + }), + } + + networkMode, networkConfig := defaultNetworkSettings(&project, service, 1, nil, true) + assert.Equal(t, string(networkMode), "host") + assert.Check(t, cmp.Nil(networkConfig)) }) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/pkg/compose/run.go new/compose-2.19.1/pkg/compose/run.go --- old/compose-2.19.0/pkg/compose/run.go 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/pkg/compose/run.go 2023-06-29 22:50:10.000000000 +0200 @@ -99,8 +99,14 @@ return "", err } } - created, err := s.createContainer(ctx, project, service, service.ContainerName, 1, - opts.AutoRemove, opts.UseNetworkAliases, opts.Interactive) + createOpts := createOptions{ + AutoRemove: opts.AutoRemove, + AttachStdin: opts.Interactive, + UseNetworkAliases: opts.UseNetworkAliases, + Labels: mergeLabels(service.Labels, service.CustomLabels), + } + + created, err := s.createContainer(ctx, project, service, service.ContainerName, 1, createOpts) if err != nil { return "", err } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/pkg/compose/watch.go new/compose-2.19.1/pkg/compose/watch.go --- old/compose-2.19.0/pkg/compose/watch.go 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/pkg/compose/watch.go 2023-06-29 22:50:10.000000000 +0200 @@ -143,6 +143,10 @@ var paths []string for _, trigger := range config.Watch { + if checkIfPathAlreadyBindMounted(trigger.Path, service.Volumes) { + logrus.Warnf("path '%s' also declared by a bind mount volume, this path won't be monitored!\n", trigger.Path) + continue + } paths = append(paths, trigger.Path) } @@ -383,3 +387,12 @@ } } } + +func checkIfPathAlreadyBindMounted(watchPath string, volumes []types.ServiceVolumeConfig) bool { + for _, volume := range volumes { + if volume.Bind != nil && strings.HasPrefix(watchPath, volume.Source) { + return true + } + } + return false +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/pkg/e2e/compose_test.go new/compose-2.19.1/pkg/e2e/compose_test.go --- old/compose-2.19.0/pkg/e2e/compose_test.go 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/pkg/e2e/compose_test.go 2023-06-29 22:50:10.000000000 +0200 @@ -277,7 +277,7 @@ }) } -func TestStopWithDependeciesAttached(t *testing.T) { +func TestStopWithDependenciesAttached(t *testing.T) { const projectName = "compose-e2e-stop-with-deps" c := NewParallelCLI(t, WithEnv("COMMAND=echo hello")) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/pkg/watch/notify.go new/compose-2.19.1/pkg/watch/notify.go --- old/compose-2.19.0/pkg/watch/notify.go 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/pkg/watch/notify.go 2023-06-29 22:50:10.000000000 +0200 @@ -68,7 +68,7 @@ // - Watch /src/repo, but ignore /src/repo/.git // - Watch /src/repo, but ignore everything in /src/repo/bazel-bin except /src/repo/bazel-bin/app-binary // -// The PathMatcher inteface helps us manage these ignores. +// The PathMatcher interface helps us manage these ignores. type PathMatcher interface { Matches(file string) (bool, error) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/compose-2.19.0/pkg/watch/paths.go new/compose-2.19.1/pkg/watch/paths.go --- old/compose-2.19.0/pkg/watch/paths.go 2023-06-21 13:02:20.000000000 +0200 +++ new/compose-2.19.1/pkg/watch/paths.go 2023-06-29 22:50:10.000000000 +0200 @@ -59,7 +59,7 @@ } if IsChild(current, existing) { - // Mark the element empty fo removal. + // Mark the element empty for removal. result[i] = "" hasRemovals = true } ++++++ compose.obsinfo ++++++ --- /var/tmp/diff_new_pack.LQzkZU/_old 2023-06-30 19:59:57.366030266 +0200 +++ /var/tmp/diff_new_pack.LQzkZU/_new 2023-06-30 19:59:57.370030290 +0200 @@ -1,5 +1,5 @@ name: compose -version: 2.19.0 -mtime: 1687345340 -commit: db24023884cbd9657c5c64b80ea27da38e9c4cc7 +version: 2.19.1 +mtime: 1688071810 +commit: c496c230710d299834cf2586d0f75066dc60d06c ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/docker-compose/vendor.tar.gz /work/SRC/openSUSE:Factory/.docker-compose.new.13546/vendor.tar.gz differ: char 5, line 1
participants (1)
-
Source-Sync