Gitlab CD crashes during deployment to google app engine - node.js

I have nodeJs app that deployed on google app engine.
When I trigger deployment through GitLab CD everything goes ok.
Recently CD pipeline started returning errors, I add --verbosity=debug flag and get the following report (from GitLab CI)
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 2 files to Google Cloud Storage ═╣
╚INFO: Uploading [/builds/***/***/api/package.json] to [staging.***.appspot.com/***]
INFO: Uploading [/tmp/tmp2sf554dn/source-context.json] to [staging.***.appspot.com/***]
════════════════════════════════════════════════════════════╝
File upload done.
DEBUG: Converted YAML to JSON: "{
"entrypoint": {
"shell": ""
},
"runtime": "nodejs12"
}"
DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
Updating service [api]...
......DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
................................DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
.................................DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
...............................DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
................................DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
...............................DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
............................DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
.............................DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
.............................DEBUG: Operation [apps/***/operations/***] not complete. Waiting to retry.
............................DEBUG: Operation [apps/***/operations/***] complete. Result: {
"error": {
"message": "Cloud build *** status: FAILURE\nError type: OK\nFull build logs: https://console.cloud.google.com/cloud-build/builds/***?project=***",
"code": 9
},
"metadata": {
"target": "***",
"method": "google.appengine.v1.Versions.CreateVersion",
"user": "***",
"endTime": "2020-09-10T09:46:28.638Z",
"#type": "type.googleapis.com/google.appengine.v1.OperationMetadataV1",
"insertTime": "2020-09-10T09:45:34.795Z"
},
"done": true,
"name": "apps/MY_PROJECT/operations/***"
}
failed.
DEBUG: (gcloud.app.deploy) Error Response: [9] Cloud build *** status: FAILURE
Error type: OK
Full build logs: https://console.cloud.google.com/cloud-build/builds/***?project=***
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 983, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 808, in Run
resources = command_instance.Run(args)
File "/usr/lib/google-cloud-sdk/lib/surface/app/deploy.py", line 121, in Run
default_strategy=flex_image_build_option_default))
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 644, in RunDeploy
ignore_file=args.ignore_file)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 430, in Deploy
extra_config_settings)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/appengine_api_client.py", line 208, in DeployService
poller=done_poller)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/operations_util.py", line 314, in WaitForOperation
sleep_ms=retry_interval)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 264, in WaitFor
sleep_ms, _StatusUpdate)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 326, in PollUntilDone
sleep_ms=sleep_ms)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 229, in RetryOnResult
if not should_retry(result, state):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 320, in _IsNotDone
return not poller.IsDone(operation)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/operations_util.py", line 183, in IsDone
encoding.MessageToPyValue(operation.error)))
googlecloudsdk.api_lib.app.operations_util.OperationError: Error Response: [9] Cloud build *** status: FAILURE
Error type: OK
Full build logs: https://console.cloud.google.com/cloud-build/builds/***?project=***
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build *** status: FAILURE
Error type: OK
Full build logs: https://console.cloud.google.com/cloud-build/builds/***
I checked the report on cloud build and get the following:
......
Setting CNB_DEPRECATION_MODE=quiet
Setting ENTRYPOINT: '/cnb/lifecycle/launcher'
*** Images (sha256:***):
eu.gcr.io/***/app-engine-tmp/app/ttl-2h/api/buildpack-app:latest - GET https://storage.googleapis.com/eu.artifacts.***.appspot.com/containers/images/sha256:***?access_token=REDACTED: unsupported status code 404; body: <?xml version='1.0' encoding='UTF-8'?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Details>No such object: eu.artifacts.***.appspot.com/containers/images/sha256:***</Details></Error>
*** Digest: sha256:***
ERROR: failed to export: failed to write image to the following tags: [eu.gcr.io/***/app-engine-tmp/app/ttl-2h/api/buildpack-app:latest: GET https://storage.googleapis.com/eu.artifacts.***.appspot.com/containers/images/sha256:***?access_token=REDACTED: unsupported status code 404; body: <?xml version='1.0' encoding='UTF-8'?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Details>No such object: eu.artifacts.***.appspot.com/containers/images/sha256:***</Details></Error>]
I don't alter the service account which used for deployment to google app engine before
Interesting detail that when I trigger deployment locally everything goes OK, and from custom GitLab.domain, but when I start to trigger on gitlab.com crashes recently.
Maybe you have a similar experience from fixing such problems?
Thanks.

Related

Apache Airflow with Python Exception: Expected state: SUCCESS. Actual state: failed

I'm running apache-airflow on my Mac m1 to insert data from a staging table(the temporary table was created from S3) to AWS redshift.
The following error was raised, and it doesn't tell me what the source issue is. Could anybody please help me debug?
[2022-07-30 16:16:58,226] {subdag.py:186} INFO - Execution finished. State is failed
[2022-07-30 16:16:58,252] {taskinstance.py:1909} ERROR - Task failed with exception
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1471, in _run_raw_task
self._execute_task_with_callbacks(context, test_mode)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1621, in _execute_task_with_callbacks
self.task.post_execute(context=context, result=result)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/operators/subdag.py", line 189, in post_execute
raise AirflowException(f"Expected state: SUCCESS. Actual state: {dag_run.state}")
airflow.exceptions.AirflowException: Expected state: SUCCESS. Actual state: failed
[2022-07-30 16:16:58,268] {taskinstance.py:1415} INFO - Marking task as FAILED. dag_id=sparkify_dag, task_id=load_artist_dim_table, execution_date=20220729T174100, start_date=20220730T161557, end_date=20220730T161658
[2022-07-30 16:16:58,298] {standard_task_runner.py:92} ERROR - Failed to execute job 399 for task load_artist_dim_table (Expected state: SUCCESS. Actual state: failed; 55013)
[2022-07-30 16:16:58,356] {local_task_job.py:156} INFO - Task exited with return code 1
[2022-07-30 16:16:58,426] {local_task_job.py:273} INFO - 0 downstream tasks scheduled from follow-on schedule check

GAE deployment throwing Error Response: [13] The system encountered a fatal error

Encountering problem when deploying Node/React application to App engine using the command: gcloud app deploy --quiet --no-promote --no-stop-previous-version --version={VERSION_NUMBER}. This didn't happen before with the previous deployments only until today.
I've also checked the deployment and application logs in Cloud Console and there are no errors. This code is also working on my local and there are no changes to the configuration so I don't know where the problem is coming from. Also did deploy the reverted code but the error is still the same.
app.yaml file:
runtime: custom
env: flex
resources:
cpu: 1
memory_gb: 2
disk_size_gb: 15
manual_scaling:
instances: 1
Here's the logs when running the debug mode: Result:
{ "done": true, "error": { "code": 13, "message": "The system encountered a fatal error" }, "metadata": { "#type": "type.googleapis.com/google.appengine.v1.OperationMetadataV1", "createVersionMetadata": { "cloudBuildId": "4e46d51e-f408-479e-ad06-81cd794d9028" }, "endTime": "2022-05-25T15:41:26.285Z", "insertTime": "2022-05-25T15:10:10.933Z", "method": "google.appengine.v1.Versions.CreateVersion", "target": "{OMITTED}", "user": "{OMITTED}" }, "name": "apps/{OMITTED}/operations/e9d94daa-055b-4903-8cbf-372df1ce5c3c" } Updating service [default] (this may take several minutes)...failed. DEBUG: (gcloud.app.deploy) Error Response: [13] The system encountered a fatal error Traceback (most recent call last): File "C:\Users\USER\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 987, in Execute resources = calliope_command.Run(cli=self, args=args) File "C:\Users\USER\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 809, in Run resources = command_instance.Run(args) File "C:\Users\USER\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\surface\app\deploy.py", line 127, in Run return deploy_util.RunDeploy( File "C:\Users\USER\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\app\deploy_util.py", line 692, in RunDeploy aiter.py", line 320, in _IsNotDone return not poller.IsDone(operation) File "C:\Users\USER\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\operations_util.py", line 182, in IsDone raise OperationError(requests.ExtractErrorMessage(googlecloudsdk.api_lib.app.operations_util.OperationError: Error Response: [13] The system encountered a fatal error ERROR: (gcloud.app.deploy) Error Response: [13] The system encountered a fatal error
I've submitted a ticket to GCP support but haven't responded yet. Wondering if someone here has encountered this error before and the resolution.
As per this public issue tracker, The Google Support Team suggests using the commands below to fix the issue:
gcloud config set interactive/hidden true
then:
gcloud app update --service account=your_project_id#appspot.gserviceaccount.com
I raised a ticket to Google Support team and they came back saying it was due to the latest release of GAE that caused it. They said they have reverted the change and it is now working as expected.

Anchore Engine - Jenkins CI plugin

We are trying to scan our docker images using Anchore Engine Jenkins plugin.
Currently we create our application docker images, push it in our own private local registry and then deploy it in our test environments.
Now, we want to setup docker image scanning in our CI/CD process to check for any vulnerabilities.
We have installed Anchore Engine using the recommended Docker-Compose yaml method given in the Documentation link:
https://anchore.freshdesk.com/support/solutions/articles/36000020729-install-on-docker-swarm
Post installation, we installed the
Anchore Container Image Scanner Plugin in Jenkins.
We configured the plugin as mentioned in the document link:
https://wiki.jenkins.io/display/JENKINS/Anchore+Container+Image+Scanner+Plugin
However, the scanning fails. Error Message as follows:
2018-10-11T07:01:44.647 INFO AnchoreWorker Analysis request accepted, received image digest sha256:7d6fb7e5e7a74a4309cc436f6d11c29a96cbf27a4a8cb45a50cb0a326dc32fe8
2018-10-11T07:01:44.647 INFO AnchoreWorker Waiting for analysis of 10.180.25.2:5000/hello-world:latest, polling status periodically
2018-10-11T07:01:44.647 DEBUG AnchoreWorker anchore-engine get policy evaluation URL: http://10.180.25.2:8228/v1/images/sha256:7d6fb7e5e7a74a4309cc436f6d11c29a96cbf27a4a8cb45a50cb0a326dc32fe8/check?tag=10.180.25.2:5000/hello-world:latest&detail=true
2018-10-11T07:01:44.648 DEBUG AnchoreWorker Attempting anchore-engine get policy evaluation (1/300)
2018-10-11T07:01:44.675 DEBUG AnchoreWorker anchore-engine get policy evaluation failed. URL: http://10.180.25.2:8228/v1/images/sha256:7d6fb7e5e7a74a4309cc436f6d11c29a96cbf27a4a8cb45a50cb0a326dc32fe8/check?tag=10.180.25.2:5000/hello-world:latest&detail=true, status: HTTP/1.1 404 NOT FOUND, error: {
"detail": {},
"httpcode": 404,
"message": "image is not analyzed - analysis_status: not_analyzed"
}
NOTE:
In Image TAG 10.180.25.2:5000/hello-world:latest, 10.180.25.2:5000 is our local private registry and hello-world:latest is latest hello-world image available in docker hub which we pulled and pushed in our registry to try out image scanning using Anchore-Engine.
Unfortunately we are not able to find much resource online to try and resolve the above mentioned issue.
Anyone who might have worked on Anchore-Engine, please may I request to have a look and help us resolve this issue.
Also, any suggestions or alternatives to anchore-engine or detailed steps in case we might have missed anything would be really appreciated.
End of the output is as follows:
2018-10-15T00:48:43.880 WARN AnchoreWorker anchore-engine get policy evaluation failed. HTTP method: GET, URL: http://10.180.25.2:8228/v1/images/sha256:7d6fb7e5e7a74a4309cc436f6d11c29a96cbf27a4a8cb45a50cb0a326dc32fe8/check?tag=10.180.25.2:5000/hello-world:latest&detail=true, status: 404, error: {
"detail": {},
"httpcode": 404,
"message": "image is not analyzed - analysis_status: not_analyzed"
}
2018-10-15T00:48:43.880 WARN AnchoreWorker Exhausted all attempts polling anchore-engine. Analysis is incomplete for sha256:7d6fb7e5e7a74a4309cc436f6d11c29a96cbf27a4a8cb45a50cb0a326dc32fe8
2018-10-15T00:48:43.880 ERROR AnchorePlugin Failing Anchore Container Image Scanner Plugin step due to errors in plugin execution
hudson.AbortException: Timed out waiting for anchore-engine analysis to complete (increasing engineRetries might help). Check above logs for errors from anchore-engine
at com.anchore.jenkins.plugins.anchore.BuildWorker.runGatesEngine(BuildWorker.java:480)
at com.anchore.jenkins.plugins.anchore.BuildWorker.runGates(BuildWorker.java:343)
at com.anchore.jenkins.plugins.anchore.AnchoreBuilder.perform(AnchoreBuilder.java:338)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1724)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
I also checked status and found below:
docker run anchore/engine-cli:latest anchore-cli --u admin --p admin123 --url http://172.18.0.1:8228/v1 system status
Service analyzer (dockerhostid-anchore-engine, http://anchore-engine:8084): up
Service catalog (dockerhostid-anchore-engine, http://anchore-engine:8082): up
Service policy_engine (dockerhostid-anchore-engine, http://anchore-engine:8087): down (unavailable)
Service simplequeue (dockerhostid-anchore-engine, http://anchore-engine:8083): up
Service apiext (dockerhostid-anchore-engine, http://anchore-engine:8228): up
Service kubernetes_webhook (dockerhostid-anchore-engine, http://anchore-engine:8338): up
Engine DB Version: 0.0.7
Engine Code Version: 0.2.4
It seems service policy engine is down
Service policy_engine (dockerhostid-anchore-engine, http://anchore-engine:8087): down (unavailable)
I also checked the docker logs . I found below error:
[service:policy_engine] 2018-10-15 09:37:46+0000 [-] [bootstrap] [DEBUG] service (policy_engine) starting in: 4
[service:policy_engine] 2018-10-15 09:37:46+0000 [-] [bootstrap] [INFO] Registration complete.
[service:policy_engine] 2018-10-15 09:37:46+0000 [-] [bootstrap] [INFO] Checking feeds client credentials
[service:policy_engine] 2018-10-15 09:37:46+0000 [-] [bootstrap] [DEBUG] Initializing a feeds client
[service:policy_engine] 2018-10-15 09:37:47+0000 [-] [bootstrap] [DEBUG] init values: [None, None, None, (), None, None]
[service:policy_engine] 2018-10-15 09:37:47+0000 [-] [bootstrap] [DEBUG] using values: ['https://ancho.re/v1/service/feeds', 'https://ancho.re/oauth/token', 'https://ancho.re/v1/account/users', 'anon#ancho.re', 3, 60]
[service:policy_engine] 2018-10-15 09:37:47+0000 [-] [urllib3.connectionpool] [DEBUG] Starting new HTTPS connection (1): ancho.re
[service:policy_engine] 2018-10-15 09:37:50+0000 [-] [bootstrap] [ERROR] Preflight checks failed with error: HTTPSConnectionPool(host='ancho.re', port=443): Max retries exceeded with url: /v1/account/users/anon#ancho.re (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ffa905f0b90>: Failed to establish a new connection: [Errno 113] No route to host',)). Aborting service startup
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/anchore_manager/cli/service.py", line 158, in startup_service
raise Exception("process exited: " + str(rc))
Exception: process exited: 1
[anchore-policy-engine] [anchore_manager.cli.service/startup_service()] [INFO] service process exited at (Mon Oct 15 09:37:50 2018): process exited: 1
[anchore-policy-engine] [anchore_manager.cli.service/startup_service()] [INFO] exiting service thread
Thanks and Regards,
Rohan Shetty
When images are added to anchore-engine, they are queued for analysis which moves them through a simple state machine that starts with ‘not_analyzed’, goes to ‘analyzing’ and finally ends in either ‘analyzed’ or ‘analysis_failed’. Only when an image has reached ‘analyzed’ will a policy evaluation be possible.
The anchore Jenkins plugin will add an image, then poll the engine for image status/evaluation for the configured number of tries (default 300). Once the image goes to ‘analyzed’ (where policy evaluation is possible), the plugin will then receive a policy evaluation result from the engine.
The plugin will fail the build (by default) if the max retries has been performed and the image has not reached ‘analyzed’, if the image does reach ‘analyzed’ but the policy evaluation is producing a ‘fail’ result (meaning the image didn’t pass your configured policy checks). Note that all build failure behavior can be controlled in the plugin (I.e. there are options to allow the plugin to succeed even if the analysis or image eval fails).
You’ll need to look at the end of the output from your build run (instead of just the beginning from your post), and combined with the information above, it should be clear which scenario is causing the plugin to fail the build.
We have resolved the issue.
Root Cause:
We were not able to establish a successful https connection to URL : https://ancho.re from within the anchore-engine docker container.
As a result the service:policy_engine was not able to start.
https://ancho.re is required to download policy feeds and sync-up periodically. Without these policy anchore-engine won't be able to analyse the docker images.
Solution:
1) We passed a HTTPS_PROXY URL as an environment variable in the docker-compose.yaml of anchore-engine.
We used this proxy URL to bypass restrictions in our environment and establish a connection with https://ancho.re url.
2) Restarted the docker containers.
Finally we got all services up and running including Anchore policy-engine.
FYI:
It takes a while to download all the required Feeds depending on your internet speed.
Lastly, Thanks to the Anchore community for quick responses and support over slack.
Hope this helps.
Warm Regards,
Rohan Shetty

Deploying Angular-Fullstack (MEAN) on Google App Engine

I've generated a project with Yeoman Angular-Fullstack generator (https://github.com/angular-fullstack/generator-angular-fullstack).
I created an app.yaml and tried to deploy the project on GAE with command:
gcloud app deploy
But I'm getting an error:
ERROR: (gcloud.app.deploy) Error Response: [13] Timed out when starting VMs. It's possible that the application code is unhealthy. (0/2 ready, 2 still deploying).
Any tips on how to debug the gcloud deploy? I'm running the latest gcloud SDK.
--
Here's a longer debug trace:
Updating service [default]...-DEBUG: Operation [apps/<MY-PROJECT>/operations/63e50c89-da5f-4697-aeea-447865a82cc4] not complete. Waiting 5s.
Updating service [default]...|DEBUG: Operation [apps/<MY-PROJECT>/operations/63e50c89-da5f-4697-aeea-447865a82cc4] complete. Result: {
"metadata": {
"target": "apps/<MY-PROJECT>/services/default/versions/20160804t151734",
"method": "google.appengine.v1beta5.Versions.CreateVersion",
"user": "<MY-EMAIL>#gmail.com",
"insertTime": "2016-08-04T12:16:31.905Z",
"endTime": "2016-08-04T12:24:03.526Z",
"#type": "type.googleapis.com/google.appengine.v1beta5.OperationMetadataV1Beta5"
},
"done": true,
"name": "apps/<MY-PROJECT>/operations/63e50c89-da5f-4697-aeea-447865a82cc4",
"error": {
"message": "Timed out when starting VMs. It's possible that the application code is unhealthy. (0/2 ready, 2 still deploying).",
"code": 13
}
}
Updating service [default]...failed.
DEBUG: (gcloud.app.deploy) Error Response: [13] Timed out when starting VMs. It's possible that the application code is unhealthy. (0/2 ready, 2 still deploying).
Traceback (most recent call last):
File "/Users/jp/softaa/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 719, in Execute
result = args.calliope_command.Run(cli=self, args=args)
File "/Users/jp/softaa/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 1404, in Run
resources = command_instance.Run(args)
File "/Users/jp/softaa/google-cloud-sdk/lib/surface/app/deploy.py", line 57, in Run
return deploy_util.RunDeploy(self, args)
File "/Users/jp/softaa/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 215, in RunDeploy
api_client.DeployService(name, version, service, manifest, image)
File "/Users/jp/softaa/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/appengine_api_client.py", line 89, in DeployService
return operations.WaitForOperation(self.client.apps_operations, operation)
File "/Users/jp/softaa/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/api/operations.py", line 70, in WaitForOperation
encoding.MessageToPyValue(completed_operation.error)))
OperationError: Error Response: [13] Timed out when starting VMs. It's possible that the application code is unhealthy. (0/2 ready, 2 still deploying).
ERROR: (gcloud.app.deploy) Error Response: [13] Timed out when starting VMs. It's possible that the application code is unhealthy. (0/2 ready, 2 still deploying).
GAE does not come with Mongo. You have two options
Use GAE flex and build your own mongo container and use it
Use a Mongo cloud provider like https://mlab.com and they even have a free version to test.
If your question is just about finding the cause of this error, I would recommend using the Development Server on your localhost to find the error.
Without taking a deeper look, I guess the Node part does not fulfil the requirements for GAE or you are trying to deploy to a region where Node Applications are not supported.

gcloud preview app deploy returns 400 with message App engine service account has insufficient permissions for project. Developer or owner required

I am trying to deploy node.js application to google cloud platform, So I have taken up following approach:
Assume my project id : "logger"(#445533661888)
1) I followed this documentation link to deploy application, link : https://cloud.google.com/nodejs/resources/frameworks/express
2) Projects app.yaml includes :
runtime: nodejs
vm: true
service: default
skip_files:
- ^(.*/)?.*/node_modules/.*$
3) Now went to google cloud console --> IAM & Admin menu, here I can see logger#appspot.gserviceaccount.com entry, Also I have added permission of owner to myemail#gmail.com to this service account
4) Now used command gcloud auth login to authenticate and used myemail#gmail.com to complete authentication
4) Now I used gcloud preview app deploy to start deployment, in this request's response I get Bad Request error 400 and Message as
App engine service account has insufficient permissions for project. Developer or owner required
I am presenting stack trace :
C:\Users\Maulikwin8>gcloud config list
Your active configuration is: [default]
[app]
suppress_change_warning = true
[core]
account = myemail#gmail.com
disable_usage_reporting = False
project = logger
C:\Users\Maulikwin8>cd C:\Users\Maulikwin8\Documents\swan\rnd\node-express-js\nodejs-docs-samples-master\appengine\express
C:\Users\Maulikwin8\Documents\swan\rnd\node-express-js\nodejs-docs-samples-master\appengine\express>gcloud preview app deploy --verbosity=debug
DEBUG: Running gcloud.preview.app.deploy with Namespace(__calliope_internal_deepest_parser=ArgumentParser(prog='gcloud.preview.app.deploy', usage=None, description="*(BETA)* This command is used to deploy both code and configuration to the
App Engine\nserver. As an input it takes one or more ``DEPLOYABLES'' that should be\nuploaded. A ``DEPLOYABLE'' can be a service's .yaml file or a configuration's\n.yaml file.", version=None, formatter_class=<class 'argparse.HelpFormatter
'>, conflict_handler='error', add_help=False), account=None, authority_selector=None, authorization_token_file=None, bucket=None, cmd_func=<bound method Command.Run of <googlecloudsdk.calliope.backend.Command object at 0x03078550>>, command
_path=['gcloud', 'preview', 'app', 'deploy'], configuration=None, credential_file_override=None, deployables=[], docker_build=None, document=None, force=False, format=None, h=None, help=None, http_timeout=None, ignore_bad_certs=False, image
_url=None, log_http=None, project=None, promote=None, quiet=None, repo_info_file=None, server=None, stop_previous_version=None, trace_email=None, trace_log=None, trace_token=None, user_output_enabled=None, verbosity='debug', version=None).
INFO: Refreshing access_token
DEBUG: API endpoint: [https://appengine.googleapis.com/], API version: [v1beta4]
You are about to deploy the following services:
- logger/deployment (from [C:\Users\Maulikwin8\Documents\swan\rnd\node-express-js\nodejs-docs-samples-master\appengine\express\app.yaml])
Deployed URL: [https://deployment-dot-logger.appspot.com]
Do you want to continue (Y/n)? Y
Beginning deployment...
DEBUG: No bucket specified, retrieving default bucket.
DEBUG: Using bucket [<googlecloudsdk.api_lib.app.cloud_storage.BucketReference object at 0x03E7A7B0>].
DEBUG: Host: appengine.google.com
DEBUG: _Authenticate configuring auth; needs_auth=False
DEBUG: Sending request to https://appengine.google.com/api/vms/prepare?app_id=logger headers={'X-appcfg-api-version': '1', 'content-length': '0', 'Content-Type': 'application/octet-stream'} body=
INFO: Attempting refresh to obtain initial access_token
INFO: Refreshing access_token
DEBUG: Got http error 400.
DEBUG: Unexpected results: {'status': '400', 'alternate-protocol': '443:quic', 'content-length': '162', 'expires': 'Mon, 01 Jan 1990 00:00:00 GMT', 'server': 'Google Frontend', 'cache-control': 'no-cache', 'date': 'Wed, 11 May 2016 10:44:32
GMT', 'alt-svc': 'quic=":443"; ma=2592000; v="33,32,31,30,29,28,27,26,25"', 'content-type': 'text/plain'}
WARNING: If this is your first deployment, please try again.
DEBUG: (gcloud.preview.app.deploy) Server responded with code [400]:
Bad Request Unexpected HTTP status 400.
Failed Project Preparation (app_id='s~logger'). App Engine service account has insufficient permissions for project. Developer or owner required.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 647, in Execute
result = args.cmd_func(cli=self, args=args)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 1407, in Run
resources = command_instance.Run(args)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\surface\preview\app\deploy.py", line 482, in Run
deploy_command_util.DoPrepareManagedVms(clients.gae)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\deploy_command_util.py", line 260, in DoPrepareManagedVms
gae_client.PrepareVmRuntime()
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\appengine_client.py", line 207, in PrepareVmRuntime
rpcserver.Send('/api/vms/prepare', app_id=self.project)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\util.py", line 365, in Send
response = self._server.Send(*args, **kwargs)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\third_party\appengine\tools\appengine_rpc_httplib2.py", line 298, in Send
'Unexpected HTTP status %s' % status)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\third_party\appengine\tools\appengine_rpc_httplib2.py", line 82, in RaiseHttpError
raise urllib2.HTTPError(url, response_info.status, msg, response_info, stream)
RPCError: Server responded with code [400]:
Bad Request Unexpected HTTP status 400.
Failed Project Preparation (app_id='s~logger'). App Engine service account has insufficient permissions for project. Developer or owner required.
ERROR: (gcloud.preview.app.deploy) Server responded with code [400]:
Bad Request Unexpected HTTP status 400.
Failed Project Preparation (app_id='s~logger'). App Engine service account has insufficient permissions for project. Developer or owner required.
I got solution, actually I was thinking that myemail#gmail.com should be owner of project.
But I did not pay much attention to their words which were "App engine service account has insufficient permissions for project. Developer or owner required"
steps :
Go to services accounts listing in developer console
select "your-project-id#appspot.gserviceaccount.com", click on permissions.
add your-project-id#appspot.gserviceaccount.com to new member and assign role as owner.
It solves problem

Resources