Skip to content

Don't review: simple reader testing + building csi from scratch#1166

Draft
raj-prince wants to merge 1 commit intomainfrom
princer_csi_test
Draft

Don't review: simple reader testing + building csi from scratch#1166
raj-prince wants to merge 1 commit intomainfrom
princer_csi_test

Conversation

@raj-prince
Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@google-oss-prow
Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @raj-prince, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on enhancing the developer experience for building, deploying, and testing the GCS FUSE CSI driver. It includes minor adjustments to the Docker build process to resolve potential permission conflicts and integrates clear logging markers for custom builds. Furthermore, it provides a comprehensive set of scripts and Kubernetes manifests to automate the creation of a GKE test environment, deploy a test application, and offer a collection of command-line shortcuts for efficient interaction and troubleshooting of the CSI driver components.

Highlights

  • Build Process Enhancement: Modified the Makefile to include the --user flag in Docker build commands, ensuring that artifacts created within the container have the correct ownership matching the host user, which prevents permission issues during local development.
  • Custom Build Identification: Added explicit klog.Info statements across various CSI driver components (CSI Driver, Metadata Prefetch, Sidecar Mounter, Webhook) to clearly mark them as 'CUSTOM BUILD - Manual Test Version' in logs, aiding in debugging and verification.
  • Automated Testing and Debugging Utilities: Introduced a suite of new scripts and YAML configurations (create_cluster.sh, setup-test-pod.sh, shortcuts.sh, test-pod.yaml) to streamline the setup of a GKE cluster, deployment of a GCS FUSE CSI driver test pod, and provide convenient command-line aliases for monitoring and debugging.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: raj-prince

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several changes primarily for testing purposes, including adding debug logs to Go files and creating new shell scripts for environment setup. The modification in the Makefile to specify the user in docker run commands is a good improvement for security and file permissions. The newly added shell scripts contain hardcoded values, which limits their reusability, and some aliases could be refactored for better readability and portability. Additionally, temporary debug logs have been added across multiple Go files, which should be removed before merging to maintain clean production logs.

klog.InitFlags(nil)
flag.Parse()

klog.Info("*** CUSTOM BUILD: CSI Driver - Manual Test Version ***")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This appears to be a temporary logging statement for debugging or testing purposes. Such logs should be removed before merging to avoid cluttering production logs.

klog.InitFlags(nil)
flag.Parse()

klog.Info("*** CUSTOM BUILD: Metadata Prefetch - Manual Test Version ***")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This appears to be a temporary logging statement for debugging or testing purposes. Such logs should be removed before merging to avoid cluttering production logs.

klog.InitFlags(nil)
flag.Parse()

klog.Info("*** CUSTOM BUILD: Sidecar Mounter - Manual Test Version ***")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This appears to be a temporary logging statement for debugging or testing purposes. Such logs should be removed before merging to avoid cluttering production logs.

klog.InitFlags(nil)
flag.Parse()

klog.Info("*** CUSTOM BUILD: Webhook - Manual Test Version ***")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This appears to be a temporary logging statement for debugging or testing purposes. Such logs should be removed before merging to avoid cluttering production logs.

