-
Notifications
You must be signed in to change notification settings - Fork 72
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
Notify when back to normal #93
Notify when back to normal #93
Conversation
@cookpad/dev-infra review please |
@@ -73,7 +73,7 @@ def notify_critical | |||
end | |||
|
|||
def notify_finished | |||
if @definition.hipchat_notify_finished? | |||
if @definition.hipchat_notify_finished? || @instance.notify_back_to_normal? | |||
message = build_message(level: 'SUCCESS', text: message_builder.finished_text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it would be better to change message text.
@@ -80,7 +80,7 @@ def notify_critical | |||
end | |||
|
|||
def notify_finished | |||
if @definition.hipchat_notify_finished? | |||
if @definition.hipchat_notify_finished? || @instance.notify_back_to_normal? | |||
send_attachment_message_to_slack( | |||
level: 'SUCCESS', | |||
text: message_builder.finished_text, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ditto) I think that it would be better to change message text.
@@ -0,0 +1,6 @@ | |||
class AddNotifyBackToNormal < ActiveRecord::Migration[5.1] | |||
def change | |||
add_column :job_definitions, :notify_back_to_normal, :boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding after: :notify_cancellation
?
@@ -25,7 +25,7 @@ def retry(token) | |||
node = extract_node(token) | |||
|
|||
message = "(token #{token.uuid}) Retry current node: '#{node.type}: #{node.option}'" | |||
token.job_instance.update_column(:error_at, nil) | |||
token.job_instance.update_columns(error_at: nil, retrying: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If some tasks exists,
eg.
my_runner: first_task
my_runner: second_task
- a first task has an error.
- a first task retried and finished successfully.
- Notified
back to normal
- a second task finished successfully
- Notified
back to normal
The No.5 notification is not necessary.
Further, the fork
task and parallel_fork
task are more complicated. It will not work we want with this implementation.
https://github.com/cookpad/kuroko2/blob/master/docs/tasks.md#fork
https://github.com/cookpad/kuroko2/blob/master/docs/tasks.md#parallel_fork
I think that it is better to set retrying status in tokens.context
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I fixed it in c5246f2.
db9d444
to
c5246f2
Compare
@@ -119,6 +120,7 @@ def process_next(node, token) | |||
token.mark_as_finished | |||
unless token.parent | |||
token.job_instance.touch(:finished_at) | |||
Notifier.notify(:back_to_normal, token.job_instance) if token.context['RETRYING'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need deleting the RETRYING
context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
token
will be destroyed at line 125. So I decided there was no need to delete the RETRYING
context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right (I forgot). That seems to be OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh..., execuse me.
https://github.com/cookpad/kuroko2/pull/93/files#diff-f7b019ffd787516ae6ba13584edcd76dR121
It is necessary to put it outside the above conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -119,6 +120,7 @@ def process_next(node, token) | |||
token.mark_as_finished | |||
unless token.parent | |||
token.job_instance.touch(:finished_at) | |||
Notifier.notify(:back_to_normal, token.job_instance) if token.context['RETRYING'] | |||
Notifier.notify(:finished, token.job_instance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When retried, should "finished" notification be sent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is necessary for when the job has enabled Notify all event to Slack/Hipchat/Webhook
and disabled Notify when back to normal
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending both "back to normal" and "finish" notification with checking" notification is duplicated when the job is enabled both "Notify all event to Slack/Hipchat/Webhook" and " Notify when back to normal", isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I understand. I fixed it in 370977b.
@@ -20,6 +20,10 @@ def launched_text | |||
"Launched '#{@definition.name}'" | |||
end | |||
|
|||
def back_to_normal_text | |||
"Back to normal the current task in '#{@definition.name}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The task in '#{@definition.name}' was successfully retried" is easier to understand I think.
@@ -119,6 +120,7 @@ def process_next(node, token) | |||
token.mark_as_finished | |||
unless token.parent | |||
token.job_instance.touch(:finished_at) | |||
Notifier.notify(:back_to_normal, token.job_instance) if token.context['RETRYING'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh..., execuse me.
https://github.com/cookpad/kuroko2/pull/93/files#diff-f7b019ffd787516ae6ba13584edcd76dR121
It is necessary to put it outside the above conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks 👍 |
Notify when retried job finished.