Repository navigation
api/profiles: Change a profile in place - #142
Merged
Merged
Conversation
PATCH /v1/tenants/{t}/profiles/{name} changes the description, the CPU, the memory, the root disk, the secure boot and the SSH keys of a
profile a user made, with the checks of the creation. What is absent is left alone; s, m and l are refused.
What Incus cannot do in place is refused with a 409 and what to do, before anything is sent: a smaller disk while an instance has the
profile, less memory while an instance that has it is running, and a size that takes the tenant over its limits. A change never starts,
stops or restarts an instance.
Closes #135
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.
What
PATCH /v1/tenants/{t}/profiles/{name}changes a profile a user made, in place (the Profile kind and its composition already allow it):description,cpu,memoryMiB,diskGiB,secureBootandsshPublicKeys, with the bounds and the checks of the creation. What the body leaves out is left alone;s,mandlare403, an unknown profile404, an empty body422. The instances that have the profile follow the change, the ones that say their own value do not (phorge-fr/Hangar#434).description: ""goes back to the one made from the size,secureBoot: nullremoves the setting (so a profile that saidtrueorfalsecan go back to saying nothing),sshPublicKeys: []removes the keys. These three are removed from the object rather than written empty. A smallSetting[T]type tells an absent field from anull, which a pointer cannot.operatorandprofiles:write, as the creation. The API's service account already haspatchonprofiles.What Incus does, measured
On a throwaway tenant (
apitest-135-*, removed afterwards, Incus projects back to what they were), a profile used by a running VM, patched on the Profile object:nprocstays 1nproc1Reached maximum aggregate value "2" for "limits.cpu"Ready=Falsewith the raw error until put backBlock volumes cannot be shrunkSo three things are refused by the API with a
409and a sentence, before anything is sent:in_use, names the instances; make another profile and create the instances again with it);running; stop it, change the profile, start it again), the rule of an instance (Refuse to lower the memory of a running VM, and say what to do #119);quota_exceeded): every instance that has the profile counts what it comes to, so the bigger profile is checked against the 2 vCPU, 4 GiB and 128 GiB. Only what the change raises is checked.Open point. The memory refusal is not what this measurement shows: Incus accepted lowering the memory of a running VM through a profile, even below its boot value, where #119 measured
failed to resize memfdon an instance. I keep the rule of the instance (one rule for the memory of a running VM, whatever the path; a wrong refusal costs a stop, a wrong acceptance leaves an Instance in error) and say it here so it can be relaxed. Not measured: a disk lowered on a stopped VM (refused the same, conservatively).Tests
internal/compute:Settingtells absent,nulland a value; the validation of a patch.internal/kube: the merge patch writes only what was given and removes an emptied description, anullsecure boot and an empty list of keys.internal/api: what is changed and what is not, the settings, every refusal (profiles every tenant has, unknown, invalid, unknown field), the three409with the instances named, the limits of the tenant for one and for several instances, who may (roles and key scopes).gofmt -l,go vet ./...,go test -race ./...,yamllint --stricton the OpenAPI and the docs check pass locally.golangci-lintis not installed locally, CI runs it.The console side is phorge-fr/phorge-console#82.
Closes #135