Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add execution history for worker #98

Merged
merged 5 commits into from
Mar 7, 2018

Conversation

takonomura
Copy link
Contributor

Add pages to show execution history for worker. You can check executed jobs at specific time.

Worker Logs page

worker_logs_page

Worker Logs Timeline page

worker_timeline_page

@ganmacs
Copy link
Contributor

ganmacs commented Jan 26, 2018

@cookpad/dev-infra Review please.

@@ -0,0 +1,44 @@
class Kuroko2::WorkerLogsController < Kuroko2::ApplicationController
def index
@logs = Kuroko2::WorkerLog.ordered.includes(:job_definition, :job_instance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to good to use local variable and not to reassign a value to same variable (to be immutable ).

end

def dataset
@logs = Kuroko2::WorkerLog.ordered.includes(:job_definition, :job_instance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

private

def set_period
@end_at = begin params[:end_at].to_datetime rescue Time.current end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify which error to rescue.

def set_period
@end_at = begin params[:end_at].to_datetime rescue Time.current end

@start_at = begin params[:start_at].to_datetime rescue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ditto) please specify error type

class CreateWorkerLogs < ActiveRecord::Migration[5.0]
def change
create_table :worker_logs do |t|
t.string :hostname, limit: 180, null: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it need to add index to hostname column?


expect(assigns(:logs)).to match_array logs
expect(assigns(:end_at)).not_to be_nil
expect(assigns(:start_at)).to eq assigns(:end_at) - 1.hour
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nits]
I think following code is more unambiguous than this code.

expect(assigns(:start_at)).to eq(assigns(:end_at) - 1.hour) 

end
end

context 'with end_at' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the spec representing if invalid time as end_at and start_at is given.

@ganmacs
Copy link
Contributor

ganmacs commented Jan 29, 2018

I'm sorry to be late for reviewing 🙇

@takonomura
Copy link
Contributor Author

@ganmacs Thanks, I fixed reviewed changes.

@@ -50,13 +50,24 @@ def invoke(execution)
command = execution.shell
env = execution.context.fetch('ENV', {})

worker_log = Kuroko2::WorkerLog.create(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry that a lot of records are made.
You should add a script that cleaning old records like https://github.com/cookpad/kuroko2/blob/b21749d9e9e65211db8656b5fd719e0ec2c601d8/bin/cleanup_old_instances.rb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it in 7cd2bbd.

@eisuke eisuke merged commit 8fc19cf into cookpad:master Mar 7, 2018
@takonomura takonomura deleted the feature/worker-logs branch April 13, 2018 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants