post-install-cmd not working in Google App Engine Flexible Environment - google-app-engine

I am trying to update a file permission via composer's post-install-cmd but seems to me it is not working correctly though in the log it says the command executed correctly but when I log in to the VM it still show the incorrect permission.
This is what I have in /composer.json
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-install-cmd": [
"chmod -R 777 public\/external_package\/webmail\/data"
]
}
This is what I have in my /app.yaml
runtime: php
env: flex
service: webservice-dev
runtime_config:
document_root: public
whitelist_functions: phpversion,phpinfo
env_variables:
# Environment variables.
APP_NAME: 'Laravel App (Dev)'
APP_ENV: dev
# ...
# ...
beta_settings:
cloud_sql_instances: ""
automatic_scaling:
min_num_instances: 2
max_num_instances: 10
cpu_utilization:
target_utilization: 0.50
resources:
cpu: 1
memory_gb: 4
Here is the screenshot of Cloud Build
And this is what I see in VM
dr-xr-x--- 1 root www-data 4096 Jan 28 19:18 data
I want this directory permissions to be 777 rather than 550

This is because App Engine always locks the document root path, for this reason the permissions are reverted.
Add this to your app.yaml
runtime_config:
skip_lockdown_document_root: true
The option skip_lockdown_document_root: true will prevent permissions from being changed.

Related

Google App Engine error when use opencensus ext

