Skip to content

Commit 78e9a13

Browse files
authored
Fix kubectl-mongodb download location and permissions required for Code Snippets (#575)
# Summary Multi cluster code snippets require `kubectl-mongodb` plugin being available in the PATH. Previous attempt #565 failed, because the file was not in the correct path (missing evg workdir) and didn't have required permissions (they were lost during `shutil.copyfiles` execution) ## Proof of Work Passing prerelease code snippets tests -> https://spruce.mongodb.com/version/690db4a65b72a10007e62a47 ## Checklist - [ ] Have you linked a jira ticket and/or is the ticket in the title? - [ ] Have you checked whether your jira ticket required DOCSP changes? - [ ] Have you added changelog file? - use `skip-changelog` label if not needed - refer to [Changelog files and Release Notes](https://github.com/mongodb/mongodb-kubernetes/blob/master/CONTRIBUTING.md#changelog-files-and-release-notes) section in CONTRIBUTING.md for more details
1 parent 05b9fac commit 78e9a13

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.evergreen-functions.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ functions:
524524
download_multi_cluster_binary:
525525
- command: subprocess.exec
526526
params:
527+
include_expansions_in_env:
528+
- workdir
527529
working_dir: src/github.com/mongodb/mongodb-kubernetes
528530
binary: scripts/release/kubectl_mongodb/download_kubectl_plugin.sh
529531
env:
@@ -791,6 +793,8 @@ functions:
791793
- code_snippets_reset
792794
- task_name
793795
- MDB_BASH_DEBUG
796+
add_to_path:
797+
- ${workdir}/bin
794798
script: |
795799
./scripts/code_snippets/tests/${task_name}
796800

scripts/release/kubectl_mongodb/download_kubectl_plugin.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ def download_kubectl_plugin_from_s3(
4141
# change the file's permissions to make file executable
4242
os.chmod(local_path, 0o755)
4343

44+
logger.info(f"Successfully downloaded artifact to {local_path}")
45+
4446
if copy_to_bin_path:
45-
shutil.copyfile(local_path, KUBECTL_MONGODB_PLUGIN_BIN_PATH)
47+
kubectl_mongodb_workdir_path = os.path.join(os.getenv("workdir", ""), KUBECTL_MONGODB_PLUGIN_BIN_PATH)
48+
# copy content, stat-info (mode too), timestamps..
49+
shutil.copy2(local_path, kubectl_mongodb_workdir_path)
50+
# preserve owner and group
51+
st = os.stat(local_path)
52+
os.chown(kubectl_mongodb_workdir_path, st.st_uid, st.st_gid)
53+
54+
logger.info(f"Copied kubectl-mongodb plugin to {kubectl_mongodb_workdir_path} for tests usage")
4655

47-
logger.info(
48-
f"Successfully downloaded artifact to {local_path}{f" and {KUBECTL_MONGODB_PLUGIN_BIN_PATH}" if copy_to_bin_path else ""}"
49-
)
5056
except ClientError as e:
5157
if e.response["Error"]["Code"] == "404":
5258
raise Exception(f"Artifact not found at s3://{s3_bucket}/{s3_plugin_path}: {e}")

0 commit comments

Comments
 (0)