-
Notifications
You must be signed in to change notification settings - Fork 562
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
many: use changes + tasks for quota group operations #10420
many: use changes + tasks for quota group operations #10420
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did a pass, found a theoretical issue but I don't think it relates to the spread tests issues, as afaict systemd uses the meters for real only for Stop/Restart
144a978
to
763dd01
Compare
Unfortunately this is blocked now, after reviewing the spread test failures again, it seems that changes like those in 763dd01 are papering over a real issue. The issue is that we now have a task which gets marked done before it is done doing things. It is okay in the case where we get rebooted in the middle after unlocking the state and come back and re-execute the task, it will not break anything, but we now have race conditions in the following situation (which is what the spread test is doing):
There are a few ways we could solve this, but this is a bit of an unfortunate corner case. Options I can think of right now:
|
763dd01
to
cc3c683
Compare
This is now rebased on #10458 which should solve the issues we had with the spread tests. At this point the two last commits cancel each other, I have both to keep history but could also be dropped. |
The exported methods from the servicestate package all return tasksets now, which is expected to be put into changes that are executed by the overlord loop. This involves changes in many parts that use quotas, such as the tests, where a new mock function to create a quota group in state without running any servicectl commands as well as changes to the client side. Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
These checks are also race conditions too Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
if the quota-control tasks don't set themselves as done prematurely
cc3c683
to
b574b07
Compare
Conflict detection is implemented in #10471 based on this one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm but the new preconditions checks are not tested afaict
return nil, fmt.Errorf("group %q already exists", name) | ||
} | ||
|
||
if memoryLimit == 0 { | ||
return nil, fmt.Errorf("cannot create quota group with no memory limit set") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these new precond checks are not tested
// oom killer to be invoked when a new group is added as a sub-group to the | ||
// larger group. | ||
if memoryLimit <= 4*quantity.SizeKiB { | ||
return nil, fmt.Errorf("memory limit for group %q is too small: size must be larger than 4KB", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
// executing this directly | ||
// make sure the specified snaps exist and aren't currently in another group | ||
if err := validateSnapForAddingToGroup(st, snaps, name, allGrps); err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
return nil, fmt.Errorf("cannot remove non-existent quota group %q", name) | ||
} | ||
|
||
// XXX: remove this limitation eventually | ||
if len(grp.SubGroups) != 0 { | ||
return nil, fmt.Errorf("cannot remove quota group with sub-groups, remove the sub-groups first") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
// now ensure that all of the snaps mentioned in AddSnaps exist as snaps and | ||
// that they aren't already in an existing quota group | ||
if err := validateSnapForAddingToGroup(st, updateOpts.AddSnaps, name, allGrps); err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. One nitpick and a few test cases missing as pointed out by Samuele (and I think I found one more), but I'm fine if they are addressed in a followup not to block this PR (and also because it's already big).
// EnsureSnapServices, see comment in ensureSnapServicesForGroup for | ||
// full details | ||
if updateOpts.NewMemoryLimit < grp.MemoryLimit { | ||
return nil, fmt.Errorf("cannot decrease memory limit of existing quota-group, remove and re-create it to decrease the limit") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT this case isn't covered either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I now pushed tests that cover most of these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last commit adding extra tests looks good, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Pawel's suggestion, otherwise looks good to me, thanks for the additional tests and pre-req PR's that have already landed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually vote
The exported methods from the servicestate package all return tasksets now,
which is expected to be put into changes that are executed by the overlord
loop. This involves changes in many parts that use quotas, such as the tests,
where a new mock function to create a quota group in state without running any
servicectl commands as well as changes to the client side.