Skip to content

Commit dc2d8cb

Browse files
authored
fix: make k8s store service files match docker (#695)
1 parent d2b951c commit dc2d8cb

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/user_services_functions/copy_files_from_user_service.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/kurtosis-tech/stacktrace"
1212
"io"
1313
apiv1 "k8s.io/api/core/v1"
14+
"path/filepath"
1415
)
1516

1617
const (
@@ -55,9 +56,17 @@ func CopyFilesFromUserService(
5556
)
5657
}
5758

59+
// we remove trailing slash
60+
srcPath = filepath.Clean(srcPath)
61+
// we get the base dir | file
62+
srcPathBase := filepath.Base(srcPath)
63+
// we get the dir that holds base the dir | file
64+
srcPathDir := filepath.Dir(srcPath)
65+
5866
commandToRun := fmt.Sprintf(
59-
`if command -v 'tar' > /dev/null; then tar cf - '%v'; else echo "Cannot copy files from path '%v' because the tar binary doesn't exist on the machine" >&2; exit 1; fi`,
60-
srcPath,
67+
`if command -v 'tar' > /dev/null; then cd '%v' && tar cf - '%v'; else echo "Cannot copy files from path '%v' because the tar binary doesn't exist on the machine" >&2; exit 1; fi`,
68+
srcPathDir,
69+
srcPathBase,
6170
srcPath,
6271
)
6372
shWrappedCommandToRun := []string{

internal_testsuites/golang/testsuite/startosis_test/startosis_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ const (
1818
serviceName = "example-datastore-server-1"
1919
serviceIdForDependentService = "example-datastore-server-2"
2020
portId = "grpc"
21-
fileToBeCreated = "/tmp/foo"
21+
filePathOnDataStoreService = "/tmp/foo/"
22+
fileToBeCreated = filePathOnDataStoreService + "doo.txt"
2223
mountPathOnDependentService = "/tmp/doo"
23-
pathToCheckOnDependentService = mountPathOnDependentService + "/foo"
24+
pathToCheckOnDependentService = mountPathOnDependentService + "/foo/doo.txt"
2425
renderedConfigMountPath = "/config"
2526
renderedConfigRelativePath = "foo/bar.yml"
2627
renderedConfigFile = renderedConfigMountPath + "/" + renderedConfigRelativePath
@@ -31,6 +32,7 @@ DATASTORE_SERVICE_NAME = "` + serviceName + `"
3132
DATASTORE_PORT_ID = "` + portId + `"
3233
DATASTORE_PORT_NUMBER = 1323
3334
DATASTORE_PORT_PROTOCOL = "TCP"
35+
DIR_OF_FILE_TO_BE_CREATED = "` + filePathOnDataStoreService + `"
3436
FILE_TO_BE_CREATED = "` + fileToBeCreated + `"
3537
3638
SERVICE_DEPENDENT_ON_DATASTORE_SERVICE = "` + serviceIdForDependentService + `"
@@ -53,14 +55,20 @@ def run(plan, args):
5355
5456
result = plan.add_service(name = DATASTORE_SERVICE_NAME, config = config)
5557
plan.print("Service " + result.name + " deployed successfully.")
58+
plan.exec(
59+
recipe = ExecRecipe(
60+
command = ["mkdir", DIR_OF_FILE_TO_BE_CREATED],
61+
),
62+
service_name = DATASTORE_SERVICE_NAME,
63+
)
5664
plan.exec(
5765
recipe = ExecRecipe(
5866
command = ["touch", FILE_TO_BE_CREATED],
5967
),
6068
service_name = DATASTORE_SERVICE_NAME,
6169
)
6270
63-
artifact_name = plan.store_service_files(name = "stored-file", service_name = DATASTORE_SERVICE_NAME, src = FILE_TO_BE_CREATED)
71+
artifact_name = plan.store_service_files(name = "stored-file", service_name = DATASTORE_SERVICE_NAME, src = DIR_OF_FILE_TO_BE_CREATED)
6472
plan.print("Stored file at " + artifact_name)
6573
6674
template_str = read_file(TEMPLATE_FILE_TO_RENDER)
@@ -119,6 +127,7 @@ Adding service example-datastore-server-1.
119127
Service 'example-datastore-server-1' added with service UUID '[a-z-0-9]+'
120128
Service example-datastore-server-1 deployed successfully.
121129
Command returned with exit code '0' with no output
130+
Command returned with exit code '0' with no output
122131
Files with artifact name 'stored-file' uploaded with artifact UUID '[a-f0-9]{32}'
123132
Stored file at stored-file
124133
Templates artifact name 'rendered-file' rendered with artifact UUID '[a-f0-9]{32}'

0 commit comments

Comments
 (0)