foreman icon indicating copy to clipboard operation
foreman copied to clipboard

Fixes #38303 - the host count depends on the organization

Open sbernhard opened this issue 9 months ago • 4 comments

If a user is in multiple organizations the host count which is displayed on different UI pages depends on the selected organization.

sbernhard avatar Mar 22 '25 14:03 sbernhard

Ready for final review.

sbernhard avatar Mar 24 '25 08:03 sbernhard

Essentially the issue is that if you go to that page as soon as you've added some hosts to a group, the counter will have the old value. Of course after 2 minutes and reloading the page it will be updated, but some might find this rather as a bug.

Then we can get rid of the cache. Its about displaying a host number - this shouldn't be mission critical :)

sbernhard avatar Apr 14 '25 16:04 sbernhard

Any opinions on cache removal/rewrite instead of patching it for one issue and leaving the other?

We will need to dig deep into the history to understand why it's there i the first place. From the first look, it's a 7 years old issue: https://projects.theforeman.org/issues/24783. I wonder how to test the performance degradation if we are to remove the cache altogether.

ShimShtein avatar Apr 15 '25 15:04 ShimShtein

I wonder how to test the performance degradation if we are to remove the cache altogether.

I don't think that someone would recognize any performance change if we drop the cache. I can run some speed tests next week.

sbernhard avatar Apr 23 '25 09:04 sbernhard

Any opinions on cache removal/rewrite instead of patching it for one issue and leaving the other?

We will need to dig deep into the history to understand why it's there i the first place. From the first look, it's a 7 years old issue: https://projects.theforeman.org/issues/24783. I wonder how to test the performance degradation if we are to remove the cache altogether.

After weeks.... I'm sorry.

I have tested it. For 53 Hostgroups it takes with cache about 0.012829598 seconds and without 0.195574074 seconds So, I think it's worth to have this cache.

Actually, to get the host count for the host groups, it would run the same sql query 53 times: SELECT "hosts".* FROM "hosts" WHERE "hosts"."type" = 'Host::Managed' AND "hosts"."organization_id" = 1 AND "hosts"."location_id" = 2 GROUP BY "hosts"."hostgroup_id

Afterwards, it selects the count of the hosts object per hostgroup_id. I think, this is pretty okish.

Now that I'm thinking out loud I'd say that my proposal also has it's drawbacks: key-values are being flooded into cache store without any removal :/

=> as described above, this is not the case. It would also be OK, to reduce the cache time from 2 minutes to 1 minute or even 30 seconds. If then, the count changes -> I think nobody would recognize it.

sbernhard avatar Jul 25 '25 16:07 sbernhard

Any feedback on this change @ShimShtein ?

sbernhard avatar Aug 19 '25 21:08 sbernhard

Looks good, let's merge it and see if we get some fallout. It definitely improves the original behavior

ShimShtein avatar Aug 27 '25 08:08 ShimShtein