From 837f0976100e0070de4106f33eb22095d4b1e9d7 Mon Sep 17 00:00:00 2001 From: defonsen Date: Mon, 21 Apr 2025 00:01:52 +0530 Subject: [PATCH 1/3] internal/libdocker: handle flush/close errors in archiveFS --- internal/libdocker/builder.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/libdocker/builder.go b/internal/libdocker/builder.go index 135ce715c0..92707a09d4 100644 --- a/internal/libdocker/builder.go +++ b/internal/libdocker/builder.go @@ -156,9 +156,13 @@ func (b *Builder) archiveFS(ctx context.Context, out io.WriteCloser, fsys fs.FS) return err } - // TODO: errors - w.Flush() - w.Close() + // Handle tar writer errors properly + if err := w.Flush(); err != nil { + return err + } + if err := w.Close(); err != nil { + return err + } return nil } From 99ff78e4dc25536e1935999f93585ab7a698a9d2 Mon Sep 17 00:00:00 2001 From: defonsen Date: Mon, 21 Apr 2025 00:02:15 +0530 Subject: [PATCH 2/3] internal/libhive: include timestamp in client log filenames --- internal/libhive/api.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/libhive/api.go b/internal/libhive/api.go index 62fecbb00e..84d4a5822c 100644 --- a/internal/libhive/api.go +++ b/internal/libhive/api.go @@ -321,11 +321,12 @@ func (api *simAPI) startClient(w http.ResponseWriter, r *http.Request) { // Note that jsonPath gets written to the result JSON and always uses '/' as the separator. // The filePath is passed to the docker backend and uses the platform separator. func (api *simAPI) clientLogFilePaths(clientName, containerID string) (jsonPath string, file string) { - // TODO: might be nice to put timestamp into the filename as well. - safeDir := strings.Replace(clientName, string(filepath.Separator), "_", -1) - jsonPath = path.Join(safeDir, fmt.Sprintf("client-%s.log", containerID)) + ts := time.Now().UTC().Format("20060102T150405Z") // yyyymmddThhmmssZ + safeDir := strings.ReplaceAll(clientName, string(filepath.Separator), "_") + fname := fmt.Sprintf("client-%s-%s.log", ts, containerID) + jsonPath = path.Join(safeDir, fname) file = filepath.Join(api.env.LogDir, filepath.FromSlash(jsonPath)) - return jsonPath, file + return } func (api *simAPI) checkClient(req *simapi.NodeConfig) (*ClientDefinition, error) { From 5b1f803a131c4355baebbfd8d705b38ab27868df Mon Sep 17 00:00:00 2001 From: defonsen Date: Mon, 21 Apr 2025 00:02:31 +0530 Subject: [PATCH 3/3] internal: remove unused MAC field from ContainerInfo struct --- internal/fakes/container.go | 3 --- internal/libdocker/container.go | 1 - internal/libhive/dockerface.go | 1 - 3 files changed, 5 deletions(-) diff --git a/internal/fakes/container.go b/internal/fakes/container.go index ccda8d1c66..5042a1bb9a 100644 --- a/internal/fakes/container.go +++ b/internal/fakes/container.go @@ -128,9 +128,6 @@ func (b *fakeBackend) StartContainer(ctx context.Context, containerID string, op ip := net.IP{192, 0, 2, byte(b.clientCounter)} info.IP = ip.String() } - if info.MAC == "" { - info.MAC = "00:80:41:ae:fd:7e" - } info.Wait = func() {} return &info, nil } diff --git a/internal/libdocker/container.go b/internal/libdocker/container.go index cc976e8499..4e1b62e8a4 100644 --- a/internal/libdocker/container.go +++ b/internal/libdocker/container.go @@ -156,7 +156,6 @@ func (b *ContainerBackend) StartContainer(ctx context.Context, containerID strin return info, err } info.IP = container.NetworkSettings.IPAddress - info.MAC = container.NetworkSettings.MacAddress // Set up the port check if requested. hasStarted := make(chan struct{}) diff --git a/internal/libhive/dockerface.go b/internal/libhive/dockerface.go index 6c0aecc23f..b63a66208f 100644 --- a/internal/libhive/dockerface.go +++ b/internal/libhive/dockerface.go @@ -69,7 +69,6 @@ type ContainerOptions struct { type ContainerInfo struct { ID string // docker container ID IP string // IP address - MAC string // MAC address. TODO: remove LogFile string // The wait function returns when the container is stopped.