-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[custom-images] deprecate gsutil command #112
base: main
Are you sure you want to change the base?
[custom-images] deprecate gsutil command #112
Conversation
96e2255
to
38aee32
Compare
All of my tests are passing, and I'm prepared to submit this change with customer's confirmation that the updates do not cause their workflow to fail. |
I've pushed these changes up to the 2025.02 branch of this repo if you'd like to test them. Here is an example of how one might exercise the script on all supported images:
|
This PR includes recent changes I've made as I've iterated on the examples in the example/secure-boot/ as well as a patch to fix issue README.md custom_image_utils/args_parser.py tests/test_args_parser.py * returned default disk size to 30GB. It could be 20GB since the base image only occupies 18GB, but the sourcedisk image is already set to 30GB, so we'll maintain that. If we need a large disk, we can specify the size at the time of image generation. custom_image_utils/shell_script_generator.py * Remove some uses of execute_with_retries * deprecate gsutil ; prefer gcloud * only print red/green for a short section, not the entire line * include signing key material in the metadata attributes * reduce noise from dd examples/secure-boot/build-current-images.sh examples/secure-boot/create-key-pair.sh examples/secure-boot/dask.sh examples/secure-boot/env.json.sample examples/secure-boot/install_gpu_driver.sh examples/secure-boot/pre-init.sh examples/secure-boot/rapids.sh * iterative changes in the example scripts scripts/customize_conda.sh startup_script/run.sh * deprecate gsutil ; prefer gcloud
38aee32
to
cde59b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fi | ||
|
||
echo 'Uploading local logs to GCS bucket.' | ||
gsutil -m rsync -r {log_dir}/ {gcs_log_dir}/ | ||
gsutil rsync -r {log_dir}/ {gcs_log_dir}/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this has dropped the -m
flag if the invocation is using legacy gsutil
instead of gcloud storage
. This might impact performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gcloud storage
considers the -m
implied and will fail if it is passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking of the case where this is run on an older base image with gcloud SDK < 402.0.0. In that case, prepare
would fall back to gsutil
, and with this change, we'd lose the -m
passed to gsutil
.
@@ -35,32 +35,51 @@ | |||
local -r cmd="$*" | |||
|
|||
for ((i = 0; i < 3; i++)); do | |||
if eval "$cmd"; then return 0 ; fi | |||
time eval "$cmd" > "/tmp/{run_id}/install.log" 2>&1 && retval=$? || {{ retval=$? ; cat "/tmp/{run_id}/install.log" ; }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this change made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to reduce noise in the log from successful runs of retried tasks, and to track the duration of long-running tasks.
This will only print the log on error
sleep 5 | ||
done | ||
return 1 | ||
) | ||
|
||
function gsutil() {{ ${{gsutil_cmd}} $* ; }} | ||
|
||
function version_ge() ( set +x ; [ "$1" = "$(echo -e "$1\n$2" | sort -V | tail -n1)" ] ; ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all of these function definitions required? I think I only saw calls to version_lt
, which in turn can call version_le
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not necessary, but will allow us to use the functions in the future without adding them. I can remove anything that isn't presently called if you think that's the right approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, generally it is good practice to remove unused code to simplify the codebase. If it's not covered by any tests or real-world usage, then we might not have confidence in it.
@@ -1,5 +1,6 @@ | |||
#!/bin/bash | |||
|
|||
# Copyright 2024 Google LLC and contributors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2025?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started writing it in 2024, and I've been advised to only use the earliest date, and not include additional years that the file was touched.
@@ -38,13 +38,26 @@ DATAPROC_VERSION=$(/usr/share/google/get_metadata_value attributes/dataproc-vers | |||
|
|||
ready="" | |||
|
|||
function version_ge() ( set +x ; [ "$1" = "$(echo -e "$1\n$2" | sort -V | tail -n1)" ] ; ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment here about whether or not all of the functions are required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not called right now, so if you're asking that I not pre-define these functions, I can do that. But beware that without this function, users will likely use ! version_ge
to mean version_lt
or version_le
interchangeably. There is currently an example of this in bdutil that is breaking the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these functions intended for any kind of reuse by users outside this context? If not, then I think it's fine to remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They mirror the same functions in [1]. My concern is that lacking all variants, developers who update this file in the future might make a convoluted and ultimately inaccurate call to this function by negating the results.
It's not a huge concern, though, and we can unbreak the build if it happens again.
I will remove the unused functions in this code.
This PR includes recent changes I've made as I've iterated on the examples in the
example/secure-boot/
directory as well as a patch to fix issue #111README.md
custom_image_utils/args_parser.py
tests/test_args_parser.py
custom-images/examples/secure-boot/pre-init.sh
Lines 149 to 157 in 19d386e
custom_image_utils/shell_script_generator.py
examples/secure-boot/build-current-images.sh
examples/secure-boot/create-key-pair.sh
examples/secure-boot/dask.sh
examples/secure-boot/env.json.sample
examples/secure-boot/install_gpu_driver.sh
examples/secure-boot/pre-init.sh
examples/secure-boot/rapids.sh
scripts/customize_conda.sh
startup_script/run.sh