Capistrano error: Host does not exist / svn: Connection closed unexpectedly - ruby-on-rails

I'm running from a Windows Vista machine using:
The latest rails (as of Jan 2. 2010),
Capistrano 2.5.10,
Subversive plugin, and
TortoiseSVN
So far, I have:
created the remote repository,
created ssh keys, and
edited the TortoiseSVN config file.
(I'm not sure if I’ve left out anything.)
Here’s the error message I get when I try to deploy using Capistrano:
* executing `deploy:cold'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "svn info svn+ssh://mydomain.com/home/45454/data/svn/repository/ -rHEAD"
checking for svn... yes
Unable to open connection:
Host does not exist
svn: Connection closed unexpectedly
*** [deploy:update_code] rolling back
* executing "rm -rf /home/45454/containers/rails/wcn/releases/20091230175413; true"
servers: ["mydomain.com"]
[mydomain.com] executing command
command finished
C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/recipes/deploy/scm/subversion.rb:58:in `query_revision': tried to run `svn info svn+ssh://mydomain.com/home/45454/data/svn/repository/ -rHEAD' and got unexpected result "" (RuntimeError)
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/recipes/deploy/scm/base.rb:35:in `send'
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/recipes/deploy/scm/base.rb:35:in `method_missing'
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/recipes/deploy/scm/base.rb:63:in `local'
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/recipes/deploy/scm/base.rb:35:in `method_missing'
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/recipes/deploy.rb:38:in `load'
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/configuration/variables.rb:87:in `call'
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/configuration/variables.rb:87:in `fetch'
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/configuration/variables.rb:110:in `protect'
... 38 levels...
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/lib/capistrano/cli/execute.rb:14:in `execute'
from C:/Ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.10/bin/cap:4
from C:/Ruby/bin/cap:19:in `load'
from C:/Ruby/bin/cap:19
Any ideas on what I should try next?

Looks like when svn goes to checkout the code it can't either resolve the hostname as defined by :repository or it can't ssh into "mydomain.com".
executing locally: "svn info svn+ssh://mydomain.com/home/45454/data/svn/repository/ -rHEAD"
checking for svn... yes
Unable to open connection:
Host does not existsvn: Connection closed unexpectedly
If you're deploying to your own Windows machine, try just using a local svn reference.

Related

After restarting the server instance, Capistrano throws the error that Authentication failed for user Net::SSH::AuthenticationFailed

It is our maintenance project. We have got the private key(id_rsa.txt) of production server to sign-in from the client.
If we want to deploy the application, we just add the private key file to my local ssh-agent
ssh-add id_rsa.txt
then follow the capistrano's deployment command and got success
bundle exec cap deploy
Here is the line for ssh in Deploy.rb:
server 'example.com', user: 'app', roles: %w[app db web sidekiq]
set :ssh_options, { forward_agent: true, user: "app", keys: %w(/home/user/id_rsa.txt) }
Problem: Everything was fine before the instance restarted via aws's web console. After, we are unable to deploy and getting an error as
home/rubx/.rvm/gems/ruby-2.7.2#glamz-web/gems/net-ssh-6.1.0/lib/net/ssh.rb:268:in `start': Authentication failed for user user#example.com (Net::SSH::AuthenticationFailed)
1: from /home/rubx/.rvm/gems/ruby-2.7.2#glamz-web/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/home/rubx/.rvm/gems/ruby-2.7.2#glamz-web/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as app#52.58.220.92: Authentication failed for user user#example.com (SSHKit::Runner::ExecuteError)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as user#example.com: Authentication failed for user user#example.com
/home/rubx/.rvm/gems/ruby-2.7.2#glamz-web/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/home/rubx/.rvm/gems/ruby-2.7.2#glamz-web/gems/sshkit-1.21.2/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
Caused by:
Net::SSH::AuthenticationFailed: Authentication failed for user user#example.com
After some googling, I tried the following steps but did not succeed.
Added my public key(.ssh/id_rsa.pub) to authorized_keys of target server
Allowing my IP address to the inbound rule of server.
Tried to put only the server key in my ssh-agent.
Note: We can successfully login to server using the same key file
Do I need to configure the server specifically for Capistrano deployment?
Thanks in advance
We were trying syslog(/var/log/syslog) for the log messages and then some googling came to know about the /var/log/auth.log.
The following error messages were found on auth.log while establishing a server connection via the script
Jun 11 05:01:36 ip- sshd[1757827]: userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
Jun 11 05:01:36 ip- sshd[1757827]: Connection closed by authenticating user app 15.4.81.22 port 47652 [preauth]
Solution
The problem was solved after allowing the ssh-rsa algorithm to PubkeyAcceptedKeyTypes in the sshd configuration
sudo vi /etc/ssh/sshd_config
PubkeyAcceptedKeyTypes=+ssh-rsa
Restart the sshd to reflect the changes
sudo systemctl restart sshd
Reference

Gitlab upgrade issue in Docker

I am trying to upgrade my Gitlab CE which is running in Docker container. I am upgrading from version 11.9.1 to 14.2.1. I am also following the required upgrade path from official Gitlab documentation which is:
11.9.1->11.11.8->12.0.12->12.1.17->12.10.14->13.0.4->13.1.11->13.8.8->13.12.9->14.0.7->14.2.1
The last version that works is 14.0.7, I am also able to run latest 14.1.x version, but during migration to 14.2.x the following error appears, some migrations does not work.
There was an error running gitlab-ctl reconfigure:
rails_migration[gitlab-rails] (gitlab::database_migrations line 51) had an error: Mixlib::ShellOut::ShellCommandFailed: bash[migrate gitlab-rails database] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/rails_migration.rb line 16) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash" "/tmp/chef-script20210903-28-4vm0c2" ----
STDOUT: rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Expected batched background migration for the given configuration to be marked as 'finished', but it is 'active': {:job_class_name=>"CopyColumnUsingBackgroundMigrationJob", :table_name=>"ci_job_artifacts", :column_name=>"id", :job_arguments=>[["id", "job_id"], ["id_convert_to_bigint", "job_id_convert_to_bigint"]]}
Finalize it manualy by running
sudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,ci_job_artifacts,id,'[["id"\, "job_id"]\, ["id_convert_to_bigint"\, "job_id_convert_to_bigint"]]']
For more information, check the documentation
https://docs.gitlab.com/ee/user/admin_area/monitoring/background_migrations.html#database-migrations-failing-because-of-batched-background-migration-not-finished
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:1129:in `ensure_batched_background_migration_is_finished'
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20210706212710_finalize_ci_job_artifacts_bigint_conversion.rb:14:in `up'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:61:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Caused by:
Expected batched background migration for the given configuration to be marked as 'finished', but it is 'active': {:job_class_name=>"CopyColumnUsingBackgroundMigrationJob", :table_name=>"ci_job_artifacts", :column_name=>"id", :job_arguments=>[["id", "job_id"], ["id_convert_to_bigint", "job_id_convert_to_bigint"]]}
Finalize it manualy by running
sudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,ci_job_artifacts,id,'[["id"\, "job_id"]\, ["id_convert_to_bigint"\, "job_id_convert_to_bigint"]]']
For more information, check the documentation
https://docs.gitlab.com/ee/user/admin_area/monitoring/background_migrations.html#database-migrations-failing-because-of-batched-background-migration-not-finished
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:1129:in `ensure_batched_background_migration_is_finished'
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20210706212710_finalize_ci_job_artifacts_bigint_conversion.rb:14:in `up'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:61:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
== 20210706212710 FinalizeCiJobArtifactsBigintConversion: migrating ===========
STDERR:
---- End output of "bash" "/tmp/chef-script20210903-28-4vm0c2" ----
Ran "bash" "/tmp/chef-script20210903-28-4vm0c2" returned 1
Running handlers:
Running handlers complete
Chef Infra Client failed. 11 resources updated in 16 seconds
Thank you for using GitLab Docker Image!
Current version: gitlab-ce=14.2.0-ce.0
Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:
docker exec -it gitlab editor /etc/gitlab/gitlab.rb
docker restart gitlab
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
If this container fails to start due to permission problems try to fix it by executing:
docker exec -it gitlab update-permissions
docker restart gitlab
Cleaning stale PIDs & sockets
Preparing services...
Starting services...
Configuring GitLab...
/opt/gitlab/embedded/bin/runsvdir-start: line 24: ulimit: pending signals: cannot modify limit: Operation not permitted
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
I have tried executing migrations by hand and all other fixes that logs propose, but none of them worked.
I use Ubuntu 20.04 LTS and Docker version 20.10.7, build 20.10.7-0ubuntu1~20.04.1
Ok, turned out that I had to update to 14.0.5 firstly and wait for some background migration to complete (you can see them in menu->admin->monitoring->background migrations).

