Compare commits

...

8 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
00166d05d9 Merge pull request #51782 from austinvazquez/add-api-go-package
api: add root doc.go to prevent fallback to github.com/moby/moby
2026-01-08 20:55:41 +01:00
Paweł Gronowski
fbe29f0624 Merge pull request #51816 from thaJeztah/fix_linting
internal/testutil/daemon: fix minor linting issues
2026-01-08 16:59:02 +00:00
Sebastiaan van Stijn
48f81c3782 Merge pull request #51828 from vvoland/windows-network-none
daemon/libnetwork: Fix panic in findHNSEp when IP networks are nil
2026-01-08 17:34:36 +01:00
Sebastiaan van Stijn
7bdc7569f1 Merge pull request #51827 from vvoland/fix-image-mount
daemon/volumes: More fs friendly image mount layer names
2026-01-08 16:41:39 +01:00
Paweł Gronowski
fadd8dc47c daemon/libnetwork: Fix panic in findHNSEp when IP networks are nil
Can happen for `docker run --network none ...`

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-01-08 15:01:10 +01:00
Paweł Gronowski
cb88c6ba10 daemon/volumes: More fs friendly image mount layer names
Hash the container ID, mount source and destination together to form a
layer name.

This ensures the generated names are filesystem-friendly and don't
exceed path length limits while maintaining uniqueness across different
mount points and containers.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-01-08 12:20:47 +01:00
Sebastiaan van Stijn
f2f622ebf4 internal/testutil/daemon: fix minor linting issues
- rename vars that shadowed
- suppress some unhandled errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-01-06 21:46:28 +01:00
Austin Vazquez
78c6b01902 api: add root doc.go to prevent fallback to github.com/moby/moby
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-12-22 14:32:23 -06:00
4 changed files with 23 additions and 15 deletions

1
api/doc.go Normal file
View File

@@ -0,0 +1 @@
package api

View File

@@ -251,9 +251,14 @@ func deleteEpFromResolverImpl(
}
func findHNSEp(ip4, ip6 *net.IPNet, hnsEndpoints []hcsshim.HNSEndpoint) *hcsshim.HNSEndpoint {
if ip4 == nil && ip6 == nil {
return nil
}
for _, hnsEp := range hnsEndpoints {
if (hnsEp.IPAddress != nil && hnsEp.IPAddress.Equal(ip4.IP)) ||
(hnsEp.IPv6Address != nil && hnsEp.IPv6Address.Equal(ip6.IP)) {
if ip4 != nil && hnsEp.IPAddress != nil && hnsEp.IPAddress.Equal(ip4.IP) {
return &hnsEp
}
if ip6 != nil && hnsEp.IPv6Address != nil && hnsEp.IPv6Address.Equal(ip6.IP) {
return &hnsEp
}
}

View File

@@ -2,6 +2,7 @@ package daemon
import (
"context"
"crypto/sha256"
"encoding/hex"
"maps"
"os"
@@ -258,10 +259,11 @@ func (daemon *Daemon) registerMountPoints(ctr *container.Container, defaultReadO
StorageOpt: ctr.HostConfig.StorageOpt,
}
// Include the destination in the layer name to make it unique for each mount point and container.
// Hash the source and destination to create a safe, unique identifier for each mount point and container.
// This makes sure that the same image can be mounted multiple times with different destinations.
// Hex encode the destination to create a safe, unique identifier
layerName := hex.EncodeToString([]byte(ctr.ID + ",src=" + mp.Source + ",dst=" + mp.Destination))
// We hash it so that the snapshot name is friendly to the underlying filesystem and doesn't exceed path length limits.
destHash := sha256.Sum256([]byte(ctr.ID + "-src=" + mp.Source + "-dst=" + mp.Destination))
layerName := hex.EncodeToString(destHash[:])
layer, err := daemon.imageService.CreateLayerFromImage(img, layerName, rwLayerOpts)
if err != nil {
return err

View File

@@ -297,7 +297,7 @@ func (d *Daemon) NewClientT(t testing.TB, extraOpts ...client.Opt) *client.Clien
c, err := d.NewClient(extraOpts...)
assert.NilError(t, err, "[%s] could not create daemon client", d.id)
t.Cleanup(func() { c.Close() })
t.Cleanup(func() { _ = c.Close() })
return c
}
@@ -571,20 +571,20 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
close(wait)
}()
clientConfig, err := d.getClientConfig()
clientCfg, err := d.getClientConfig()
if err != nil {
return err
}
client := &http.Client{
Transport: clientConfig.transport,
httpClient := &http.Client{
Transport: clientCfg.transport,
}
req, err := http.NewRequest(http.MethodGet, "/_ping", http.NoBody)
if err != nil {
return errors.Wrapf(err, "[%s] could not create new request", d.id)
}
req.URL.Host = clientConfig.addr
req.URL.Scheme = clientConfig.scheme
req.URL.Host = clientCfg.addr
req.URL.Scheme = clientCfg.scheme
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
@@ -602,7 +602,7 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
rctx, rcancel := context.WithTimeout(context.TODO(), 2*time.Second)
defer rcancel()
resp, err := client.Do(req.WithContext(rctx))
resp, err := httpClient.Do(req.WithContext(rctx))
if err != nil {
if i > 2 { // don't log the first couple, this ends up just being noise
d.log.Logf("[%s] error pinging daemon on start: %v", d.id, err)
@@ -615,7 +615,7 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
continue
}
resp.Body.Close()
_ = resp.Body.Close()
if resp.StatusCode != http.StatusOK {
d.log.Logf("[%s] received status != 200 OK: %s\n", d.id, resp.Status)
}
@@ -644,7 +644,7 @@ func (d *Daemon) Kill() error {
}
defer func() {
d.logFile.Close()
_ = d.logFile.Close()
d.cmd = nil
}()
@@ -1062,7 +1062,7 @@ func cleanupRaftDir(t testing.TB, d *Daemon) {
// artifacts.
//
// We currently do not include container logs in the bundles, so this also
// removes the "containers" sub-directory.
// removes the "containers" subdirectory.
func cleanupDaemonStorage(t testing.TB, d *Daemon) {
t.Helper()
dirs := []string{