--min-instances google cloud function cloud shell command error - google-cloud-shell

I am trying to set the minimum number of instances for my google cloud function (not for cloud run) using the below command, but its not working, giving error ERROR: (gcloud.beta.functions.deploy) unrecognized arguments. I tried by removing \ as well as putting = after --min-instances, nothing working. At the same time -max-instances is working, having issue with --min-instances. I need to run using cloud shell command only, Don't want to directly setting it in GCP console. Any helpful answers please?
gcloud beta functions deploy
--min-instances 2

Related

Is it possible to auto-retry firebase cloud-function deploys when doing a full deploy?

I have a large amount of cloud functions (150+) that need to be deployed. When i run the following: firebase deploy --only functions to do a full deploy i get the following message:
⚠ functions: too many functions are being deployed, cannot poll status.
In a few minutes, you can check status at https://console.firebase.google.com/project/.../functions/logs
You can use the --only flag to deploy only a portion of your functions in the future.
✔ Deploy complete!
indicating that the deploy is in progress. The issue i have is that usually several functions fail to deploy due to quota limits or other non-code ralated issues, and these have to be retried/redeployed. When polling firebase will give the code to use to retry these, however, when not polling then no further console output is given. When i access the interface i am able to see which functions failed to deploy:
enter image description here
Is there an option either in the google interface to retry these, or some command option that can be added to the deploy command to auto-retry failed functions? Currently i have to manually gather all the failed function-names by manually looking trough the list and run a deploy specifying only those.
There is no such option to automatically retry. Maybe you could write code to scan the logs to figure out what failed and retry yourself. Alternatively, you could instead invoke the CLI once for each individual function at a controlled rate, and check the results individually.
What you have here sounds like a feature request, which you could post to the firebase-tools GitHub repo. You could also reach out to Firebase support to make your needs known.

how to get firebase cloud messanging running on local host

I try to get a simple firebase cloud message app, web, to run. The README of the sample app says:
1. On the command line run `firebase serve -p 8081` using the Firebase CLI tool to launch a local server.
That gives the error
Error: Cannot understand what targets to deploy/serve. If you are using PowerShell make sure you place quotes around any comma-separated lists (ex: --only "functions,firestore").
So I tried
firebase serve -p 8081 .
which returns
Having trouble? Try firebase [command] --help
How can I get a local web app that receives messages get running? Will similar troubles start again when hosting on firebase.
I am stuck. Firebase is an endless series of weird docu, weird results, all errors have been encountered by others and there are lon long threads on any of them.

Permission errors unit-testing Google Cloud Functions calling firestore db

I'm following the guide at https://firebase.google.com/docs/functions/unit-testing, but I always get " FirebaseError: Missing or insufficient permissions" when I run my test. I have the correct service-account.json file and I'm setting up firebase-functions-test with it (that part goes without error).
I've tried it with the emulator running (setting the FIRESTORE_EMULATOR_HOST var), and without it (which I assume uses live data) but I always get this error, as soon as my code under test does a db request such as:
data = await db().collection('/machines').get()
So my function under test is getting called, but it just can't do anything.
I also tried calling firebase.initializeApp() the same way I do in my front-end app, but that doesn't help, although without it I get the error telling me to call Firebase App.initializeApp().
firebase use is set to my current project.
I also tried running my test as firebase emulators:exec jest, no difference.
Any ideas?

See continuous logging on command line

I am currently working on a Firebase function. As I am still in the development stage, I have a number of logs in my code to see what's going on.
async function getAddressByIdAsync(address) {
let addr = addressesRef.child(address);
console.log(addr);
return admin.database().ref('Addresses/' + address);
}
The only way I have found to be able to see these logs in real time is though the Firebase console, which is very slow and generally a bad UI experience IMO.
I'm looking for a command line solution that will let me see in real time the logs coming from the Firebase cloud function.
I have tried this command
firebase functions:log
Which appears to return the last twenty or so log entries into my Firebase Functions.
I know Google Cloud has a tail option on the end of that CLI but it doesn't work here.
firebase functions:log tail
Error: Too many arguments. Run firebase help functions:log for usage instructions
Is there a way to get a live running output of the logs from firebase cloud functions?
You can try the local emulator, that way you can first run your functions locally (and log in your terminal), before deploying.
https://firebase.google.com/docs/functions/local-emulator

ERROR: (gcloud.compute.ssh) Could not fetch resource: - The resource was not found

I'm trying to run R on Google Cloud following Google's suggested tutorial. However, I have experienced some trouble when finally creating the cluster. When creating the cluster with
elasticluster start myslurmcluster
I get the following error message
ERROR: (gcloud.compute.ssh) Could not fetch resource:
- The resource 'projects/MY_PROJECT/zones/us-central1-b/instances/myslurmcluster-frontend001' was not found
I had run through previous stages of the tutorial several times with no problems but I suspect the issue might be related to the SSH keys so that I can sign in to my cluster.
Any help or advice greatly received!
ERROR: (gcloud.compute.ssh) Could not fetch resource:
- The resource 'projects/MY_PROJECT/zones/us-central1-b/instances/myslurmcluster-frontend001' was not found
The error you are getting means that when you are trying to compute SSH, your resource was not found. The reason for this case is the instance zone and gcloud default zone are different. The command line didn’t specified the instance zone. So the google cloud compute default zone was used. Obviously, The instance should not be found in the default zone. Just adding the zone option in command could solve the problem. The command format is like:
gcloud compute --project "MY_PROJECT" ssh --zone "us-central1-b" "myslurmcluster-frontend001"
To see what your default region and zone settings are, run the following gcloud command:
gcloud compute project-info describe --project [PROJECT_ID]
where [PROJECT_ID] is your own project ID.
Hope this helps... Easy way to find out instance zones without having to type/know instance name.
gcloud compute instances list
Should list instances and information - including (time)ZONE.

Resources