Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Fixed the crono job overflowing the log column
Browse files Browse the repository at this point in the history
Before this commit, the crono job kept on adding the log into the `log` column
from the `crono_jobs` table. This is, of course, a bad thing. What I did to fix
this is to simply remove this columns from the DB, and crono is ok with that.
Running crono again with this patch runs in the very same way as it used to be,
but without adding the log all the time.

Moreover, the log is supposed to go to the stdout, as envisioned by the
Twelve-Factor App manifesto: http://12factor.net. Docker follows this too, and
by doing so then the log of this job blends in with docker-compose logs
command. This has two main consequences:

1. The user can decide how to manage logs in an easier way, so there's no way
   that we run out of disk (an issue we were having).
2. supervisor is no longer needed. Instead, we take advantage of the
   compose-setup.sh script to do it properly. Before this patch, for some
   reason the catalog job did not reach the db container.

Fixes #479
Fixes #505

Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
  • Loading branch information
mssola authored and flavio committed Dec 21, 2015
1 parent 1daaf11 commit a0ed6d6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 16 deletions.
5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ MAINTAINER Flavio Castelli <fcastelli@suse.com>
ENV COMPOSE=1
EXPOSE 3000

# install supervisord, this is required to run cronos
RUN apt-get update && apt-get install -y supervisor
RUN ln -s /portus/docker/crono-supervisord.conf /etc/supervisor/conf.d/crono.conf

WORKDIR /portus
COPY Gemfile* ./
RUN bundle install --retry=3

ADD . .

4 changes: 4 additions & 0 deletions compose-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ docker-compose up -d

setup_database

# At this point, the DB is up and running. Therefore, at this point the crono
# container will certainly work.
docker-compose restart crono

# The cleaned up host. We do this because when the $DOCKER_HOST variable was
# already set, then it might come with the port included.
final_host=$(echo $DOCKER_HOST | grep -E -o '([0-9]{1,3}[\.]){3}[0-9]{1,3}' | head -1)
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20151215152138_remove_log_from_crono_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveLogFromCronoJob < ActiveRecord::Migration
def change
remove_column :crono_jobs, :log, :text
end
end
32 changes: 27 additions & 5 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20151029145958) do
ActiveRecord::Schema.define(version: 20151215152138) do

create_table "activities", force: :cascade do |t|
t.integer "trackable_id", limit: 4
Expand All @@ -31,13 +31,32 @@
add_index "activities", ["recipient_id", "recipient_type"], name: "index_activities_on_recipient_id_and_recipient_type", using: :btree
add_index "activities", ["trackable_id", "trackable_type"], name: "index_activities_on_trackable_id_and_trackable_type", using: :btree

create_table "application_tokens", force: :cascade do |t|
t.string "application", limit: 255, null: false
t.string "token_hash", limit: 255, null: false
t.string "token_salt", limit: 255, null: false
t.integer "user_id", limit: 4, null: false
end

add_index "application_tokens", ["user_id"], name: "index_application_tokens_on_user_id", using: :btree

create_table "comments", force: :cascade do |t|
t.text "body", limit: 65535
t.integer "repository_id", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id", limit: 4
end

add_index "comments", ["repository_id"], name: "index_comments_on_repository_id", using: :btree
add_index "comments", ["user_id"], name: "index_comments_on_user_id", using: :btree

create_table "crono_jobs", force: :cascade do |t|
t.string "job_id", limit: 255, null: false
t.text "log", limit: 65535
t.string "job_id", limit: 255, null: false
t.datetime "last_performed_at"
t.boolean "healthy", limit: 1
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

add_index "crono_jobs", ["job_id"], name: "index_crono_jobs_on_job_id", unique: true, using: :btree
Expand Down Expand Up @@ -74,6 +93,7 @@
t.integer "namespace_id", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "source_url", limit: 255, default: "", null: false
end

add_index "repositories", ["name", "namespace_id"], name: "index_repositories_on_name_and_namespace_id", unique: true, using: :btree
Expand All @@ -96,6 +116,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id", limit: 4
t.string "digest", limit: 255
end

add_index "tags", ["name", "repository_id"], name: "index_tags_on_name_and_repository_id", unique: true, using: :btree
Expand Down Expand Up @@ -149,6 +170,7 @@
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
add_index "users", ["username"], name: "index_users_on_username", unique: true, using: :btree

add_foreign_key "comments", "repositories"
add_foreign_key "stars", "repositories"
add_foreign_key "stars", "users"
end
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ web:

crono:
image: portus_web
command: /usr/bin/supervisord
entrypoint: bundle exec crono
volumes:
- .:/portus
links:
Expand Down
5 changes: 0 additions & 5 deletions docker/crono-supervisord.conf

This file was deleted.

0 comments on commit a0ed6d6

Please sign in to comment.