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

Log only unique servers id used to process miq_request #18962

Conversation

yrudman
Copy link
Contributor

@yrudman yrudman commented Jul 11, 2019

ISSUE:
In some situations miq_request may start re-queuing :
in log:
Screen Shot 2019-07-11 at 1 36 16 PM

FIX:
Log only unique servers id

this PR is follow-up to #17451

@miq-bot add-label core, hammer/yes, changelog/yes, technical debt

@yrudman
Copy link
Contributor Author

yrudman commented Jul 11, 2019

\cc @lfu @d-m-u

@d-m-u
Copy link
Contributor

d-m-u commented Jul 11, 2019

Honestly this had nothing to do with me at all and I don't know why I'm involved. But this looks better than it was.

def mark_execution_servers
options[:executed_on_servers] ||= []
options[:executed_on_servers] << MiqServer.my_server.id
options[:executed_on_servers].shift if options[:executed_on_servers].size > LOG_SERVERS_LIMIT
Copy link
Member

Choose a reason for hiding this comment

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

Is there value to keep the same server multiple times?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so but Lucy should answer this.

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 think order is important

Copy link
Member

Choose a reason for hiding this comment

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

This is from previous discussion: #17451 (comment).

If we want to record all the servers in the order the tasks have been executed and limit the array size, maybe we can do this:

 options[:executed_on_servers] << MiqServer.my_server.id unless options[:executed_on_servers].last == MiqServer.my_server.id

cc @gmcculloug

Copy link
Contributor Author

@yrudman yrudman Jul 12, 2019

Choose a reason for hiding this comment

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

@lfu good suggestion, but it may not help if there are more than one server which may process request.
We could either sacrifice order and collect unique entries or sacrifice full history and limit size, I am not sure how we can do both.
It is a corner case, I am not sure what is the correct solution here and what limit should be in case we will decide to limit array size

Copy link
Contributor Author

@yrudman yrudman Jul 12, 2019

Choose a reason for hiding this comment

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

I think order will be gone if we will use Set:
entry [1,2,1] will be [1,2] and last server will be shown as 2

Copy link
Member

Choose a reason for hiding this comment

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

I think order will be gone if we will use Set:
entry [1,2,1] will be [1,2]

Only if duplicates are have some value... I have no idea, so I'm just asking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

me too :) I am not sure what is correct solution here

Copy link
Member

Choose a reason for hiding this comment

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

Review the comments from @lfu on the thread she listed above #17451 (comment):

This array is to record the id of servers where the automate task has been processed. So all the logs from these servers would be collected in case of troubleshooting. The order of the ids in the array is not important in this case.

and

If a long array is not a concern, we can get rid of calling uniq

So uniq still gives us the ability to see all the places it ran, which was the main purpose, and if we go this way I would skip limiting the array for now so we know where to collect logs from. This is based on my assumption that most environments have a reasonable number of workers per-zone so the list would be contained by that. If you feel this is incorrect than we should limit it.

This is a bit crazy, but since I worked on it I thought I would include it for fun.
If we want to keep a little sense of order the following logic clears out the current server record from the list and then appends it to the end and ensures we only return the last LOG_SERVERS_LIMIT elements. Again, with removing dups we could probably drop this limit here as well.

def last_test_servers(server_list, server_id)
  ((server_list -= [server_id]) << server_id).last(LOG_SERVERS_LIMIT)
end

or without limits:

def last_test_servers(server_list, server_id)
  (server_list -= [server_id]) << server_id
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 It looks like good compromise

@yrudman yrudman force-pushed the limit-length-of-saved-servers-tracked-in-miq-request branch from f2b9f5a to c5354aa Compare July 15, 2019 11:49
@yrudman yrudman changed the title Log only 10 last servers used to process miq_request Log only unique servers id used to process miq_request Jul 15, 2019
@yrudman yrudman force-pushed the limit-length-of-saved-servers-tracked-in-miq-request branch from c5354aa to 98d7bfd Compare July 15, 2019 17:18
@miq-bot
Copy link
Member

miq-bot commented Jul 15, 2019

Checked commits yrudman/manageiq@98d7bfd~...b7e8fa3 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@jrafanie jrafanie merged commit e85255f into ManageIQ:master Jul 15, 2019
@jrafanie jrafanie self-assigned this Jul 15, 2019
@jrafanie jrafanie added this to the Sprint 116 Ending Jul 22, 2019 milestone Jul 15, 2019
@yrudman yrudman deleted the limit-length-of-saved-servers-tracked-in-miq-request branch July 16, 2019 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants