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

Can't delete or overwrite function that failed to deploy earlier #118

Closed
redpandatronicsuk opened this Issue Apr 16, 2017 · 13 comments

Comments

Projects
None yet
5 participants
@redpandatronicsuk
Copy link

redpandatronicsuk commented Apr 16, 2017

I had an error in a function and when I tried to deploy it, it failed with an error message. I then fixed the error and tried to redeploy, but it would still show me the same error message. So I thought I could delete the function, but it still produces the same error. I even tried to re-deploy with an empty index.js file, to reset it, but it wouldn't work. The working functions get deleted successfully, but the function that had the error in it, won't go. I'll paste the command line output, that should make it clearer what the error is:

$ mv index.js index.bak
$ touch index.js
$ firebase deploy

=== Deploying to 'foo'...

i  deploying functions
i  functions: ensuring necessary APIs are enabled...
i  runtimeconfig: ensuring necessary APIs are enabled...
✔  runtimeconfig: all necessary APIs are enabled
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  starting release process (may take several minutes)...
i  functions: deleting function bar...
i  functions: deleting function foo...
i  functions: deleting function fooNew...
⚠  functions[foo]: Deploy Error: Failed to configure trigger GCS Bucket: undefined
✔  functions[bar]: Successful delete operation.
✔  functions[fooNew]: Successful delete operation.
✔  functions: 2 function(s) deployed successfully.

Then if I leave index.js empty and re-run deploy, I get:

$ firebase deploy --only functions

=== Deploying to 'foo'...

i  deploying functions
i  functions: ensuring necessary APIs are enabled...
i  runtimeconfig: ensuring necessary APIs are enabled...
✔  runtimeconfig: all necessary APIs are enabled
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  starting release process (may take several minutes)...
i  functions: deleting function foo...
⚠  functions[foo]: Deploy Error: Failed to configure trigger GCS Bucket: undefined

No matter how many times I re-run the command, it produces the same output. For some reason it won't delete the foo function.

@rldaulton

This comment has been minimized.

Copy link
Contributor

rldaulton commented Apr 19, 2017

can you include your package.json file contents? Also, have you checked your logs? Can we see those? make sure you run npm install before you try to deploy

@redpandatronicsuk

This comment has been minimized.

Copy link
Author

redpandatronicsuk commented Apr 19, 2017

Thanks for your reply. Here is the contents of package.json:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "dependencies": {
    "@google-cloud/storage": "^0.4.0",
    "child-process-promise": "^2.2.0",
    "ffmpeg-static": "^2.0.0",
    "firebase": "^3.7.8",
    "firebase-admin": "~4.1.2",
    "firebase-functions": "^0.5",
    "lodash": "^4.17.4",
    "mkdirp": "^0.5.1",
    "mkdirp-promise": "^4.0.0"
  },
  "private": true
}

Here is a sample log entry for the failed execution:
8:24:34.924 pm warning userSubmttedVideoUploadLstener Failed to configure trigger GCS Bucket: undefined
I can't find more in the log about the userSubmttedVideoUploadLstener function.

I did run npm install before deploying.

