From 3a5e7278eb149f01ac9e5ebe5d68fc40fbd95b21 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 14 Oct 2024 17:08:39 +0900 Subject: [PATCH 1/4] use docker client no timeout --- .../user_services_functions/copy_files_from_user_service.go | 5 +++-- .../backend_impls/docker/docker_manager/docker_manager.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go index 1e5fa4ac7e..b0ad542488 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go @@ -54,10 +54,11 @@ func CopyFilesFromUserService( } defer tarStreamReadCloser.Close() - if _, err := io.Copy(output, tarStreamReadCloser); err != nil { + if numBytesCopied, err := io.Copy(output, tarStreamReadCloser); err != nil { return stacktrace.Propagate( err, - "An error occurred copying the bytes of TAR'd up files at '%v' on service '%v' to the output", + "'%v' bytes copied before an error occurred copying the bytes of TAR'd up files at '%v' on service '%v' to the output", + numBytesCopied, srcPathOnContainer, serviceUuid, ) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_manager.go b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_manager.go index bd4e771c04..b76e691028 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_manager.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_manager.go @@ -1553,7 +1553,7 @@ func (manager *DockerManager) CopyFromContainer(ctx context.Context, containerId } } - tarStreamReadCloser, _, err := manager.dockerClient.CopyFromContainer( + tarStreamReadCloser, _, err := manager.dockerClientNoTimeout.CopyFromContainer( ctx, containerId, srcPath) From 21543b1599f1b0d7593912601120e4bbb970360c Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 14 Oct 2024 17:21:39 +0900 Subject: [PATCH 2/4] use context without deadline --- .../user_services_functions/copy_files_from_user_service.go | 1 + 1 file changed, 1 insertion(+) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go index b0ad542488..62677dad04 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go @@ -26,6 +26,7 @@ func CopyFilesFromUserService( output io.Writer, dockerManager *docker_manager.DockerManager, ) error { + ctx = context.WithoutCancel(ctx) srcPath := srcPathOnContainer srcPathBase := filepath.Base(srcPathOnContainer) From 98b501876d59bd340a3be9acf1c0e43867d3be61 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 14 Oct 2024 17:34:36 +0900 Subject: [PATCH 3/4] name context --- .../user_services_functions/copy_files_from_user_service.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go index 62677dad04..63d2c2526f 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go @@ -26,7 +26,7 @@ func CopyFilesFromUserService( output io.Writer, dockerManager *docker_manager.DockerManager, ) error { - ctx = context.WithoutCancel(ctx) + ctxWithoutCancel := context.WithoutCancel(ctx) srcPath := srcPathOnContainer srcPathBase := filepath.Base(srcPathOnContainer) @@ -36,13 +36,13 @@ func CopyFilesFromUserService( } logrus.Debugf("Copying contents from the src path: %v and base %v", srcPath, srcPathBase) - _, serviceDockerResources, err := getSingleUserServiceObjAndResourcesNoMutex(ctx, enclaveId, serviceUuid, dockerManager) + _, serviceDockerResources, err := getSingleUserServiceObjAndResourcesNoMutex(ctxWithoutCancel, enclaveId, serviceUuid, dockerManager) if err != nil { return stacktrace.Propagate(err, "An error occurred getting user service with UUID '%v' in enclave with ID '%v'", serviceUuid, enclaveId) } container := serviceDockerResources.ServiceContainer - tarStreamReadCloser, err := dockerManager.CopyFromContainer(ctx, container.GetId(), srcPath) + tarStreamReadCloser, err := dockerManager.CopyFromContainer(ctxWithoutCancel, container.GetId(), srcPath) if err != nil { return stacktrace.Propagate( err, From e5f579f5457a0534ede3e986acabe3228db10692 Mon Sep 17 00:00:00 2001 From: Tedi Mitiku Date: Mon, 14 Oct 2024 17:47:43 +0900 Subject: [PATCH 4/4] use original context --- .../user_services_functions/copy_files_from_user_service.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go index 63d2c2526f..538bc62511 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/user_services_functions/copy_files_from_user_service.go @@ -26,8 +26,6 @@ func CopyFilesFromUserService( output io.Writer, dockerManager *docker_manager.DockerManager, ) error { - ctxWithoutCancel := context.WithoutCancel(ctx) - srcPath := srcPathOnContainer srcPathBase := filepath.Base(srcPathOnContainer) if srcPathBase == doNotIncludeParentDirInArchiveSymbol { @@ -36,13 +34,13 @@ func CopyFilesFromUserService( } logrus.Debugf("Copying contents from the src path: %v and base %v", srcPath, srcPathBase) - _, serviceDockerResources, err := getSingleUserServiceObjAndResourcesNoMutex(ctxWithoutCancel, enclaveId, serviceUuid, dockerManager) + _, serviceDockerResources, err := getSingleUserServiceObjAndResourcesNoMutex(ctx, enclaveId, serviceUuid, dockerManager) if err != nil { return stacktrace.Propagate(err, "An error occurred getting user service with UUID '%v' in enclave with ID '%v'", serviceUuid, enclaveId) } container := serviceDockerResources.ServiceContainer - tarStreamReadCloser, err := dockerManager.CopyFromContainer(ctxWithoutCancel, container.GetId(), srcPath) + tarStreamReadCloser, err := dockerManager.CopyFromContainer(ctx, container.GetId(), srcPath) if err != nil { return stacktrace.Propagate( err,