@@ -218,17 +218,33 @@ function export-windows-docker-event-log() {
218
218
done
219
219
}
220
220
221
- # Save log files and serial console output from Windows node $1 into local
222
- # directory $2.
223
- # This function shouldn't ever trigger errexit.
224
- function save-logs-windows() {
225
- local -r node=" ${1} "
226
- local -r dest_dir=" ${2} "
221
+ # Saves log files from diagnostics tool.(https://github.com/GoogleCloudPlatform/compute-image-tools/tree/master/cli_tools/diagnostics)
222
+ function save-windows-logs-via-diagnostics-tool() {
223
+ local node=" ${1} "
224
+ local dest_dir=" ${2} "
225
+
226
+ gcloud compute instances add-metadata ${node} --metadata enable-diagnostics=true --project=${PROJECT} --zone=${ZONE}
227
+ local logs_archive_in_gcs=$( gcloud alpha compute diagnose export-logs ${node} --zone=${ZONE} --project=${PROJECT} | tail -n 1)
228
+ local temp_local_path=" ${node} .zip"
229
+ for retry in {1..20}; do
230
+ if gsutil mv " ${logs_archive_in_gcs} " " ${temp_local_path} " > /dev/null 2>&1 ; then
231
+ echo " Downloaded diagnostics log from ${logs_archive_in_gcs} "
232
+ break
233
+ else
234
+ sleep 10
235
+ fi
236
+ done
227
237
228
- if [[ ! " ${gcloud_supported_providers} " =~ " ${KUBERNETES_PROVIDER }" ]]; then
229
- echo " Not saving logs for ${node} , Windows log dumping requires gcloud support "
230
- return
238
+ if [[ -f " ${temp_local_path } " ]]; then
239
+ unzip ${temp_local_path} -d " ${dest_dir} " > /dev/null
240
+ rm -f ${temp_local_path}
231
241
fi
242
+ }
243
+
244
+ # Saves log files from SSH
245
+ function save-windows-logs-via-ssh() {
246
+ local node=" ${1} "
247
+ local dest_dir=" ${2} "
232
248
233
249
export-windows-docker-event-log " ${node} "
234
250
@@ -253,6 +269,25 @@ function save-logs-windows() {
253
269
fi
254
270
done
255
271
done
272
+ }
273
+
274
+ # Save log files and serial console output from Windows node $1 into local
275
+ # directory $2.
276
+ # This function shouldn't ever trigger errexit.
277
+ function save-logs-windows() {
278
+ local -r node=" ${1} "
279
+ local -r dest_dir=" ${2} "
280
+
281
+ if [[ ! " ${gcloud_supported_providers} " =~ " ${KUBERNETES_PROVIDER} " ]]; then
282
+ echo " Not saving logs for ${node} , Windows log dumping requires gcloud support"
283
+ return
284
+ fi
285
+
286
+ if [[ " ${KUBERNETES_PROVIDER} " == " gke" ]]; then
287
+ save-windows-logs-via-diagnostics-tool " ${node} " " ${dest_dir} "
288
+ else
289
+ save-windows-logs-via-ssh " ${node} " " ${dest_dir} "
290
+ fi
256
291
257
292
# Serial port 1 contains the Windows console output.
258
293
gcloud compute instances get-serial-port-output --project " ${PROJECT} " \
0 commit comments