modules/mu/clouds/google/function.rb in cloud-mu-3.1.4 vs modules/mu/clouds/google/function.rb in cloud-mu-3.1.5

- old
+ new

@@ -338,11 +338,11 @@ } ] end codefile = bok["project"]+"_"+bok["region"]+"_"+bok["name"]+".zip" - MU::Cloud::Google::Function.downloadPackage(@cloud_id, codefile, credentials: @config['credentials']) + return nil if !MU::Cloud::Google::Function.downloadPackage(@cloud_id, codefile, credentials: @config['credentials']) bok['code'] = { 'zip_file' => codefile } bok @@ -415,20 +415,26 @@ if cloud_desc.source_archive_url cloud_desc.source_archive_url.match(/^gs:\/\/([^\/]+)\/(.*)/) bucket = Regexp.last_match[1] path = Regexp.last_match[2] - MU::Cloud::Google.storage(credentials: credentials).get_object(bucket, path, download_dest: zipfile) + begin + MU::Cloud::Google.storage(credentials: credentials).get_object(bucket, path, download_dest: zipfile) + rescue ::Google::Apis::ClientError => e + MU.log "Couldn't retrieve gs://#{bucket}/#{path} for #{function_id}", MU::WARN, details: e.inspect + return false + end elsif cloud_desc.source_upload_url resp = MU::Cloud::Google.function(credentials: credentials).generate_function_download_url( function_id ) if resp and resp.download_url f = File.open(zipfile, "wb") f.write Net::HTTP.get(URI(resp.download_url)) f.close end end + true end # Upload a zipfile to our admin Cloud Storage bucket, for use by # Cloud Functions # @param zipfile [String]: Source file