gcloud get-logs command not working - google-app-engine

I was trying to download logs from a GAE app using the gcloud cli
In the documentation the command I was supposed to use was:
gcloud preview app get-logs --version 1 default mylogs.txt
However, when running this command I get the following error:
ERROR: (gcloud.preview.app) Invalid choice: 'get-logs'. Did you mean 'deploy'?
All the tools are installed and there's nothing to update using gcloud components list and gcloud components update
Also I have authenticated and set the project
gcloud auth login
gcloud config set project mytestproject

This command moved to go underneath the modules command group, and unfortunately the documentation lagged behind.
The equivalent command is
$ gcloud preview app modules get-logs --version 1 default mylogs.txt
Sorry for the confusion!

You can also try appcfg.py request_logs myapp/ mylogs.txt to download the logs for your application which is running in App Engine.
This Command only works for App Engine but not for Managed VM's.Refer to the link https://cloud.google.com/appengine/docs/python/tools/uploadinganapp#Python_Downloading_logs

Related

Stuck on "Get Started" page of Google App Engine. "gcloud app deploy" fails

I am stuck on the first page of instructions for Google App Engine
https://console.cloud.google.com/appengine/start/reception
I downloaded and installed the cloud SDK.
"gcloud init" worked.
I am stuck at "Deploy to App Engine".
When I type "gcloud app deploy" in Terminal, I get two errors.
"ERROR: An app.yaml (or appengine-web.xml) file is required to deploy this directory as an App Engine application. Create an app.yaml file using the directions at https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml"
The page it says to go to does not give directions for creating the file. What is the command? Also, why is this error happening at all? If I follow the instructions on the Get Started page, I should not get an error. Some instructions must be missing or something not working when I install the SDK.
The second error I get is "ERROR: (gcloud.app.deploy) [/Users/chucky] could not be identified as a valid source directory or file."
Again, there must be instructions missing because I am following them.
Screen Shot
gcloud app deploy is for deploying a project. This means you need to have a folder with a sample project. The project will need to have an app.yaml file. Essentially, the steps are
Download and install the Google Cloud SDK
Run gcloud init to initialize the SDK (this makes you to login to Google and grant access to gcloud to your account; also sets up your default project)
Create your project (or copy an existing one) where project is your App i.e. the application you are working on. This project should have an app.yaml file.
Then deploy your project to production by running gcloud app deploy. You first have to change directory to your project folder. If you don't want to do this, you have to specify the full path to your app.yaml file.
An alternative for steps 3 - 4 is to use a Graphical User Interface (GUI) like one from us - https://nocommandline.com . You just click a button to create a new project and it will create a shell project ('hello world') with all the necessary files. To deploy your project, you also click another button 'Deploy' and it will take care of deploying your project.
From the link:
https://console.cloud.google.com/appengine/start/reception
First, you need to download the resources. You can use the Cloud SDK, Cloud Shell, directly download from github or other terminal to download the resources files. For example, you want to deploy a Python app using Cloud SDK in Windows OS:
Install and open Cloud SDK.
Copy the resources file from github:
From Cloud SDK run:
git clone https://github.com/GoogleCloudPlatform/python-docs-samples
Go to directory of your application files:
cd python-docs-samples/appengine/standard_python3/hello_world
Deploy and browse your application
Deploy using the command:
gcloud app deploy --project PROJECTID
Browse using the command:
gcloud app browse --project PROJECTID
If you see the Hello World! you've successfully deployed your application.

Why the gcloud components update command always show restarting command

When I want to deploy my Go app to App Engine, I found that I have to install the app-engine-go. And it even said the installation is on a new window, no window popped out.
https://github.com/ChihchengHsieh/ProblemsScreenShot/blob/master/image-2.png
C:\go-work\src\orderFunc>gcloud app deploy
The component [app-engine-go] is required for staging this
application.
Restarting command:
$ gcloud components install app-engine-go
Installing component in a new window.
Please re-run this command when installation is complete.
$ gcloud app deploy
When I run the command gcloud components install app-engine-go and gcloud components update, it shows:
https://github.com/ChihchengHsieh/ProblemsScreenShot/blob/master/image.png
C:\go-work\src\orderFunc>gcloud components install app-engine-go
Restarting command:
$ gcloud components install app-engine-go
C:\go-work\src\orderFunc>gcloud components update
Restarting command:
$ gcloud components update
C:\go-work\src\orderFunc>gcloud components install app-engine-go
Restarting command:
$ gcloud components install app-engine-go
I already tried reinstalling the google cloud SDK, but it's the same.
I expect it can show some installation process.
I was trying to deploy a quickstart for .NET Google App Engine application and I run into the same issue. My issue was that I needed to execute $ gcloud components install beta to be able to deploy my GAE .NET app. And I was getting the same behavior as yours. PowerShell would print
Restarting command:
$ gcloud components install beta
but nothing actually happened. No window popup nor installation progress in the same window where I run the command. Also non of the other commands for installing or updating components were working. I could only list them with $ gcloud components list, but not install nor update any of them.
SOLUTION
I have noticed that if you run PowerShell with administrative privileges, it will open a window in C:\Windows\system32 directory. If you execute the command there, then another window will pop up and will proceed with installation or update of gcloud components. However if you cd into different directory the behavior will be as mentioned in this issue.
So to resolve this:
Run PowerShell as Administrative
If the directory is different than what I described above execute $ C:\Windows\system32 otherwise go to Step 3
Execute any command you want for gcloud components. e.g. $ gcloud components update or gcloud components install beta etc.
A window should popup and proceed with the installation or update of the components.
For me a working solution in PowerShell was this:
PS C:\Users\project> $Env:CLOUDSDK_PYTHON = gcloud components copy-bundled-python
After running this command (setting the CLOUDSDK_PYTHON envrionment varible) the command would work without opening another window:
PS C:\Users\project> gcloud components install beta
Your current Google Cloud CLI version is: 413.0.0
Installing components from version: 413.0.0
+---------------------------------------------+
| These components will be installed. |
+----------------------+------------+---------+
| Name | Version | Size |
+----------------------+------------+---------+
| gcloud Beta Commands | 2023.01.06 | < 1 MiB |
+----------------------+------------+---------+
For the latest full release notes, please visit:
https://cloud.google.com/sdk/release_notes
Do you want to continue (Y/n)?
I've also found an issue on the Google issue tracker that looks like it could be related on first glance, but it's closed as not reproducable, so if anyone knows what exactly reproduces this problem share it with Google in this issue

