Skip to content

Initial setup#2

Merged
bobbyiliev merged 16 commits intomainfrom
initial-setup
Apr 18, 2025
Merged

Initial setup#2
bobbyiliev merged 16 commits intomainfrom
initial-setup

Conversation

@bobbyiliev
Copy link
Collaborator

@bobbyiliev bobbyiliev commented Apr 11, 2025

I've also started preparing a PR for the GCP Terraform module here: MaterializeInc/terraform-google-materialize#44

@bobbyiliev bobbyiliev force-pushed the initial-setup branch 2 times, most recently from 9964e9e to 84ac4f2 Compare April 11, 2025 14:54
@bobbyiliev bobbyiliev requested a review from jubrad April 11, 2025 14:58
Comment on lines +19 to +24
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
severity: error
check_together: "yes"
formats: sh
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT
I'd just move this to a bin/lint script that can get called... you can check out i2's pre-commit for example, but doing this via local script call that also installs necessary packages makes it way easier to use locally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoa there! unit testing bash!?
@alex-hunt-materialize is gonna love this.

Comment on lines +41 to +43
git clone https://github.com/bats-core/bats-support.git /tmp/bats-support
git clone https://github.com/bats-core/bats-assert.git /tmp/bats-assert
git clone https://github.com/bats-core/bats-file.git /tmp/bats-file
Copy link
Contributor

Choose a reason for hiding this comment

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

might want to lock these versions down .

manage-taints.sh Outdated
echo "Removing taint $TAINT_KEY from node $NODE_NAME"

kubectl --server="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}" \
--token="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \
Copy link
Contributor

Choose a reason for hiding this comment

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

Does kubectl not automatically detect this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh good point, I'll need to check this.

jq -r '.blockdevices[] | select(.model // empty | contains("Amazon EC2 NVMe Instance Storage")) | .path' 2>/dev/null) && [ -n "$lsblk_output" ]; then
echo "$lsblk_output"
else
nvme list | grep "Amazon EC2 NVMe Instance Storage" | awk '{print $1}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need both ways here?

echo "$CLOUD_PROVIDER"
return 0
else
echo "ERROR: CLOUD_PROVIDER environment variable is required" >&2
Copy link
Contributor

Choose a reason for hiding this comment

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

You are setting this as a bash variable above, when it gets passed as an arg. If they set it as an env var, it won't work. Please tell them to pass the --cloud-provider arg instead.


echo "Starting NVMe disk configuration..."

if ! CLOUD_PROVIDER=$(detect_cloud_provider); then
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ! CLOUD_PROVIDER=$(detect_cloud_provider); then
if [[ -z "$CLOUD_PROVIDER" ]]; then

I see no need for detect_cloud_provider at all if you aren't doing any detection.

manage-taints.sh Outdated
echo "Usage: $0 [remove]"
exit 1
;;
esac
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not call the script remove-taint.sh and not have to parse this arg?

manage-taints.sh Outdated

TAINT_KEY="disk-unconfigured"

if [ -z "${NODE_NAME:-}" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, it's a bit weird to mix env var parsing and args.

manage-taints.sh Outdated
Comment on lines +25 to +33
if [ -z "$KUBERNETES_SERVICE_HOST" ] || [ -z "$KUBERNETES_SERVICE_PORT" ]; then
echo "Error: Kubernetes service environment variables not found"
exit 1
fi

if [ ! -f "/var/run/secrets/kubernetes.io/serviceaccount/token" ]; then
echo "Error: Service account token not found"
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

kubectl should automatically detect this stuff, and possibly other auth methods. No need to manually check this.

manage-taints.sh Outdated
;;
esac

exit 0
Copy link
Contributor

Choose a reason for hiding this comment

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

exit 0 at the end of a script is almost always redundant. Better to remove it, so if you forget set -e you don't accidentally hide a failure.

@bobbyiliev bobbyiliev merged commit e2e93c2 into main Apr 18, 2025
2 checks passed
@bobbyiliev bobbyiliev deleted the initial-setup branch April 18, 2025 16:03
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.

3 participants