diff --git a/cmd/hi/cleanup.go b/cmd/hi/cleanup.go index e0268fd8..8dc57b4b 100644 --- a/cmd/hi/cleanup.go +++ b/cmd/hi/cleanup.go @@ -10,11 +10,11 @@ import ( "time" "github.com/cenkalti/backoff/v5" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" - "github.com/docker/docker/errdefs" ) // cleanupBeforeTest performs cleanup operations before running tests. @@ -309,9 +309,9 @@ func cleanCacheVolume(ctx context.Context) error { err = cli.VolumeRemove(ctx, volumeName, true) if err != nil { - if errdefs.IsNotFound(err) { + if cerrdefs.IsNotFound(err) { fmt.Printf("Go module cache volume not found: %s\n", volumeName) - } else if errdefs.IsConflict(err) { + } else if cerrdefs.IsConflict(err) { fmt.Printf("Go module cache volume is in use and cannot be removed: %s\n", volumeName) } else { fmt.Printf("Failed to remove Go module cache volume %s: %v\n", volumeName, err) diff --git a/cmd/hi/docker.go b/cmd/hi/docker.go index 3ad70173..fbc2dba6 100644 --- a/cmd/hi/docker.go +++ b/cmd/hi/docker.go @@ -14,6 +14,7 @@ import ( "strings" "time" + cerrdefs "github.com/containerd/errdefs" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/mount" @@ -502,9 +503,9 @@ func getDockerSocketPath() string { // checkImageAvailableLocally checks if the specified Docker image is available locally. func checkImageAvailableLocally(ctx context.Context, cli *client.Client, imageName string) (bool, error) { - _, _, err := cli.ImageInspectWithRaw(ctx, imageName) + _, err := cli.ImageInspect(ctx, imageName) if err != nil { - if client.IsErrNotFound(err) { + if cerrdefs.IsNotFound(err) { return false, nil } diff --git a/cmd/hi/stats.go b/cmd/hi/stats.go index 1c17df84..e80ee8d1 100644 --- a/cmd/hi/stats.go +++ b/cmd/hi/stats.go @@ -12,7 +12,6 @@ import ( "sync" "time" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" @@ -153,13 +152,13 @@ func (sc *StatsCollector) monitorDockerEvents(ctx context.Context, runID string, case event := <-events: if event.Type == "container" && event.Action == "start" { // Get container details - containerInfo, err := sc.client.ContainerInspect(ctx, event.ID) + containerInfo, err := sc.client.ContainerInspect(ctx, event.Actor.ID) if err != nil { continue } - // Convert to types.Container format for consistency - cont := types.Container{ + // Convert to container.Summary format for consistency + cont := container.Summary{ ID: containerInfo.ID, Names: []string{containerInfo.Name}, Labels: containerInfo.Config.Labels, @@ -180,7 +179,7 @@ func (sc *StatsCollector) monitorDockerEvents(ctx context.Context, runID string, } // shouldMonitorContainer determines if a container should be monitored. -func (sc *StatsCollector) shouldMonitorContainer(cont types.Container, runID string) bool { +func (sc *StatsCollector) shouldMonitorContainer(cont container.Summary, runID string) bool { // Check if it has the correct run ID label if cont.Labels == nil || cont.Labels["hi.run-id"] != runID { return false @@ -241,7 +240,7 @@ func (sc *StatsCollector) collectStatsForContainer(ctx context.Context, containe decoder := json.NewDecoder(statsResponse.Body) - var prevStats *container.Stats + var prevStats *container.StatsResponse for { select { @@ -250,7 +249,7 @@ func (sc *StatsCollector) collectStatsForContainer(ctx context.Context, containe case <-ctx.Done(): return default: - var stats container.Stats + var stats container.StatsResponse if err := decoder.Decode(&stats); err != nil { // EOF is expected when container stops or stream ends if err.Error() != "EOF" && verbose { @@ -299,7 +298,7 @@ func (sc *StatsCollector) collectStatsForContainer(ctx context.Context, containe } // calculateCPUPercent calculates CPU usage percentage from Docker stats. -func calculateCPUPercent(prevStats, stats *container.Stats) float64 { +func calculateCPUPercent(prevStats, stats *container.StatsResponse) float64 { // CPU calculation based on Docker's implementation cpuDelta := float64(stats.CPUStats.CPUUsage.TotalUsage) - float64(prevStats.CPUStats.CPUUsage.TotalUsage) systemDelta := float64(stats.CPUStats.SystemUsage) - float64(prevStats.CPUStats.SystemUsage) diff --git a/integration/scenario.go b/integration/scenario.go index 0108a1de..e209f6ea 100644 --- a/integration/scenario.go +++ b/integration/scenario.go @@ -96,7 +96,7 @@ type User struct { type Scenario struct { // TODO(kradalby): support multiple headcales for later, currently only // use one. - controlServers *xsync.MapOf[string, ControlServer] + controlServers *xsync.Map[string, ControlServer] derpServers []*dsic.DERPServerInContainer users map[string]*User @@ -180,7 +180,7 @@ func NewScenario(spec ScenarioSpec) (*Scenario, error) { testHashPrefix := "hs-" + util.MustGenerateRandomStringDNSSafe(scenarioHashLength) s := &Scenario{ - controlServers: xsync.NewMapOf[string, ControlServer](), + controlServers: xsync.NewMap[string, ControlServer](), users: make(map[string]*User), pool: pool,