Recover userservices_limit on IPMachinesService from its server group - #185
Open
janpenitent wants to merge 1 commit into
Open
Recover userservices_limit on IPMachinesService from its server group#185janpenitent wants to merge 1 commit into
janpenitent wants to merge 1 commit into
Conversation
Since the migration of Physical Machines to server groups as backend, the
service stopped reporting its userservices_limit, so it was inherited as
UNLIMITED from the base Service class.
As a consequence, pools of this service with "Maximum number of services"
set to 0 got an unlimited usage info, and the {use}/{usec}/{left}/{total}
macros of pools and metapools were replaced by an empty string (metapools)
or by 0/0%/-1 (pools).
Now the limit is recovered on unmarshal from the servers of the server
group, as it was done before the migration. Machines on maintenance are
also counted, because the limit is the number of registered machines.
janpenitent
force-pushed
the
fix-ipmachines-userservices-limit
branch
from
July 31, 2026 11:50
3cbe55f to
4b1aaf2
Compare
dkmstr
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Short-name macros
{usec}/{use}/{left}render empty on metapools (and as garbage0/0%/-1on standalone pools) for any pool backed by a Static Multiple IP service.Reported by a customer on 4.0.0 build 20260630, but it affects every installation since
d84e5ac38.Cause
d84e5ac38("Heavy redone of Physical Machines using server groups as backend") dropped theuserservices_limitcalculation fromIPMachinesServiceand never reimplemented it over the new data source. The class now inherits the base default,consts.UNLIMITED(-1).That value is not only cosmetic:
ServicePool.get_max()falls back toservice.get_instance().userservices_limitwhenevermax_srvs == 0.max_srvsis always 0:IPMachinesService.uses_cache = False, so the pool-save handler zeroesinitial_srvs,cache_l1_srvs,cache_l2_srvsandmax_srvsno matter what the admin types.UNLIMITEDsince the regression. These pools currently have no effective cap at all, and there is no configuration workaround.UsageInfoVarsblanks all four macros whentotal <= 0, hence the empty macros. The standalone-pool path inuds/web/util/services.pysubstitutes raw, hence the-1leaking to the UI.Fix
Declare
userservices_limit_field()onIPMachinesService, counting the servers of its server group.Service.unmarshal()already resolves this member (int /NumericField/ callable), including thetry/exceptfallback and the negative clamp — same mechanismOpenGnsysServiceuses.Machines in maintenance are counted: the limit is the number of registered machines, not the currently usable ones. Counting only non-maintenance ones would let putting a machine into maintenance lower the pool max below what is already assigned. That is why
enumerate_servers()(which filtersmaintenance_mode=False) is not reused.5 added lines, no new imports, no migrations, no GUI/API/serialization changes.
Tests
TestServiceMulti.test_userservices_limit— marshal/unmarshal roundtrip plus the maintenance-mode case.Heads-up before merging
Restoring the cap is the correct pre-
d84e5ac38behaviour, but any installation currently holding more liveUserServices than registered machines will start gettingMaxServicesReachedError, and the admin cannot raise the limit becausemax_srvsis forced to 0. Worth a release note.Two separate GUI nits found while tracing this, deliberately not touched here:
max_srvsas "Max services per user" when it is the pool-wide maximum (4.0 has the correct wording).uses_cache = False, even though all four fields are always saved as 0.