Also, I tried to deleting the function using the Google Cloud web interface (https://console.cloud.google.com/functions/list?project=xxx). When I hit the delete function button, it shows a notification saying: Deleting function successfully started. But the function never seems to get deleted.

UPDATE:
In Google Cloud, the log entry is more verbose:

{
 protoPayload: {
  @type: "type.googleapis.com/google.cloud.audit.AuditLog"    
  status: {
   code: 13     
   message: "Failed to configure trigger GCS Bucket: undefined"     
  }
  serviceName: "cloudfunctions.googleapis.com"    
  methodName: "google.cloud.functions.v1beta2.CloudFunctionsService.DeleteFunction"    
  resourceName: "projects/xxx/locations/us-central1/functions/userSubmttedVideoUploadLstener"    
 }
 insertId: "54D876B9438E8.A034086.B80CDE1B"   
 resource: {
  type: "cloud_function"    
  labels: {
   project_id: "xxx"     
   region: "us-central1"     
   function_name: "userSubmttedVideoUploadLstener"     
  }
 }
 timestamp: "2017-04-19T16:21:44.352Z"   
 severity: "ERROR"   
 logName: "projects/xxx/logs/cloudaudit.googleapis.com%2Factivity"   
 operation: {
  id: "operations/bWVpbnRydW1wZi1mZDE0ZS91cy1jZW50cmFsMS91c2VyU3VibXR0ZWRWaWRlb1VwbG9hZExzdGVuZXIvT2hXWkZtMWRkWlU"    
  producer: "cloudfunctions.googleapis.com"    
  last: true    
 }
}
@rldaulton

This comment has been minimized.

Copy link
Contributor

rldaulton commented Apr 19, 2017

It looks like this is a permissions issue with your storage bucket. I would try deleting your functions file locally (save your code), and re-create a local repo. But first, try firebase logout followed by firebase login to reset your auth tokens and maybe this will re-write your permissions for GCB. Then firebase init functions and drag in your old code files. Run npm install and try to re-deploy.

@redpandatronicsuk

This comment has been minimized.

Copy link
Author

redpandatronicsuk commented Apr 20, 2017

Thanks, I tried your instructions, but I still get the error that the function won't delete. It is not a big problem though as everything else seems to work fine, besides the warning message.

I have another related question however. I have a function that gets triggered when a file gets uploaded to a storage bucket. Then in that function, I download the file, process it and upload it to the bucket under a different name (similar to the generate-thumbnail example in this repository). Then for the newly uploaded file I can generate a download URL using:

`https://firebasestorage.googleapis.com/v0/b/xxx.appspot.com/o/${'path/to/processed/video.mp4'.replace(/\//g,'%2F')}?alt=media`

This URL is pretty long, so I want to shorten it with Dynamic Links. To do this I make a POST request to the webapi, e.g:
https://foo.app.goo.gl/?link=https://firebasestorage.googleapis.com/v0/b/xxx.appspot.com/o/user-submitted-videos%2path%2Fto%2Fprocessed%2Fvideo.mp4?alt=media

The problem is that the short link redirects to the URL .../user-submitted-videos/path/to/processed/video.mp4?alt=media, i.e. the %2F are changed back to / again and the URL doesn't work.

How can I make a short link that preservers the %2F? Also, is it correct to use the web api for Dynamic Links or is there something in firebase-functions or firebase-admin I can use?

@inlined

This comment has been minimized.

Copy link
Member

inlined commented Apr 21, 2017

@redpandatronicsuk

This comment has been minimized.

Copy link
Author

redpandatronicsuk commented Apr 21, 2017

Thanks for your suggestion @inlined, with two % signs, it doesn't replace %2F with /, but it leaves the extra % sign, so that doesn't work neither.

@rldaulton

This comment has been minimized.

Copy link
Contributor

rldaulton commented Apr 21, 2017

Try this:
https://foo.app.goo.gl/?link=https://firebasestorage.googleapis.com/v0/b/xxx.appspot.com/o/user-submitted-videos%252path%252Fto%252Fprocessed%252Fvideo.mp4?alt=media

@redpandatronicsuk

This comment has been minimized.

Copy link
Author

redpandatronicsuk commented Apr 21, 2017

Awesome! Using %252F instead of %2F works.

@rldaulton

This comment has been minimized.

Copy link
Contributor

rldaulton commented Apr 21, 2017

Cool - can we close this issue @redpandatronicsuk?

@redpandatronicsuk

This comment has been minimized.

Copy link
Author

redpandatronicsuk commented Apr 21, 2017

I still can't delete the function, but its not a big problem for me, so you can close the issue. Thanks for your help!

@marcorei

This comment has been minimized.

Copy link

marcorei commented Jul 31, 2017

@redpandatronicsuk Did you figure out how to delete the function? I have a similar problem and found your issue via google.

If you did it would be great if you could write an answer to my question on StackOverflow!

@redpandatronicsuk

This comment has been minimized.

Copy link
Author

redpandatronicsuk commented Jul 31, 2017

The function got deleted somehow, but I can't remember having done anything. I think it was a bug on the Firebase side that got fixed. Try contacting support.

@mdrideout

This comment has been minimized.

Copy link

mdrideout commented Jan 25, 2018

I recently had an issue similar to this. I was trying to deploy functions, but the previous deployment was still in process (for like 15 minutes). I tried to delete the functions from the Google Cloud Functions console manually, and the delete process itself then took another 10 minutes. Eventually, they did delete and I was able to re-deploy. I think there was something funky going on, on Google's end.

After the delete completed successfully, I was able to deploy again without issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment