From 74e9ca528a113b55c9923033b2eb3b3ba36fe12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Sierant?= Date: Wed, 14 May 2025 15:28:30 +0200 Subject: [PATCH] Fixes to search snippets --- .evergreen-functions.yml | 13 +++++++++++++ .evergreen.yml | 19 ++++++++++++++++++- docs/community-search/quick-start/README.md | 6 +----- .../community-search/quick-start/README.md.j2 | 4 ---- ...0210_verify_community_search_pullsecret.sh | 3 ++- .../code_snippets/090_helm_add_mogodb_repo.sh | 2 +- .../env_variables_e2e_prerelease.sh | 6 ++++++ .../quick-start/env_variables_e2e_public.sh | 2 ++ scripts/code_snippets/sample_commit_output.sh | 5 +++-- ...ask_kind_community_search_snippets_test.sh | 2 +- scripts/dev/contexts/evg-private-context | 4 ++++ .../dev/contexts/prerelease_gke_code_snippets | 2 +- .../contexts/prerelease_kind_code_snippets | 14 ++++++++++++++ scripts/dev/contexts/public_gke_code_snippets | 3 ++- .../dev/contexts/public_kind_code_snippets | 14 ++++++++++++++ 15 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 docs/community-search/quick-start/env_variables_e2e_prerelease.sh create mode 100644 docs/community-search/quick-start/env_variables_e2e_public.sh create mode 100644 scripts/dev/contexts/prerelease_kind_code_snippets create mode 100644 scripts/dev/contexts/public_kind_code_snippets diff --git a/.evergreen-functions.yml b/.evergreen-functions.yml index 98a898321..72c22c6a1 100644 --- a/.evergreen-functions.yml +++ b/.evergreen-functions.yml @@ -445,7 +445,20 @@ functions: aws_secret: ${enterprise_aws_secret_access_key} local_files_include_filter: - src/github.com/mongodb/mongodb-kubernetes/public/architectures/**/*.log + - src/github.com/mongodb/mongodb-kubernetes/docs/**/*.log + remote_file: logs/${task_id}/${execution}/ + bucket: operator-e2e-artifacts + permissions: private + visibility: signed + content_type: text/plain + - command: s3.put + params: + aws_key: ${enterprise_aws_access_key_id} + aws_secret: ${enterprise_aws_secret_access_key} + local_files_include_filter: - src/github.com/mongodb/mongodb-kubernetes/public/architectures/**/*.out + - src/github.com/mongodb/mongodb-kubernetes/docs/**/*.out + preserve_path: true remote_file: logs/${task_id}/${execution}/ bucket: operator-e2e-artifacts permissions: public-read diff --git a/.evergreen.yml b/.evergreen.yml index 78e2fbf80..c30955b66 100644 --- a/.evergreen.yml +++ b/.evergreen.yml @@ -1862,13 +1862,30 @@ buildvariants: - name: private_kind_code_snippets display_name: private_kind_code_snippets - allowed_requesters: ["patch"] + tags: [ "e2e_test_suite" ] + allowed_requesters: ["patch", "github_pr"] run_on: - ubuntu2204-large <<: *base_om8_dependency tasks: - name: kind_code_snippets_task_group + - name: prerelease_kind_code_snippets + display_name: prerelease_kind_code_snippets + allowed_requesters: ["patch"] + run_on: + - ubuntu2204-large + tasks: + - name: kind_code_snippets_task_group + + - name: public_kind_code_snippets + display_name: public_kind_code_snippets + allowed_requesters: ["patch"] + run_on: + - ubuntu2204-large + tasks: + - name: kind_code_snippets_task_group + ### Build variants for manual patch only - name: publish_om60_images diff --git a/docs/community-search/quick-start/README.md b/docs/community-search/quick-start/README.md index 01998f597..3934db1ab 100644 --- a/docs/community-search/quick-start/README.md +++ b/docs/community-search/quick-start/README.md @@ -53,11 +53,7 @@ First, add the MongoDB Helm repository. This repository contains the Helm chart ```shell copy helm repo add mongodb https://mongodb.github.io/helm-charts helm repo update mongodb -if [[ "${OPERATOR_HELM_CHART}" != "helm_chart" ]]; then helm search repo "${OPERATOR_HELM_CHART}"; fi; -``` -After adding the repository, update your local Helm chart repository cache: -```shell -helm repo update +helm search repo mongodb/mongodb-kubernetes ``` ### 3. Install MongoDB Kubernetes Operator diff --git a/docs/community-search/quick-start/README.md.j2 b/docs/community-search/quick-start/README.md.j2 index ec2371869..0e3125075 100644 --- a/docs/community-search/quick-start/README.md.j2 +++ b/docs/community-search/quick-start/README.md.j2 @@ -38,10 +38,6 @@ First, add the MongoDB Helm repository. This repository contains the Helm chart ```shell copy {% include "code_snippets/090_helm_add_mogodb_repo.sh" %} ``` -After adding the repository, update your local Helm chart repository cache: -```shell -helm repo update -``` ### 3. Install MongoDB Kubernetes Operator diff --git a/docs/community-search/quick-start/code_snippets/0210_verify_community_search_pullsecret.sh b/docs/community-search/quick-start/code_snippets/0210_verify_community_search_pullsecret.sh index f9b442230..576824091 100644 --- a/docs/community-search/quick-start/code_snippets/0210_verify_community_search_pullsecret.sh +++ b/docs/community-search/quick-start/code_snippets/0210_verify_community_search_pullsecret.sh @@ -1,4 +1,4 @@ -echo "Verifying mongodb-kubernetes-database-pods contains proper pull secret" +echo "Verifying mongodb-kubernetes-database-pods service account contains proper pull secret" if ! kubectl get --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" -o json \ sa mongodb-kubernetes-database-pods -o=jsonpath='{.imagePullSecrets[*]}' | \ grep community-private-preview-pullsecret; then @@ -7,3 +7,4 @@ if ! kubectl get --context "${K8S_CLUSTER_0_CONTEXT_NAME}" -n "${MDB_NAMESPACE}" sa mongodb-kubernetes-database-pods -o=yaml return 1 fi +echo "SUCCESS: mongodb-kubernetes-database-pods service account contains proper pull secret" diff --git a/docs/community-search/quick-start/code_snippets/090_helm_add_mogodb_repo.sh b/docs/community-search/quick-start/code_snippets/090_helm_add_mogodb_repo.sh index 8b19942ad..a348a3e0f 100644 --- a/docs/community-search/quick-start/code_snippets/090_helm_add_mogodb_repo.sh +++ b/docs/community-search/quick-start/code_snippets/090_helm_add_mogodb_repo.sh @@ -1,3 +1,3 @@ helm repo add mongodb https://mongodb.github.io/helm-charts helm repo update mongodb -if [[ "${OPERATOR_HELM_CHART}" != "helm_chart" ]]; then helm search repo "${OPERATOR_HELM_CHART}"; fi; +helm search repo mongodb/mongodb-kubernetes diff --git a/docs/community-search/quick-start/env_variables_e2e_prerelease.sh b/docs/community-search/quick-start/env_variables_e2e_prerelease.sh new file mode 100644 index 000000000..b708d7786 --- /dev/null +++ b/docs/community-search/quick-start/env_variables_e2e_prerelease.sh @@ -0,0 +1,6 @@ +export K8S_CLUSTER_0_CONTEXT_NAME="${CLUSTER_NAME}" + +export PRIVATE_PREVIEW_IMAGE_PULLSECRET="${COMMUNITY_PRIVATE_PREVIEW_PULLSECRET_DOCKERCONFIGJSON}" + +export OPERATOR_ADDITIONAL_HELM_VALUES="" +export OPERATOR_HELM_CHART="${PROJECT_DIR}/helm_chart" diff --git a/docs/community-search/quick-start/env_variables_e2e_public.sh b/docs/community-search/quick-start/env_variables_e2e_public.sh new file mode 100644 index 000000000..8a835d9b7 --- /dev/null +++ b/docs/community-search/quick-start/env_variables_e2e_public.sh @@ -0,0 +1,2 @@ +export K8S_CLUSTER_0_CONTEXT_NAME="${CLUSTER_NAME}" +export PRIVATE_PREVIEW_IMAGE_PULLSECRET="${COMMUNITY_PRIVATE_PREVIEW_PULLSECRET_DOCKERCONFIGJSON}" diff --git a/scripts/code_snippets/sample_commit_output.sh b/scripts/code_snippets/sample_commit_output.sh index d54623980..0eb12227b 100755 --- a/scripts/code_snippets/sample_commit_output.sh +++ b/scripts/code_snippets/sample_commit_output.sh @@ -3,15 +3,16 @@ set -Eeou pipefail source scripts/dev/set_env_context.sh -if [ "${COMMIT_OUTPUT:-false}" = true ]; then +if [[ "${CODE_SNIPPETS_COMMIT_OUTPUT:-"false"}" == "true" ]]; then echo "Pushing output files" branch="meko-snippets-update-$(date "+%Y%m%d%H%M%S")" git checkout -b "${branch}" git reset git add public/architectures/**/*.out git add docs/**/output/*.out + git add docs/**/*.md git commit -m "Update code snippets outputs" - git remote set-url origin https://x-access-token:"${GH_TOKEN}"@github.com/mongodb/mongodb-kubernetes.git + git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/mongodb/mongodb-kubernetes.git" git push origin "${branch}" else echo "Not pushing output files" diff --git a/scripts/code_snippets/task_kind_community_search_snippets_test.sh b/scripts/code_snippets/task_kind_community_search_snippets_test.sh index c85feac37..4b4501c2c 100755 --- a/scripts/code_snippets/task_kind_community_search_snippets_test.sh +++ b/scripts/code_snippets/task_kind_community_search_snippets_test.sh @@ -12,9 +12,9 @@ trap dump_logs EXIT test_dir="./docs/community-search/quick-start" source "${test_dir}/env_variables.sh" +echo "Sourcing env variables for ${CODE_SNIPPETS_FLAVOR} flavor" # shellcheck disable=SC1090 test -f "${test_dir}/env_variables_${CODE_SNIPPETS_FLAVOR}.sh" && source "${test_dir}/env_variables_${CODE_SNIPPETS_FLAVOR}.sh" - ${test_dir}/test.sh scripts/code_snippets/kind_community_search_snippets_render_template.sh diff --git a/scripts/dev/contexts/evg-private-context b/scripts/dev/contexts/evg-private-context index 423355528..52584edc7 100644 --- a/scripts/dev/contexts/evg-private-context +++ b/scripts/dev/contexts/evg-private-context @@ -101,6 +101,10 @@ export RUNNING_IN_EVG="true" export DELETE_KIND_NETWORK="true" +# code_snippets_commit_output can be set in evergreen patch by --param code_snippets_commit_output=true +# it's also set explicitly in public_*_snippets variants +export CODE_SNIPPETS_COMMIT_OUTPUT=${code_snippets_commit_output:-"false"} + # MCO # shellcheck disable=SC2154 export READINESS_PROBE_IMAGE="268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes-readinessprobe:${version_id}" diff --git a/scripts/dev/contexts/prerelease_gke_code_snippets b/scripts/dev/contexts/prerelease_gke_code_snippets index 8eb284746..61a07676f 100644 --- a/scripts/dev/contexts/prerelease_gke_code_snippets +++ b/scripts/dev/contexts/prerelease_gke_code_snippets @@ -11,7 +11,7 @@ source "${script_dir}/root-context" export MDB_GKE_PROJECT="scratch-kubernetes-team" export K8S_CLUSTER_SUFFIX="-${version_id}-${RANDOM}" -export COMMIT_OUTPUT=true +export CODE_SNIPPETS_COMMIT_OUTPUT=true # we reset evg host to use a default ~/.kube/config for GKE instead of the one from evg host export EVG_HOST_NAME="" diff --git a/scripts/dev/contexts/prerelease_kind_code_snippets b/scripts/dev/contexts/prerelease_kind_code_snippets new file mode 100644 index 000000000..d6fea1d84 --- /dev/null +++ b/scripts/dev/contexts/prerelease_kind_code_snippets @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# this context file is for code snippets running on GKE clusters +set -Eeou pipefail + +# overrides of public env_variables.sh +script_name=$(readlink -f "${BASH_SOURCE[0]}") +script_dir=$(dirname "${script_name}") + +source "${script_dir}/root-context" + +export NAMESPACE=mongodb +export CODE_SNIPPETS_FLAVOR=e2e_prerelease +export CODE_SNIPPETS_COMMIT_OUTPUT=true diff --git a/scripts/dev/contexts/public_gke_code_snippets b/scripts/dev/contexts/public_gke_code_snippets index 8f93b699b..dddae3db9 100644 --- a/scripts/dev/contexts/public_gke_code_snippets +++ b/scripts/dev/contexts/public_gke_code_snippets @@ -10,6 +10,7 @@ script_dir=$(dirname "${script_name}") source "${script_dir}/root-context" export MDB_GKE_PROJECT="scratch-kubernetes-team" +# shellcheck disable=SC2154 export K8S_CLUSTER_SUFFIX="-${version_id}-${RANDOM}" # we reset evg host to use a default ~/.kube/config for GKE instead of the one from evg host @@ -18,4 +19,4 @@ export EVG_HOST_NAME="" # ENV_VARIABLES.SH overrides export OPERATOR_ADDITIONAL_HELM_VALUES="" export OPERATOR_HELM_CHART="" -export COMMIT_OUTPUT=true +export CODE_SNIPPETS_COMMIT_OUTPUT=true diff --git a/scripts/dev/contexts/public_kind_code_snippets b/scripts/dev/contexts/public_kind_code_snippets new file mode 100644 index 000000000..83d816c43 --- /dev/null +++ b/scripts/dev/contexts/public_kind_code_snippets @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# this context file is for code snippets running on GKE clusters +set -Eeou pipefail + +# overrides of public env_variables.sh +script_name=$(readlink -f "${BASH_SOURCE[0]}") +script_dir=$(dirname "${script_name}") + +source "${script_dir}/root-context" + +export NAMESPACE=mongodb +export CODE_SNIPPETS_FLAVOR=e2e_public +export CODE_SNIPPETS_COMMIT_OUTPUT=true