GoogleCloudPlatform / appengine-ruby

Optional integration library for the Ruby runtime for Google App Engine
Apache License 2.0
53 stars 21 forks source link

Error connecting to Redis (Redis::TimeoutError) (Redis::CannotConnectError) #36

Open jonasmora opened 4 years ago

jonasmora commented 4 years ago

I have a rack app with redis, the app is working fine but when I try to run a script using appengine:exec I receive a timeout error.

Any help would be appreciate it.

 bundle exec rake appengine:exec GAE_PROJECT=machinal-test GAE_CONFIG=app-development.yaml -- bundle exec ruby scripts/update_leaderboards.rb

Using the `cloud_build` strategy for appengine:exec
(i.e. running your app image in Cloud Build)
PROJECT: machinal-test
SERVICE: default
VERSION: 20200811t172903
TIMEOUT: 30m

Created [https://cloudbuild.googleapis.com/v1/projects/machinal-test/builds/1d90cf68-0cd3-471c-8095-e4784e13f709].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/1d90cf68-0cd3-471c-8095-e4784e13f709?project=517948324116].
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- REMOTE BUILD OUTPUT ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
starting build "1d90cf68-0cd3-471c-8095-e4784e13f709"

FETCHSOURCE
BUILD
Pulling image: gcr.io/google-appengine/exec-wrapper:latest
latest: Pulling from google-appengine/exec-wrapper
75f546e73d8b: Already exists
0f3bb76fc390: Already exists
3c2cba919283: Already exists
60a2832f551e: Pulling fs layer
261fe7768d03: Pulling fs layer
1a1bdff19664: Pulling fs layer
1a1bdff19664: Verifying Checksum
1a1bdff19664: Download complete
261fe7768d03: Verifying Checksum
261fe7768d03: Download complete
60a2832f551e: Verifying Checksum
60a2832f551e: Download complete
60a2832f551e: Pull complete
261fe7768d03: Pull complete
1a1bdff19664: Pull complete
Digest: sha256:6819234d5d981983dc4d7afd3722d35194d3e10264218515a0577fcf93f06993
Status: Downloaded newer image for gcr.io/google-appengine/exec-wrapper:latest
gcr.io/google-appengine/exec-wrapper:latest

---------- INSTALL IMAGE ----------
sha256:71b97a04a5bde5aecf5132261df1231e113348d852880a79eb9bc2202f7f8211: Pulling from machinal-test/appengine/default.20200811t172903
bd47987755ba: Pulling fs layer
831c222b21d8: Pulling fs layer
3c2cba919283: Pulling fs layer
d4078914ea9b: Pulling fs layer
0b738ba60421: Pulling fs layer
b36ab2b2370c: Pulling fs layer
2a1964acb7aa: Pulling fs layer
5548dfc15af8: Pulling fs layer
2b63f569a95a: Pulling fs layer
9c2ba3f56571: Pulling fs layer
d4078914ea9b: Waiting
0b738ba60421: Waiting
b36ab2b2370c: Waiting
2a1964acb7aa: Waiting
5548dfc15af8: Waiting
9c2ba3f56571: Waiting
2b63f569a95a: Waiting
3c2cba919283: Verifying Checksum
3c2cba919283: Download complete
831c222b21d8: Verifying Checksum
831c222b21d8: Download complete
0b738ba60421: Verifying Checksum
0b738ba60421: Download complete
b36ab2b2370c: Verifying Checksum
b36ab2b2370c: Download complete
bd47987755ba: Verifying Checksum
bd47987755ba: Download complete
2a1964acb7aa: Verifying Checksum
2a1964acb7aa: Download complete
2b63f569a95a: Verifying Checksum
2b63f569a95a: Download complete
5548dfc15af8: Verifying Checksum
5548dfc15af8: Download complete
9c2ba3f56571: Verifying Checksum
9c2ba3f56571: Download complete
d4078914ea9b: Verifying Checksum
d4078914ea9b: Download complete
bd47987755ba: Pull complete
831c222b21d8: Pull complete
3c2cba919283: Pull complete
d4078914ea9b: Pull complete
0b738ba60421: Pull complete
b36ab2b2370c: Pull complete
2a1964acb7aa: Pull complete
5548dfc15af8: Pull complete
2b63f569a95a: Pull complete
9c2ba3f56571: Pull complete
Digest: sha256:71b97a04a5bde5aecf5132261df1231e113348d852880a79eb9bc2202f7f8211
Status: Downloaded newer image for us.gcr.io/machinal-test/appengine/default.20200811t172903@sha256:71b97a04a5bde5aecf5132261df1231e113348d852880a79eb9bc2202f7f8211

---------- CONNECT CLOUDSQL ----------
cloud_sql_proxy is running.

---------- EXECUTE COMMAND ----------
bundle exec ruby scripts/update_leaderboards.rb
Database settings: {:adapter=>"postgres", :host=>"/cloudsql/machinal-test:us-central1:machinal-development", :database=>"machinal_data_server", :user=>"machinal_api"}
Redis settings: {:host=>"10.7.90.107", :port=>"6379"}
/app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:362:in `rescue in establish_connection': Error connecting to Redis on 10.7.90.107:6379 (Redis::TimeoutError) (Redis::CannotConnectError)
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:343:in `establish_connection'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:107:in `block in connect'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:308:in `with_reconnect'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:106:in `connect'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:381:in `ensure_connected'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:233:in `block in process'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:320:in `logging'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:232:in `process'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:198:in `call_pipelined'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:165:in `block in call_pipeline'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:308:in `with_reconnect'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis/client.rb:163:in `call_pipeline'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis.rb:2492:in `block in multi'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis.rb:69:in `block in synchronize'
    from /opt/rbenv/versions/2.5.7/lib/ruby/2.5.0/monitor.rb:235:in `mon_synchronize'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis.rb:69:in `synchronize'
    from /app/vendor/bundle/ruby/2.5.0/gems/redis-4.2.1/lib/redis.rb:2484:in `multi'
    from /app/vendor/bundle/ruby/2.5.0/gems/leaderboard-3.12.1/lib/leaderboard.rb:142:in `rank_member_in'
    from /app/vendor/bundle/ruby/2.5.0/gems/leaderboard-3.12.1/lib/leaderboard.rb:132:in `rank_member'
    from scripts/update_leaderboards.rb:8:in `block (2 levels) in <main>'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/dataset/actions.rb:150:in `block in each'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:614:in `block (2 levels) in fetch_rows'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:800:in `yield_hash_rows'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:614:in `block in fetch_rows'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:146:in `execute'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:500:in `_execute'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:318:in `block (2 levels) in execute'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:522:in `check_database_errors'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:318:in `block in execute'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/connection_pool/threaded.rb:92:in `hold'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/database/connecting.rb:270:in `synchronize'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:318:in `execute'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/dataset/actions.rb:1089:in `execute'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/adapters/postgres.rb:614:in `fetch_rows'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/dataset/actions.rb:150:in `each'
    from /app/vendor/bundle/ruby/2.5.0/gems/sequel-5.32.0/lib/sequel/model/plugins.rb:33:in `each'
    from scripts/update_leaderboards.rb:7:in `block in <main>'
    from scripts/update_leaderboards.rb:5:in `each'
    from scripts/update_leaderboards.rb:5:in `<main>'
ERROR
ERROR: build step 0 "gcr.io/google-appengine/exec-wrapper:latest" failed: step exited with non-zero status: 1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ERROR: (gcloud.builds.submit) build 1d90cf68-0cd3-471c-8095-e4784e13f709 completed with status "FAILURE"
rake aborted!
AppEngine::Util::Gcloud::GcloudFailed: GCloud failed with result code 1
/Users/jonas/.rbenv/versions/2.5.7/bin/bundle:23:in `load'
/Users/jonas/.rbenv/versions/2.5.7/bin/bundle:23:in `<main>'
Tasks: TOP => appengine:exec
(See full trace by running task with --trace)
jonasmora commented 4 years ago

Based on this comment

https://github.com/GoogleCloudPlatform/appengine-ruby/blob/b071f8e922ed5c1b88be045ee2a8fcc0aa9e90dd/lib/appengine/tasks.rb#L87-L99

I'm assuming that the strategy cloud_build doesn't work in this case and the deployment one needs to be use instead.