概要
GCPのCompute上でgitlab立てようとしたら,
途中でエラーが出たので.
今後gitlab立てない気もするが知見として書く.
インストール手順として
gitlab-ctl reconfigure
を行う必要があるのだが,エラーが発生した.
このコマンドは内部でchefが動いている.
chefの実行したbashでエラーを吐いている.
環境
この時点で察する人もいるかもしれない.
Google Cloud Platform f1-micro(vCPU x 1、メモリ 0.6 GB)
OS: Linux CentOS7.3
エラー全文
Railsでデータベースをマイグレートする際に,
正常終了するはずが[137]を返して異常終了いる.
137はkill -9(SIGKILL)されたときに返すらしい.
Recipe: gitlab::database_migrations
* bash[migrate gitlab-rails database] action run
================================================================================
Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '137'
---- Begin output of "bash" "/tmp/chef-script20170613-10673-15jo1yq" ----
STDOUT:
STDERR:
---- End output of "bash" "/tmp/chef-script20170613-10673-15jo1yq" ----
Ran "bash" "/tmp/chef-script20170613-10673-15jo1yq" returned 137
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb
51: bash "migrate gitlab-rails database" do
52: code <<-EOH
53: set -e
54: log_file="#{node['gitlab']['gitlab-rails']['log_directory']}/gitlab-rails-db-migrate-$(date +%Y-%m-%d-
55: umask 077
56: /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}
57: STATUS=${PIPESTATUS[0]}
58: echo $STATUS > #{db_migrate_status_file}
59: exit $STATUS
60: EOH
61: environment env_variables unless env_variables.empty?
62: notifies :run, 'execute[enable pg_trgm extension]', :before if omnibus_helper.service_enabled?('postgres
63: notifies :run, "execute[clear the gitlab-rails cache]", :immediately
64: dependent_services.each do |svc|
65: notifies :restart, svc, :immediately
66: end
67: not_if "(test -f #{db_migrate_status_file}) && (cat #{db_migrate_status_file} | grep -Fx 0)"
68: only_if { node['gitlab']['gitlab-rails']['auto_migrate'] }
69: end
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb:51:in `from_
bash("migrate gitlab-rails database") do
action [:run]
updated true
retries 0
retry_delay 2
default_guard_interpreter :default
command "migrate gitlab-rails database"
backup 5
returns 0
code " set -e\n log_file=\"/var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-tlab:db:configure 2>& 1 | tee ${log_file}\n STATUS=${PIPESTATUS[0]}\n echo $STATUS > /var/opt/gitlab/gitlab-r803-915a0aa\n exit $STATUS\n"
interpreter "bash"
declared_type :bash
cookbook_name "gitlab"
recipe_name "database_migrations"
not_if "(test -f /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-915amigrate-873248b1f0d3a7a5535771a3a1635803-915a0aa | grep -Fx 0)"
only_if { #code block }
end
Platform:
---------
x86_64-linux
原因
137はkill -9(SIGKILL)されたときに返すらしい.
/var/log/messagesを見たところ,
Jun 13 **:**:** [hostname] kernel: Out of memory: Kill process 12897 (bundle) score 321 or sacrifice child
Jun 13 **:**:** [hostname] kernel: Killed process 12897 (bundle) total-vm:496584kB, anon-rss:193164kB, file-rss:0kB, shmem-rss:0kB
メモリがない……
解決
仮想メモリをファイルから作ってなんとかなった.
dd if=/dev/zero of=/swap bs=1M count=1024
mkswap /swap
swapon /swap
知見
- メモリサイズが足りなくてエラーになるのは,よく見る.
- ビルドやマイグレートのときは疑う.
- シェルのリターンから原因を推測できる.
- 137はkill -9で終了
- kill -9は/var/log/messagesを見れば原因がわかるかも.
- 今回は Out of memory