Discourse server fails to start with errors related to redis

Rails server fails to start in Discourse project either in development or production. Below are the logs when trying to start the server in dev mode. The application was installed and has been working, It's deployed on AWS in production mode and restarting the unicorn loads the application for some time and again the url stops responding with error messages.
Development logs from $rails s
rb t#ip-XXX-XX-XX-XX-app:/var/www/discourse# vi
config/environments/development.r
root#ip-172-31-25-46-app:/var/www/discourse# rails s
=> Booting Puma
=> Rails 5.1.4 application starting in production
=> Run `rails server -h` for more startup options
Exiting
bundler: failed to load command: script/rails (script/rails)
Redis::CommandError: ERR Error running script (call to f_b06356ba4628144e123b652c99605b873107c9be): #user_script:14: #user_script: 14: -MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis/client.rb:121:in `call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:2399:in `block in _eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:58:in `block in synchronize'
/usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:58:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:2398:in `_eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:2450:in `evalsha'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.1/lib/message_bus/backends/redis.rb:380:in `cached_eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.1/lib/message_bus/backends/redis.rb:140:in `publish'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.1/lib/message_bus.rb:248:in `publish'
/var/www/discourse/lib/distributed_cache.rb:72:in `publish'
**Production logs **
/var/www/discourse/lib/demon/base.rb:109:in `ensure_running'
/var/www/discourse/lib/demon/base.rb:34:in `block in ensure_running'
/var/www/discourse/lib/demon/base.rb:33:in `each'
/var/www/discourse/lib/demon/base.rb:33:in `ensure_running'
config/unicorn.conf.rb:145:in `master_sleep'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:284:in `join'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/bin/unicorn:126:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.3.0/bin/unicorn:23:in `load'
/var/www/discourse/vendor/bundle/ruby/2.3.0/bin/unicorn:23:in `<main>'
E, [2018-01-04T08:43:37.949928 #60] ERROR -- : reaped #<Process::Status: pid 5870 exit 1> worker=unknown
Detected dead worker 5870, restarting...
Loading Sidekiq in process id 5883
Failed to report error: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. 4 Redis::CommandError (MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.)
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.0/lib/redis/client.rb:121:in `call' web-exception
Redis logs
47:M 17 Jan 09:38:01.070 # Can't save in background: fork: Cannot allocate memory
47:M 17 Jan 09:38:07.087 * 10000 changes in 60 seconds. Saving...
The issue has been fixed, Edited this file
/etc/sysctl.conf and added the line at last
vm.overcommit_memory=1
After this restarted sysctl.
$ sudo sysctl -p /etc/sysctl.conf
Redis doesn't need the amount of memory which OS thinks, the status 1 means always overcommit, never check.
More details can be found from Redis Docs.