WARNING: [pool app] child 29 said into stderr: "php-fpm: pool app: symbol lookup error: /opt/php73/lib/x86_64-linux-gnu/extensions/no-debug-non-zts-20180731/opencensus.so: undefined symbol: ZVAL_DESTRUCTOR"
I using GAE env flex. today GAE use php7.3-fpm and i got that error. I check other website in GAE using php7.2-fpm working normally.
How can i fix problem.
Inside your app.yaml you should set the runtime:
env: flex
runtime: php
On your composer.json file you should specify the version that you want to use, for example if you want to use php 7.2 instead of 7.3:
{
"require": {
"php": "7.2.*"
}
}
It's important to specify said version otherwise the runtime might upgrade inadvertently into a new version as mentioned in the official documentation
By default, the PHP runtime uses PHP 7.2, but you should explicitly
declare your PHP version in the composer.json file to prevent your
application from being automatically upgraded when a new version of
PHP becomes available.
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 1
disk_size_gb: 10
runtime_config:
document_root: public
# Ensure we skip ".env", which is only for local development
skip_files:
- .env
- .git
- /vendor/
- /node_modules/
env_variables:
# Put production environment variables here.
APP_LOG: errorlog
APP_KEY: **App_Key**
APP_NAME: Application
APP_ENV: production
APP_DEBUG: true ```

"network: session_affinity:true " property of app.yaml file is not reflecting in google app engine

I am using app.yaml file to configure my app engine. Below is the file.
runtime: java
env: flex
resources:
memory_gb: 6.5
cpu: 5
disk_size_gb: 20
automatic_scaling:
min_num_instances: 6
max_num_instances: 8
cpu_utilization:
target_utilization: 0.6
handlers:
- url: /.*
script: this field is required, but ignored
network:
session_affinity: true
Now when I click the "view" link for the version list in the cloud console, I can see below config.
runtime: java
api_version: '1.0'
env: flexible
threadsafe: true
handlers:
- url: /.*
script: 'this field is required, but ignored'
automatic_scaling:
cool_down_period: 120s
min_num_instances: 6
max_num_instances: 8
cpu_utilization:
target_utilization: 0.6
network: {}
resources:
cpu: 5
memory_gb: 6.5
disk_size_gb: 20
liveness_check:
initial_delay_sec: 300
check_interval_sec: 30
timeout_sec: 4
failure_threshold: 4
success_threshold: 2
readiness_check:
check_interval_sec: 5
timeout_sec: 4
failure_threshold: 2
success_threshold: 2
app_start_timeout_sec: 300
So as you can see network property is still blank, if i change others parameters like cpu , min_num_instances all others properties are getting reflected except below one not sure why ?.
network:
session_affinity: true
Actually this is a known issue for App Engine, the status can be tracked at this link
You can use gcloud beta app deploy as a workaround to get the session affinity working until the issue is resolved
You may need to add an instance_tag and a name. The others are optional:
network:
instance_tag: TAG_NAME
name: NETWORK_NAME
session_affinity: true (optional)
subnetwork_name: SUBNETWORK_NAME (optional)
forwarded_ports: (optional)
- PORT
- HOST_PORT:CONTAINER_PORT
- PORT/tcp
- HOST_PORT:CONTAINER_PORT/udp

Connect to Google Cloud postgres SQl from Google App Engine Custom flex environment

I have a Java application for which the database configuration is read through the following file:
db.properties
dataSourceClassName = org.postgresql.ds.PGSimpleDataSource
dataSource.serverName = 127.0.0.1
dataSource.databaseName = <db name>
dataSource.portNumber = 5432
dataSource.user = postgres
dataSource.password = <password>
maximumPoolSize = 5
I have built a Dockerfile which
creates a container for the java application
exposes ports 8080, and 5432
starts the webserver with ENTRYPOINT ["mvn", "jetty:run"]
My app.yaml file for flex environment:
runtime: custom
env: flex
network:
instance_tag: nlpapigae
session_affinity: true
# forwarded_ports:
# - 8080
resources:
cpu: 8
memory_gb: 40
disk_size_gb: 32
automatic_scaling:
min_num_instances: 1
max_num_instances: 10
cool_down_period_sec: 180
cpu_utilization:
target_utilization: .75
beta_settings:
cloud_sql_instances: <instance name>=tcp:5432
env_variables:
POSTGRES_HOST: "/cloudsql/<instance name>"
POSTGRES_DB: <db name>
POSTGRES_USER: postgres
POSTGRES_PASSWORD: <password>
When I deploy the application, I get the error that Postgres db is not reachable. How do i get this right?
Try enabling the Cloud SQL Admin API. If you are connecting between multiple projects, check out the Connecting to App Engine page to ensure your service account has the correct permissions.
As a Java user, you may also be interested in the Cloud SQL JDBC Socket Factory.

Google App engine Deoployment receives ERROR Only when specifiying CPUs above 1 in app.yaml

I have a Flask app that deploys fine in the Google App Engine Flexible environment but some new updates have made it relatively resource intensive (Was receiving a [CRITICAL] Worker Timeout message.) In attempting to fix this issue I wanted to increase the number of CPUs for my app.
app.yaml:
env: flex
entrypoint: gunicorn -t 600 --timeout 600 -b :$PORT main:server
runtime: python
threadsafe: false
runtime_config:
python_version: 2
automatic_scaling:
min_num_instances: 3
max_num_instances: 40
cool_down_period_sec: 260
cpu_utilization:
target_utilization: .5
resources:
cpu: 3
After some time I receive:
"Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [13] An internal error occurred during deployment."
Is there some sort of permission issue preventing me from increasing the CPUs? Or is my app.ymal invalid?
You can not set the number of cores(CPU) to odd numbers except 1. It should be even.

GAE: Upgrading vm: true to env: flex drives auto-scaler to create infinite amount of instances

I've noticed that when I'm upgrading the vm tag to the new env one, that the auto scaler creates an infinite amount of instances during the deployment process. This only happens when I'm using the new env flag. This is my conf file:
runtime: custom
vm: true
service: default
threadsafe: true
health_check:
enable_health_check: True
check_interval_sec: 5
timeout_sec: 4
unhealthy_threshold: 2
healthy_threshold: 2
restart_threshold: 60
automatic_scaling:
min_num_instances: 1
cool_down_period_sec: 60
cpu_utilization:
target_utilization: 0.9
It would be great if anyone could help me because I'm unable to migrate my VM's because of this problem.
Cheers

Resources