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 logical processors to custom field #271

Merged
merged 5 commits into from
Jul 10, 2024

Conversation

justinbarclay
Copy link
Member

@justinbarclay justinbarclay commented Jul 4, 2024

Note that we still need to test and validate that this will run correctly in vms

@justinbarclay justinbarclay force-pushed the jb/split-count-and-threads branch from b8fe02e to 6391fb5 Compare July 4, 2024 20:59
@@ -222,6 +221,9 @@ def v2_runner_on_ok(self, result):
"storage_allocated_gb": storage_allocated_gb(facts),
"storage_used_gb": storage_used_gb(facts),
"cpu_count": cpu_count(facts),
"custom_fields": {
"CPU_LogicalProcessors": cpu_logical_processors(facts)
Copy link
Contributor

@SamDesmondKing SamDesmondKing Jul 9, 2024

Choose a reason for hiding this comment

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

Aside: how would you feel about making this a default server field?

Copy link
Contributor

@SamDesmondKing SamDesmondKing left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look at this Justin, I think it's really important that our discovery tools have a unified approach to the data we're collecting.

I've done some testing on this today and it seems like there are still a few kinks to work out.

Firstly, in MS4W cpu_count refers to physical cores, where as in MS4U it appears to refer to CPU sockets. Which one is the intention here?

Also, in my testing I found that MS4W is incorrectly counting logical cores on the m5d.metal instance. It's actually counting physical cores. What's strange is that for a VM t3.2xlarge it's correctly counting logical and physical cores. This could be a quirk of the metal instance but AWS and the machine itself seems to think it has 96 logical cores rather than the reported 48.

As I mentioned in the comments, for MS4U I've added a commit to append to the custom field key rather that overwriting it, feel free to use at your discretion.

I also have a Q about nomenclature, and whether we want to codify cpu_logical_processors as a first-class server attribute rather than a custom field.

@@ -222,6 +221,9 @@ def v2_runner_on_ok(self, result):
"storage_allocated_gb": storage_allocated_gb(facts),
"storage_used_gb": storage_used_gb(facts),
"cpu_count": cpu_count(facts),
"custom_fields": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not able to get this result in my testing, I believe this custom_fields key/value is being overwritten here.

Copy link
Contributor

Choose a reason for hiding this comment

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

The core of the issue was actually here - the update_results function was just replacing the entire custom_fields key in the result hash. Since CPU stats are taken last, they were overwriting the custom field added here. I've taken the liberty of pushing up a commit to this branch which fixes it - feel free to use or revert at your discretion if you don't agree with the approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's weird; thanks for the deep dive into this.

@@ -167,7 +167,8 @@ $ServerStats = {
CPU_Description = $cpu.Description
CPU_Manufacturer = $cpu.Manufacturer
CPU_L2CacheSize = $cpu.L2CacheSize
CPU_L3CacheSize = $cpu.L3CacheSize
CPU_L3CacheSize = $cpu.L3CacheSize
CPU_LogicalProcessors = $cpu.NumberOfLogicalProcessors
Copy link
Contributor

@SamDesmondKing SamDesmondKing Jul 9, 2024

Choose a reason for hiding this comment

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

Nit: the naming convention CPU_LogicalProcessors feels fine here but out of place in the MS4U python and in our app. I think it should be cpu_logical_processors.

There's precedent for this as MS4W already returns the custom fields that we actually use in our rails naming convention:

image

Copy link
Member Author

Choose a reason for hiding this comment

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

As we discussed, I was just following the naming conventions I established, but I agree. We should normalize on snake_case

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@justinbarclay justinbarclay merged commit 6ad4d40 into master Jul 10, 2024
2 checks passed
@justinbarclay justinbarclay deleted the jb/split-count-and-threads branch July 10, 2024 17:47
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.

2 participants