Deploying rails app to Amazon Ec2 instance using rubber(free-tier)

I am trying to upload my rails app to free-tier ec2 instance using rubber gem. Using railcast video and following this tutorial
https://liggat.org/a-full-AWS-rails-stack-provision-and-deployment-with-the-rubber-gem/
Using cap rubber:create, I am able to create ec2 instance, but it does not get connected. I get the following error:
** Failed to connect to xx.xxx.xxx.xx, retrying
* 2017-10-31 19:10:56 executing `rubber:_ensure_key_file_present'
servers: ["xx.xxx.xxx.xx"]
/Users/somnathdas/.rvm/gems/ruby-2.4.0/gems/net-ssh-2.9.4/lib/net/ssh.rb:197: warning: constant ::Fixnum is deprecated
/Users/somnathdas/.rvm/gems/ruby-2.4.0/gems/net-ssh-2.9.4/lib/net/ssh/transport/session.rb:67:in `initialize': Object#timeout is deprecated, use Timeout.timeout instead.
/Users/somnathdas/.rvm/gems/ruby-2.4.0/gems/net-ssh-2.9.4/lib/net/ssh/transport/session.rb:84:in `initialize': Object#timeout is deprecated, use Timeout.timeout instead.
./Users/somnathdas/.rvm/gems/ruby-2.4.0/gems/net-ssh-2.9.4/lib/net/ssh/transport/cipher_factory.rb:98: warning: constant OpenSSL::Cipher::Cipher is deprecated
. ** Failed to connect to xx.xxx.xxx.xx, retrying
* 2017-10-31 19:10:59 executing `rubber:_ensure_key_file_present'
Also rubber does not update /etc/hosts file. But interestingly when I ssh into remote instance through
ssh -v -i ~/.ec2/gsg-keypair ubuntu#ec2-xx.xxx.xxx.xx.us-west-2.compute.amazonaws.com
it gets connected. Also, cap rubber:bootstrap fails after this, giving this error
* 2017-10-31 19:13:17 executing `rubber:bootstrap'
triggering before callbacks for `rubber:bootstrap'
* 2017-10-31 19:13:17 executing `rubber:base:update_sudoers'
servers: ["production.xxxxx.io"]
/Users/somnathdas/.rvm/gems/ruby-2.4.0/gems/net-ssh-2.9.4/lib/net/ssh.rb:197: warning: constant ::Fixnum is deprecated
/Users/somnathdas/.rvm/gems/ruby-2.4.0/gems/net-ssh-2.9.4/lib/net/ssh/transport/session.rb:67:in `initialize': Object#timeout is deprecated, use Timeout.timeout instead.
connection failed for: production.xxxx.io (SocketError: getaddrinfo: nodename nor servname provided, or not known)
I am stuck on this for 5 days. if some kind soul can help, I would really be obliged.

Booting up Vagrant from Jenkins throws Permission Denied

I am trying to Boot up Vagrant VM from Jenkins. I gave Vagrantfile path in 'Boot up Vagrant VM'.
When the job runs, I get the following error:
Failed to iterate on remote directory vagrant_projs
[ vagrant ]: Executing command :[vagrant, up] in folder /Users/abc/Desktop/vagrant_projs
[vagrant_projs] $ vagrant up
[ vagrant ]: Error starting up vagrant, caught IOException, message: Cannot run program "vagrant" (in directory "/Users/abc/Desktop/vagrant_projs"): error=13, Permission denied
[ vagrant ]: [Ljava.lang.StackTraceElement;#5e144dc9
Build step 'Boot up Vagrant VM' marked build as failure
Finished: FAILURE
I thought it might be because of permissions of Vagrantfile and thus I have chmod 777 to it manually. Even after that it gives me the same error.
UPDATE:
I moved the folder in which Vagrantfile resided from Desktop to user folder and I got different stacktrace.
[workspace] $ vagrant -v
Vagrant 1.7.2
[ vagrant ]: Executing command :[vagrant, up] in folder /Users/abalan15/vagrant_projs
[vagrant_projs] $ vagrant up
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:313:in `unlink': Permission denied - /Users/abalan15/vagrant_projs/.vagrant/machines/default/virtualbox/id (Errno::EACCES)
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:313:in `delete'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:313:in `id='
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:142:in `initialize'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/vagrantfile.rb:75:in `new'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/vagrantfile.rb:75:in `machine'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:614:in `machine'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:168:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:192:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:192:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:174:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:174:in `with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/up/command.rb:74:in `block in execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:277:in `block (2 levels) in batch'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:275:in `tap'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:275:in `block in batch'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:274:in `synchronize'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:274:in `batch'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/up/command.rb:58:in `execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/cli.rb:42:in `execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:301:in `cli'
from /opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.2/bin/vagrant:174:in `<main>'
Build step 'Boot up Vagrant VM' marked build as failure
Finished: FAILURE
At last!
When we try to invoke/boot Vagrant VM from Jenkins(with vagrant plugin), .vagrant.d & folder with vagrantfile will be invoked. Permission for the jenkins user should be given to these folders.
In mac, right click on these folders, get info, on the bottom(permissions), click the + symbol and add jenkins to the 'Users & Groups'
A few things to check when dealing with permission problems in Jenkins:
What user name is running the container (Tomcat) or the Jenkins native binary?
What user name is the jenkins process / jnlp / slave using (if this isn't on the master Jenkins node)

Resources