3

I use a shutdown-script to backup the files on an instance before it is shutdown. In this shutdown-script, the gsutil tool is used to send files to a bucket at google cloud storage.

/snap/bin/gsutil -m rsync -d -r /home/ganjin/notebook gs://ganjin-computing/XXXXXXXXXXX/TEST-202104/notebook

It worked well for long days. But recently, there occurs some error as below.

If I run the code manually, it works well. It seems that there is something wrong with jobs management of systemd.

Could anyone give me some hint?

 INFO shutdown-script: /snap/bin/gsutil -m rsync -d -r /home/ganjin/notebook gs://ganjin-computing/XXXXXXXXXXX/TEST-202104/notebook
Apr 25 03:00:41 instance-XXXXXXXXXXX systemd[1]: Requested transaction contradicts existing jobs: Transaction for snap.google-cloud-sdk.gsutil.d027e14e-3905-4c96-9e42-c1f5ee9c6b1d.scope/start is destructive (poweroff.target has 'start' job queued, but 'stop' is included in transaction).
Apr 25 03:00:41 instance-XXXXXXXXXXX shutdown-script: INFO shutdown-script: internal error, please report: running "google-cloud-sdk.gsutil" failed: cannot create transient scope: DBus error "org.freedesktop.systemd1.TransactionIsDestructive": [Transaction for snap.google-cloud-sdk.gsutil.d027e14e-3905-4c96-9e42-c1f5ee9c6b1d.scope/start is destructive (poweroff.target has 'start' job queued, but 'stop' is included in transaction).]
  • What is your current systemd version? Are you using the same systemd version the script was last working? – Chandra Kiran Pasumarti Jun 01 '21 at 07:49
  • Check if there is an update available (`gcloud components update`). Update and I think that error will go away. – John Hanley Jun 01 '21 at 08:00
  • Where I run "gcloud components update" on the instance (the one to be used to create image file), there comes error: `ERROR: (gcloud.components.update) You cannot perform this action because this Cloud SDK installation is managed by an external package manager. Please consider using a separate installation of the Cloud SDK created through the default mechanism described at: https://cloud.google.com/sdk/` – Xuefeng LIU Jun 07 '21 at 16:30
  • I am using a Ubuntu image:`Linux instance-XXXXXXX 5.4.0-1036-gcp #39-Ubuntu SMP Thu Jan 14 18:41:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux` – Xuefeng LIU Jun 07 '21 at 16:33
  • Try the follow steps: 1) `gcloud version`. Write down the version of `gsutil`. 2) `sudo apt update`. 3) `sudo apt upgrade`. 4) `gcloud version`. 5) Did `gsutil` update? – John Hanley Jun 07 '21 at 19:27
  • The original output of "gcloud --version" gaves "gsutil 4.61". After I updated the os, the output is "gsutil 4.64". I will now check the shutdown script result after updating. – Xuefeng LIU Jul 10 '21 at 15:31
  • Even with gsutil as 4.64, the shutdown script in the shutdown process cannot copy file from the instance to google cloud storage. But if I run the shutdown script manually, it works well. – Xuefeng LIU Jul 10 '21 at 16:59
  • Can you try by updating the guest environment as mentioned in the answer below? – Chandra Kiran Pasumarti Jul 12 '21 at 19:51

1 Answers1

0
  1. Update gsutil with -f option.

    update gsutil -f

    If the above command doesn’t work then try the command below:

    sudo apt-get update && sudo apt-get --only-upgrade install google-cloud-sdk

  2. Update guest environment and try to shutdown the instance. Use the link below as a reference to update the guest environment.

    https://cloud.google.com/compute/docs/images/install-guest-environment#update-guest

  3. If still facing issues do forceful shutdown:

    sudo poweroff -f