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

Reusage of --force flag for function deployment with minimum instances (minimum bill) #6485

Closed
Buckwich opened this issue Nov 1, 2023 · 5 comments

Comments

@Buckwich
Copy link

Buckwich commented Nov 1, 2023

[REQUIRED] Environment info

firebase-tools: 12.4.4 (should be the same on latest version)

Platform: Docker on Ubuntu on Github Action Runner

[REQUIRED] Test case

Any normal firebase project with some functions. Optionally it is using a CI/CD (non-interactive) to deploy. Adjusting the minInstances to increase the minimum bill of the project, in our case 1 is enough.

.runWith({
  minInstances:1
})

[REQUIRED] Steps to reproduce

Deploy the adjusted function optimally via a non interactive terminal, ie. github action.

[REQUIRED] Expected behavior

The function should be deployed with minInstance=1.

[REQUIRED] Actual behavior

Error message: Pass the --force option to deploy functions that increase the minimum bill and deployment is canceled.

The problem is that we can't use the --force flag as this would also auto delete functions. From the help section this behaviour is also not clear. There the force flag is only documented to delete functions:

 -f, --force              delete Cloud Functions missing from the current working directory without confirmation

Solution Idea

The --force flag should not be reused as a helper for other stuff than the deletion. Probably a separate flag for that would suffice, eg. --allow-bill-increase.

That flag would replace force in this file:

if (options.force) {

@aalej
Copy link
Contributor

aalej commented Nov 3, 2023

Hi @Buckwich, thanks for raising this issue and providing detailed feedback. Passing the --force flag should only delete functions which are found in your project but do not exist in your local source code.

Just to make sure we’re on the same page here and to get a better understanding of your use case, do you have functions in your project that do not exist in your local source code?

I do agree with your feedback here, a better description for the --force flag could be added, and if there are scenarios where the --force flag would not be ideal to use, adding a separate flag would be a good approach. For now, I’ll mark this as a feature request.

@Buckwich
Copy link
Author

Buckwich commented Nov 3, 2023

Thanks for your response. Normally we don't have functions without source code, but it has happened and the error (function without source) prevented us from deploying a corrupt state of our project. If we would use --force by default we would miss that valid error.

@colerogers
Copy link
Contributor

Hi @Buckwich thanks for opening this issue. We treat min instances a bit special since they change how much customers are billed. We don't want someone to accidentally increase their bill so we gate it around a confirmation. The --force flag has acted as a way to skip these interactive prompts. Adding a separate flag into the CLI is actually a much more involved process on the backend and generally specific product flags are discouraged from the general firebase deploy command, so I don't see us going with that direction. I drafted #6506 for updating the prompt. Thanks and let me know if I missed anything, otherwise I'm going to close this out

@martolini
Copy link

martolini commented Jan 25, 2024

Sorry for reopening this, but I just bumped our firebase-functions dependency, does this mean that if we use minInstances: 1 (which we often do), we're now forced to use the --force flag? That seems super scary.

@vitoras
Copy link

vitoras commented Mar 25, 2024

I agree with @martolini, I'm facing an issue with cold starts where Google support recommends setting a min instance to our functions (https://www.googlecloudcommunity.com/gc/Serverless/GCP-cloud-function-giving-504-timeout-at-cold-start/m-p/727675), but since I have almost 20 functions, I can't keep then in the same codebase, so therefore, being forced to add the --force flag in one of them will force me to delete all of my other functions.

There has to be a workaround without having to set min instances manually on a terminal every time we redeploy it.

Edit: Nvm, you could just use the --only flag as well.

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

No branches or pull requests

5 participants