freedomofpress / containers

Repo to house all FPF related containers
4 stars 0 forks source link

Catch exception running gcloud auth, log output and exit code #20

Closed maeve-fpf closed 4 years ago

maeve-fpf commented 4 years ago

This container's script was failing due to a read-only fs, but only with a traceback:

Traceback (most recent call last):                                                                                                                            
  File "/usr/local/bin/gs_bucket_sync.py", line 159, in <module>                                                                                              
    backup.initialize_svc_acct(parsed_args.svc_act_key)                                                                                                       
  File "/usr/local/bin/gs_bucket_sync.py", line 69, in initialize_svc_acct                                                                                    
    self._subprocess_debug_wrap(gcloud_auth_cmd)                                                                                                              
  File "/usr/local/bin/gs_bucket_sync.py", line 59, in _subprocess_debug_wrap                                                                                      cmd, stderr=subprocess.STDOUT, shell=shellmode).decode('ascii')                                                                                           
  File "/usr/lib/python3.5/subprocess.py", line 316, in check_output                                                                                          
    **kwargs).stdout                                                                                                                                          
  File "/usr/lib/python3.5/subprocess.py", line 398, in run                                                                                                   
    output=stdout, stderr=stderr)                                                                                                                             
subprocess.CalledProcessError: Command '['gcloud', 'auth', 'activate-service-account', '--key-file', '/secrets/GS_BUCKET_SVC_ACCT.json']' returned non-zero exi
t status 1    

Catch and log, so it looks like:

command ['gcloud', 'auth', 'activate-service-account', '--key-file', '/secrets/GS_BUCKET_SVC_ACCT.json'] failed with status 1, output = b"WARNING: Could not setup log file in /home/gcloud_user/.config/gcloud/logs, (OSError: [Errno 30] Read-only file system: '/home/gcloud_user/.config')\nERROR: (gcloud.auth.activate-service-account) Unable to create private file [/home/gcloud_user/.config/gcloud/credentials.db]: [Errno 30] Read-only file system: '/home/gcloud_user/.config'\n"