`gcloud preview app deploy` gives MaxRetrialsException in version 105.0.0

When I run gcloud preview app deploy with Cloud SDK version 105.0.0, I get the following error message:
ERROR: gcloud crashed (MaxRetrialsException): last_result=(None, (<class 'googlecloudsdk.calliope.exceptions.BadFileException'>, BadFileException('[.../source-context.json] not found or not accessible',), <traceback object at 0x7f7bb4ab07e8>)), last_retrial=3, time_passed_ms=1,time_to_wait=0
This is a known issue, and is fixed in the 106.0.0 Cloud SDK release. Please update to that release.
If you cannot, work around by running:
gcloud config set app/use_gsutil true
This particular issue happens when using gcloud to deploy to a 'standard' (as opposed to a 'managed VM' or 'flexible') App Engine app that has a .git directory.

ERROR: (gcloud.preview.app) Invalid choice: 'run'

I'm trying to get the golang hello-world bigtable example running locally locally and running into this issue. When I run gcloud preview app run app.yaml from the bigtable-hello directory, I get the following error:
➜ bigtable-hello gcloud preview app run app.yaml
Usage: gcloud
preview app [optional flags] group may be
modules command may be deploy | gen-config
(BETA) This set of commands allows you to deploy your app, manage your existing deployments, and also run your app locally. These
commands replace their equivalents in the appcfg tool.
global flags: Run gcloud -h for a description of flags available
to all commands.
command groups: modules (BETA) View and manage your
App Engine modules.
commands: deploy (BETA) Deploy the local code
and/or configuration of
your app to App Engine. gen-config (BETA) Generate missing configuration files for a
source directory.
ERROR: (gcloud.preview.app) Invalid choice: 'run'.
Valid choices are [deploy, gen-config, gen-repo-info-file, instances,
modules, services, versions].
I've put the demo files into my local go directory like below:
app run is no longer part of the gcloud SDK as can be seen under all the possible command trees:
gcloud alpha has no app command group
gcloud app has no run command
gcloud beta has no run command
gcloud preview app has no app command group
This was removed with version 92.0.0 released on January 13, 2016. That changelog recommends using dev_appserver.py instead. An example can be found in Running the local development server.
> dev_appserver.py src/github.com/jamescharlesworth/bigtable-hello
Other flags and options can be found in dev_appserver.py's documentation in Local Development Server Options.

Using gcloud on Travis CI

I have gcloud installed and working and a service account gets also activated. I run the following and get a success(?):
$ gcloud auth activate-service-account "${GAE_CLIENT_ACCOUNT}" --key-file "${GAE_CLIENT_KEY_JSON_FILE}"
Activated service account credentials for: [xxxxx#developer.gserviceaccount.com]
Then I run this:
$ gcloud preview app deploy app.yaml --project "${GAE_PROJECT_ID}" --quiet --version "${GAE_PROJECT_VERSION}"
You are about to deploy the following modules:
- ricochet-robots/default/dev From: [/home/travis/build/ricochetrobots/ricochetrobots-landing/app.yaml]
Updating module [default]...Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=xxxxxxxx.apps.googleusercontent.com&access_type=offline
Updating module [default].../
As you can see, it prompts me to follow the link and do an oauth. Because I'm on a ci server, it's not possible to follow the link.
How kan I suppress that? Or is there a totally diffrent way of deploying the app automatically.
This is a known issue in version 0.9.61.
For now, you can work around by pinning to a previous version:
gcloud config set component_manager/fixed_sdk_version 0.9.60
gcloud components update
Since you're running in a CI server, you can also set the following environment variable, if you run gcloud components update in your script. This may be an easier fix, depending on your CI server.
CLOUDSDK_COMPONENT_MANAGER_SNAPSHOT_URL=https://dl.google.com/dl/cloudsdk/release/components-v0.9.60.json
Running gcloud preview app deploy --set-default using a service account has the same issue in versions 0.9.57 through 0.9.62. If you'd like to use this command, you can pin to 0.9.56.
We're targeting a fix for version 0.9.63 or shortly thereafter. Follow the issue on the gcloud bug tracker for more updates.
EDIT: This issue was fixed in version 0.9.63.

Resources