Comment on lines +1 to +36
gcloud beta container --project "gcs-tess" clusters create "rapid-ga-test-cluster-us-west4a" \
--zone "us-west4-a" \
--no-enable-basic-auth \
--cluster-version "1.33.5-gke.2072000" \
--release-channel "regular" \
--machine-type "c4-standard-192" \
--image-type "COS_CONTAINERD" \
--disk-type "hyperdisk-balanced" \
--disk-size "400" \
--metadata disable-legacy-endpoints=true \
--service-account "default" \
--max-pods-per-node "110" \
--num-nodes "8" \
--logging=SYSTEM,WORKLOAD \
--monitoring=SYSTEM,STORAGE,POD,DEPLOYMENT,STATEFULSET,DAEMONSET,HPA,CADVISOR,KUBELET \
--enable-ip-alias \
--network "projects/gcs-tess/global/networks/default" \
--subnetwork "projects/gcs-tess/regions/us-west4/subnetworks/default" \
--cluster-secondary-range-name "geertj-pods" \
--no-enable-intra-node-visibility \
--default-max-pods-per-node "110" \
--enable-ip-access \
--security-posture=standard \
--workload-vulnerability-scanning=disabled \
--addons HorizontalPodAutoscaling,HttpLoadBalancing,GcePersistentDiskCsiDriver \
--enable-autoupgrade \
--enable-autorepair \
--max-surge-upgrade 1 \
--max-unavailable-upgrade 0 \
--binauthz-evaluation-mode=DISABLED \
--enable-shielded-nodes \
--shielded-integrity-monitoring \
--no-shielded-secure-boot \
--node-locations "us-west4-a" \
--enable-gvnic \
--workload-pool=gcs-tess.svc.id.goog No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This script has several issues that affect its usability and correctness:

  1. It is missing a shebang (e.g., #!/bin/bash) at the beginning of the file.
  2. It contains many hardcoded values (e.g., project ID, cluster name, zone). These should be parameterized using variables to make the script reusable.
  3. The file is missing a newline at the end.

I suggest refactoring it to use variables for configuration and adding a shebang.

#!/bin/bash
set -euo pipefail

# Configuration
PROJECT="gcs-tess"
CLUSTER_NAME="rapid-ga-test-cluster-us-west4a"
ZONE="us-west4-a"
CLUSTER_VERSION="1.33.5-gke.2072000"
RELEASE_CHANNEL="regular"
MACHINE_TYPE="c4-standard-192"
IMAGE_TYPE="COS_CONTAINERD"
DISK_TYPE="hyperdisk-balanced"
DISK_SIZE="400"
NUM_NODES="8"
WORKLOAD_POOL="${PROJECT}.svc.id.goog"
CLUSTER_SECONDARY_RANGE_NAME="geertj-pods"

gcloud beta container --project "${PROJECT}" clusters create "${CLUSTER_NAME}" \
  --zone "${ZONE}" \
  --no-enable-basic-auth \
  --cluster-version "${CLUSTER_VERSION}" \
  --release-channel "${RELEASE_CHANNEL}" \
  --machine-type "${MACHINE_TYPE}" \
  --image-type "${IMAGE_TYPE}" \
  --disk-type "${DISK_TYPE}" \
  --disk-size "${DISK_SIZE}" \
  --metadata disable-legacy-endpoints=true \
  --service-account "default" \
  --max-pods-per-node "110" \
  --num-nodes "${NUM_NODES}" \
  --logging=SYSTEM,WORKLOAD \
  --monitoring=SYSTEM,STORAGE,POD,DEPLOYMENT,STATEFULSET,DAEMONSET,HPA,CADVISOR,KUBELET \
  --enable-ip-alias \
  --network "projects/${PROJECT}/global/networks/default" \
  --subnetwork "projects/${PROJECT}/regions/us-west4/subnetworks/default" \
  --cluster-secondary-range-name "${CLUSTER_SECONDARY_RANGE_NAME}" \
  --no-enable-intra-node-visibility \
  --default-max-pods-per-node "110" \
  --enable-ip-access \
  --security-posture=standard \
  --workload-vulnerability-scanning=disabled \
  --addons HorizontalPodAutoscaling,HttpLoadBalancing,GcePersistentDiskCsiDriver \
  --enable-autoupgrade \
  --enable-autorepair \
  --max-surge-upgrade 1 \
  --max-unavailable-upgrade 0 \
  --binauthz-evaluation-mode=DISABLED \
  --enable-shielded-nodes \
  --shielded-integrity-monitoring \
  --no-shielded-secure-boot \
  --node-locations "${ZONE}" \
  --enable-gvnic \
  --workload-pool="${WORKLOAD_POOL}"

Comment on lines +12 to +17
PROJECT_ID="gcs-tess"
PROJECT_NUMBER="222564316065"
NAMESPACE="gcs-csi-test"
# BUCKET_NAME="gcs-fuse-warp-test-bucket"
BUCKET_NAME="princer-zonal-us-west4-a"
KSA_NAME="gcs-csi-test-sa"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The script contains hardcoded values for project ID, project number, namespace, bucket name, and KSA name. This makes the script difficult to reuse in different environments or for different tests. Consider parameterizing these values using environment variables with defaults or command-line arguments.

Suggested change
PROJECT_ID="gcs-tess"
PROJECT_NUMBER="222564316065"
NAMESPACE="gcs-csi-test"
# BUCKET_NAME="gcs-fuse-warp-test-bucket"
BUCKET_NAME="princer-zonal-us-west4-a"
KSA_NAME="gcs-csi-test-sa"
PROJECT_ID="${PROJECT_ID:-gcs-tess}"
PROJECT_NUMBER="${PROJECT_NUMBER:-222564316065}"
NAMESPACE="${NAMESPACE:-gcs-csi-test}"
# BUCKET_NAME="gcs-fuse-warp-test-bucket"
BUCKET_NAME="${BUCKET_NAME:-princer-zonal-us-west4-a}"
KSA_NAME="${KSA_NAME:-gcs-csi-test-sa}"

if [[ "$SKIP_SETUP" == "false" ]]; then
# Create GCS bucket
echo -e "\n1. Creating GCS bucket..."
gsutil mb -p $PROJECT_ID -l us-central1 gs://$BUCKET_NAME || echo "Bucket may already exist"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The command gsutil mb ... || echo "..." suppresses the exit code of gsutil mb. If gsutil mb fails for a reason other than the bucket already existing (e.g., authentication issue), set -e will not be triggered, and the script will continue, potentially leading to failures later on. A more robust approach would be to check if the bucket exists before attempting to create it.

Suggested change
gsutil mb -p $PROJECT_ID -l us-central1 gs://$BUCKET_NAME || echo "Bucket may already exist"
gsutil ls -b "gs://$BUCKET_NAME" &>/dev/null || gsutil mb -p "$PROJECT_ID" -l us-central1 "gs://$BUCKET_NAME"

alias desc-csi='kubectl describe daemonset gcsfusecsi-node'

# Check all custom builds
alias check-custom='echo "=== CSI Driver ===" && kubectl logs daemonset/gcsfusecsi-node -c gcs-fuse-csi-driver -n gcs-fuse-csi-driver --tail=100 | grep "CUSTOM BUILD" | head -2 && echo -e "\n=== Webhook ===" && kubectl logs deployment/gcs-fuse-csi-driver-webhook -n gcs-fuse-csi-driver --tail=100 | grep "CUSTOM BUILD" | head -2 && echo -e "\n=== Sidecar ===" && kubectl logs gcs-csi-test-pod -c gke-gcsfuse-sidecar -n gcs-csi-test --tail=100 2>/dev/null | grep "CUSTOM BUILD" | head -2 || echo "No sidecar pod found"'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check-custom alias is very long and complex, which makes it hard to read and maintain. It's better to define it as a function for improved readability.

Suggested change
alias check-custom='echo "=== CSI Driver ===" && kubectl logs daemonset/gcsfusecsi-node -c gcs-fuse-csi-driver -n gcs-fuse-csi-driver --tail=100 | grep "CUSTOM BUILD" | head -2 && echo -e "\n=== Webhook ===" && kubectl logs deployment/gcs-fuse-csi-driver-webhook -n gcs-fuse-csi-driver --tail=100 | grep "CUSTOM BUILD" | head -2 && echo -e "\n=== Sidecar ===" && kubectl logs gcs-csi-test-pod -c gke-gcsfuse-sidecar -n gcs-csi-test --tail=100 2>/dev/null | grep "CUSTOM BUILD" | head -2 || echo "No sidecar pod found"'
check-custom() {
echo "=== CSI Driver ==="
kubectl logs daemonset/gcsfusecsi-node -c gcs-fuse-csi-driver -n gcs-fuse-csi-driver --tail=100 | grep "CUSTOM BUILD" | head -2
echo -e "\n=== Webhook ==="
kubectl logs deployment/gcs-fuse-csi-driver-webhook -n gcs-fuse-csi-driver --tail=100 | grep "CUSTOM BUILD" | head -2
echo -e "\n=== Sidecar ==="
kubectl logs gcs-csi-test-pod -c gke-gcsfuse-sidecar -n gcs-csi-test --tail=100 2>/dev/null | grep "CUSTOM BUILD" | head -2 || echo "No sidecar pod found"
}

Comment on lines +44 to +47
alias rebuild='cd /home/princer_google_com/dev/gcs-fuse-csi-driver && export PROJECT_ID=gcs-tess REGISTRY=gcr.io/gcs-tess/princer STAGINGVERSION=v999.999.999 BUILD_GCSFUSE_FROM_SOURCE=true && make build-image-and-push-multi-arch REGISTRY=$REGISTRY STAGINGVERSION=$STAGINGVERSION'
alias reinstall='cd /home/princer_google_com/dev/gcs-fuse-csi-driver && export REGISTRY=gcr.io/gcs-tess/princer STAGINGVERSION=v999.999.999 && make uninstall && make install'
alias update-csi='cd /home/princer_google_com/dev/gcs-fuse-csi-driver && export REGISTRY=gcr.io/gcs-tess/princer STAGINGVERSION=v999.999.999 && kubectl set image daemonset/gcsfusecsi-node gcs-fuse-csi-driver=$REGISTRY/gcs-fuse-csi-driver:$STAGINGVERSION -n gcs-fuse-csi-driver && kubectl set image deployment/gcs-fuse-csi-driver-webhook gcs-fuse-csi-driver-webhook=$REGISTRY/gcs-fuse-csi-driver-webhook:$STAGINGVERSION -n gcs-fuse-csi-driver'
alias recreate-pod='cd /home/princer_google_com/dev/gcs-fuse-csi-driver && ./setup-test-pod.sh --skip-setup'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The aliases rebuild, reinstall, update-csi, and recreate-pod contain a hardcoded absolute path /home/princer_google_com/dev/gcs-fuse-csi-driver. This makes the script specific to one user's environment and not portable. Consider using a variable for the path, which can be configured by the user. Also, using a subshell (...) for commands that change directory is a good practice to avoid changing the current directory of the user's shell.

Suggested change
alias rebuild='cd /home/princer_google_com/dev/gcs-fuse-csi-driver && export PROJECT_ID=gcs-tess REGISTRY=gcr.io/gcs-tess/princer STAGINGVERSION=v999.999.999 BUILD_GCSFUSE_FROM_SOURCE=true && make build-image-and-push-multi-arch REGISTRY=$REGISTRY STAGINGVERSION=$STAGINGVERSION'
alias reinstall='cd /home/princer_google_com/dev/gcs-fuse-csi-driver && export REGISTRY=gcr.io/gcs-tess/princer STAGINGVERSION=v999.999.999 && make uninstall && make install'
alias update-csi='cd /home/princer_google_com/dev/gcs-fuse-csi-driver && export REGISTRY=gcr.io/gcs-tess/princer STAGINGVERSION=v999.999.999 && kubectl set image daemonset/gcsfusecsi-node gcs-fuse-csi-driver=$REGISTRY/gcs-fuse-csi-driver:$STAGINGVERSION -n gcs-fuse-csi-driver && kubectl set image deployment/gcs-fuse-csi-driver-webhook gcs-fuse-csi-driver-webhook=$REGISTRY/gcs-fuse-csi-driver-webhook:$STAGINGVERSION -n gcs-fuse-csi-driver'
alias recreate-pod='cd /home/princer_google_com/dev/gcs-fuse-csi-driver && ./setup-test-pod.sh --skip-setup'
alias rebuild='(cd ${GCS_FUSE_CSI_DRIVER_PATH:-/home/princer_google_com/dev/gcs-fuse-csi-driver} && export PROJECT_ID=gcs-tess REGISTRY=gcr.io/gcs-tess/princer STAGINGVERSION=v999.999.999 BUILD_GCSFUSE_FROM_SOURCE=true && make build-image-and-push-multi-arch REGISTRY=$REGISTRY STAGINGVERSION=$STAGINGVERSION)'
alias reinstall='(cd ${GCS_FUSE_CSI_DRIVER_PATH:-/home/princer_google_com/dev/gcs-fuse-csi-driver} && export REGISTRY=gcr.io/gcs-tess/princer STAGINGVERSION=v999.999.999 && make uninstall && make install)'
alias update-csi='(cd ${GCS_FUSE_CSI_DRIVER_PATH:-/home/princer_google_com/dev/gcs-fuse-csi-driver} && export REGISTRY=gcr.io/gcs-tess/princer STAGINGVERSION=v999.999.999 && kubectl set image daemonset/gcsfusecsi-node gcs-fuse-csi-driver=$REGISTRY/gcs-fuse-csi-driver:$STAGINGVERSION -n gcs-fuse-csi-driver && kubectl set image deployment/gcs-fuse-csi-driver-webhook gcs-fuse-csi-driver-webhook=$REGISTRY/gcs-fuse-csi-driver-webhook:$STAGINGVERSION -n gcs-fuse-csi-driver)'
alias recreate-pod='(cd ${GCS_FUSE_CSI_DRIVER_PATH:-/home/princer_google_com/dev/gcs-fuse-csi-driver} && ./setup-test-pod.sh --skip-setup)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant