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

Move logic for event display message to task_runner #3476

Closed
wants to merge 14 commits into from

Conversation

preetapan
Copy link
Contributor

@preetapan preetapan commented Oct 31, 2017

Adds two new fields DisplayMessage and Details.

Needs some more unit test updates

This fixes #3399

@preetapan preetapan changed the title Move logic for determinic event display message to task_runner Move logic for event display message to task_runner Oct 31, 2017
Copy link
Member

@schmichael schmichael left a comment

Choose a reason for hiding this comment

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

Did you mean to commit the generated code?

@@ -73,6 +73,7 @@ const (
ACLTokenUpsertRequestType
ACLTokenDeleteRequestType
ACLTokenBootstrapRequestType
ReasonWithinPolicy = "Restart within policy"
Copy link
Member

Choose a reason for hiding this comment

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

This seems out of place... At least put a space between it and the "enum" above + a comment describing its intended purpose.


func (event *TaskEvent) PopulateEventDisplayMessage() {
// Build up the description based on the event type.
if event == nil { //TODO PA needs investigation alloc_runner's Run method sends a nil event when sigterming nomad. Why?
Copy link
Member

Choose a reason for hiding this comment

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

Hm, interesting. I don't see anywhere in here that taskDestroyEvent could still be nil by the time r.destroyTaskRunners(taskDestroyEvent) is called.

However I do feel like event being nil can intentionally happen (perhaps to cause a sync without changing the task's state?) -- I just can't find where now...

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 saw it only when shutting down, and it always consistently happened during shutdown. Haven't found the root cause yet..

Copy link
Member

Choose a reason for hiding this comment

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

Hm if it's dev mode we destroy/GC all allocations on shutdown, so Nomad would be breaking out of that OUTER loop in AllocRunner.Run and hitting the AllocRunner.handleDestroy() code path if that helps.

Time: time.Now().UnixNano(),
Type: event,
Time: time.Now().UnixNano(),
Details: make(map[string]string),
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a map of type -> details instead of just being a string containing the details? It doesn't seem like we'd ever have an event with multiple detail entries but maybe I'm missing something?

Copy link
Member

Choose a reason for hiding this comment

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

(If we want to keep this a map perhaps we should create a global static map of "Types -> String Keys" instead of hardcoding the strings below?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created this because we want to get rid of the many fields like ErrorReason/KillReason etc and there can be more than one entry for a single event (e.g kill_signal and kill_reason)

Copy link
Member

@schmichael schmichael Oct 31, 2017

Choose a reason for hiding this comment

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

(Oops, left a comment in the wrong place; editing)

Ah! Makes sense. I must have missed the descriptive comment on the field.

parts = append(parts, fmt.Sprintf("Exit Code: %d", event.ExitCode))
if event.DisplayMessage != "" {
formattedTime := formatUnixNanoTime(event.Time)
events[size-i] = fmt.Sprintf("%s|%s|%s", formattedTime, event.Type, event.DisplayMessage)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make a named variable

Details map[string]string
}

func (event *TaskEvent) PopulateEventDisplayMessage() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe have a couple basic tests for a sanity check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@preetapan
Copy link
Contributor Author

@schmichael yes I meant to commit generated code, I've added new fields to the API. This is needed until we make the workflow change we talked about.

@preetapan
Copy link
Contributor Author

Closing this one, will open a new one against master

@preetapan preetapan closed this Nov 2, 2017
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants