Skip to content
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

Deleting in non-interactive mode is not possible #877

Closed
ahaverty opened this issue Aug 17, 2018 · 23 comments
Closed

Deleting in non-interactive mode is not possible #877

ahaverty opened this issue Aug 17, 2018 · 23 comments

Comments

@ahaverty
Copy link

Version info

"firebase-tools": "4.1.1"

Platform Information

OS X and Bitbucket Pipelines CI

Steps to reproduce

In Bitbucket pipelines CI, using non-interactive mode with env variables
firebase use myproject
firebase deploy with 5 functions in index.js

In a later PR
firebase deploy with just 4 functions in index.js

Expected behavior

  1. The full firebase deploy removes the "5th" function that is no longer in the latest index.js
  2. No manual steps/CLI commands are required (like in previous versions of firebase tools)

Actual behavior

Error: The following functions are found in your project but do not exist in your local source code:
... list of functions ...
Aborting because deletion cannot proceed in non-interactive mode. To fix, manually delete the functions by running:

@laurenzlong
Copy link
Contributor

Hi, this is intentional behavior, since we got a lot of feedback that users did not like how the CLI automatically deleted their functions. So now we require user confirmation for deletions, which cannot be done in non-interactive.

This is why the release was a major version bump, to indicate a breaking change in behavior.

@ahaverty
Copy link
Author

@laurenzlong could a flag be added to allow deletions in non-interactive mode? Deleting functions by hand in CLI for us is way less safe and inconvenient versus a good review/merge policy + CI deployments

@laurenzlong
Copy link
Contributor

Could you expand on your rationale a bit more? Are you deleting functions often during CI?

@ahaverty
Copy link
Author

Sure: We're constantly refactoring old functions and often replacing (swapping https onRequest for onCall for example). It's easier for us to delete the old function and add a new one. Sometimes we simply aren't using the function anymore, and want it gone.
We wouldn't delete a function every week, but now that it's not possible to do via CI, it means we have to add a manual step in review to manually delete before merging and auto deploying. It also means at least two developers need write access to our production functions, which we're trying to get away from for peace of mind.
If we had something like firebase deploy --allow-deletes and we maintain a good review process, our entire Dev team can freely create/update/delete anything without waiting on me to open up production CLI on my laptop while I'm working on something else.

I can understand why the default would be not to delete, but we're suprised it's not possible/blocked in non-interactive mode, assuming most people in that mode are thoroughly reviewing before deploying like we are?

@laurenzlong
Copy link
Contributor

Thanks for the feedback Alan, I'll open up the discussion internally about this.

@ahaverty
Copy link
Author

Thanks Lauren 🙌

@heygambo
Copy link

heygambo commented Sep 2, 2018

We have exactly the same issue. It would help as a lot as well. We had to give up our automated deployments using Google Cloud Builder because of the update.

@IchordeDionysos
Copy link
Contributor

IchordeDionysos commented Sep 18, 2018

Not sure if anyone suggested it already.
Most of the users seem to prefer a flag where functions not present will get deleted.

This is not always the option everyone want's to have.
For example, we would like to have a flag, which allows us to just ignore these functions.
So the functions won't get an update or get deleted.

For example, if someone created a new function in a feature branch and deployed it using firebase deploy --only functions:functionName for testing purposes.
This won't affect any other function in production use.

And then someone tries to deploy a new version, then our CI pipeline would start and call the command
firebase deploy --ignore-missing-functions, then the deploy would update all present functions, create missing functions, but would not update or delete the function functionName.

I see the benefit of a flag to get back the old behaviour, so both behaviours would be great to have in my opinion.
Either delete missing functions or just ignore them.

@laurenzlong laurenzlong reopened this Sep 26, 2018
@arthabus
Copy link

arthabus commented Oct 3, 2018

Same here. Because we have lots of triggers and often times we need to move user database from prod to dev project for investigation and troubleshooting we need a way to disable all the triggers during json import.
And the only way to disable triggers we came up is to actually delete all the functions in dev project before the import - literally comment out all the index.js, deploy it to dev, then import the json and then revert all the functions back for further investigation of any reported issues.

If there is a way to disable triggers in a more friendly way with the updated CLI I would much appreciate any input on how to achieve that. Otherwise removing functions from CLI in a batch is still something we rely on.

@solomonengel
Copy link

@laurenzlong is this being addressed?

@mbleigh
Copy link
Contributor

mbleigh commented Oct 12, 2018 via email

@IchordeDionysos
Copy link
Contributor

@mbleigh Is there any option to not delete any function when I run firebase deploy?

For example, if I have 2 separate repositories with totally different functions which all deploy to the same Functions project.

So e.g.:
I have repos

  • "frontend", with the function:
    • languageRedirector
  • "backend", with:
    • onUserAuthenticated

Now if I run firebase deploy from the "frontend" repo I want to update only languageRedirector
and if I run firebase deploy from the "backend" repo I want to update only onUserAuthenticated

Is this possible?

@bkendall
Copy link
Contributor

bkendall commented Nov 5, 2018

@IchordeDionysos that is not possible, as far as I'm aware. During the deploy process, the functions are inspected to figure out what needs to be removed and what needs to be added. If one is "missing" from the code, the CLI will attempt to delete it.

@IchordeDionysos
Copy link
Contributor

Is this #999 something you are considering? :)
We really need this option as our CI script currently won't work without this...

@bkendall
Copy link
Contributor

I just put a note on that PR. While it's a good idea, there's a bit more internal process that has to happen to add a flag like this. I wouldn't expect something to happen in a number of days, but know that it's on our radar.

@bkendall
Copy link
Contributor

@IchordeDionysos In the meantime, is it possible for you to use --only functions:[function] on firebase deploy to get your CI working? You can find more details here: https://firebase.google.com/docs/cli/#deploy_specific_functions

@heygambo
Copy link

For us the issue is resolved. We're able to deploy via Google Cloud Builder again.

ademidun added a commit to ademidun/atila-angular that referenced this issue Aug 10, 2019
@alizbazar
Copy link

Here's the "hack" that we are using to only upsert function (not delete others):

echo "n\n" | firebase deploy --only functions --interactive --token $FIREBASE_TOKEN

Would also appreciate having and explicit option such as --no-delete rather than relying on the question never changing 😏

@animysore
Copy link

Another "hack" alternative is to explicitly pass all function names after reading them from the index.ts

firebase deploy --token $FIREBASE_TOKEN --only functions:`sed -n "s/exports\.\(\w*\).*$/\1/p"  functions/index.ts | paste -s -d, -`

Explanation

@donvaughn
Copy link

donvaughn commented May 12, 2021

In some cases, using cloud function groups may be enough to ignore other functions. For example, In your root index.js file, you would export your groups:

 // metrics.js and accounts.js export multiple functions
exports.metrics = require('./metrics');
exports.accounts = require('./accounts');  
...

And the deploy command for the metrics function group then looks like this:

firebase deploy --only functions:metrics

And when using the above deploy command with the --force option, you can automatically delete functions removed from the metrics group while ignoring all functions in other groups.

@louis030195
Copy link

Still no way to confirm in any case in non-interactive mode?

A -yjust like in apt install -y foowould be nice

firebase deploy -y

@Retsuki
Copy link

Retsuki commented Jan 4, 2022

I wanted to deploy through the cloud build.
so I did below

pachage.json

{
  ...
  "scripts"{
    "deploy:staging": "firebase use staging && echo \"n\n\" | firebase deploy --only functions --interactive",
    ...
  },
}

cloudbuild.yaml

steps:
  - id: Install packages
    name: 'gcr.io/cloud-builders/npm'
    args: ['install']
  - id: Build firebase functions
    name: 'gcr.io/cloud-builders/npm'
    args: ['run', 'build']
  - id: Deploy to firebase functions
    name: 'gcr.io/cloud-builders/npm'
    args: ['run', 'deploy:staging']

I hope to help someone.
thank you.

@leo-paz
Copy link

leo-paz commented Feb 4, 2022

@Retsuki Do you have firebase tools as a dependency?

It would really be nice to just have an ignore flag for this 😐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests