Skip to content

Conversation

Hephi2
Copy link
Contributor

@Hephi2 Hephi2 commented Sep 24, 2025

Solves #547
- Adds fields in admin UI
- Sets HostConfig.Memory and HostConfig.NanoCPUs fields for Docker Socket Proxy
- Passes memory and nanoCPU values to HaRP Proxy (requires changes in HaRP repo)

Requires changes in HaRP to work. See nextcloud/HaRP#46

To validate the effect of the resource constraints run e.g. the following commands:

  • docker exec -it <container_id> bash
  • Testing the cpu constraint:
    • yes > /dev/null
    • You will observe with docker stats <container_id> that the container stays around the configured CPU cap
  • Testing the memory constraint:
  • E.g. python3 -c "a = ' ' * (1024 * 1024 * 1024); input()"
  • You will observe with docker stats <container_id> that the limit is equal to to set memory value and if the needed memory is too high, the process will be killed

@Hephi2 Hephi2 force-pushed the enh/resource-limits branch from 713abdd to f7c8735 Compare September 24, 2025 15:28
@Hephi2
Copy link
Contributor Author

Hephi2 commented Sep 25, 2025

Hey @kyteinsky @oleksandr-nc,
I'm not sure why the two tests are failing. I ran npm run build and there are no differences that need to be pushed.
Do you have any idea what might be causing this or what I could do?

@Hephi2 Hephi2 marked this pull request as ready for review September 26, 2025 06:38
@Hephi2 Hephi2 force-pushed the enh/resource-limits branch from 31bee10 to c78d2a3 Compare September 26, 2025 06:48
@oleksandr-nc
Copy link
Contributor

Hey @kyteinsky @oleksandr-nc, I'm not sure why the two tests are failing. I ran npm run build and there are no differences that need to be pushed. Do you have any idea what might be causing this or what I could do?

Hello! You can use /compile command to trigger the rebuild and push the assets by the bot to make CI happy

@oleksandr-nc
Copy link
Contributor

P.S.: But we usually do this after the PR is approved, before merging - the only exceptions are those PRs where the author is confident there won't be any changes to not remove commits of bots from git history.

The developers are building JS locally for review.

I will try to check this PR - is it ready for review or not?

@Hephi2
Copy link
Contributor Author

Hephi2 commented Sep 26, 2025

I see, that makes sense. Thank you.
Yes, it's ready for review.

@oleksandr-nc
Copy link
Contributor

@Hephi2 When I edit the daemon deploy page and fill the Memory limit and then start changing the CPU limit, the Memory limit gets reset.
Can this be fixed?

@oleksandr-nc
Copy link
Contributor

cpu-limit.mp4

@oleksandr-nc
Copy link
Contributor

Tests were performed on HaRP, results:

Without memory limit:

root@test-deploy:/ex_app/lib# python3 test_mem.py 
Requesting 16 GiB (17,179,869,184 bytes) allocation...
Allocation succeeded, touching pages to ensure commit...
Success. Touched 16 GiB in 3.24s (pid 2406)

Result: 🆗


With 8GB memory limit:

root@test-deploy:/ex_app/lib# python3 test_mem.py 
Requesting 16 GiB (17,179,869,184 bytes) allocation...
Killed
root@test-deploy:/ex_app/lib# python3 test_mem.py --gib=8
Requesting 8 GiB (8,589,934,592 bytes) allocation...
Allocation succeeded, touching pages to ensure commit...
Success. Touched 8 GiB in 16.22s (pid 2009)

Result: 🆗


Without CPU limit:

Screenshot From 2025-09-26 16-21-49

Result: 🆗


With CPU limit=4:

Screenshot From 2025-09-26 16-34-14

Result: 🆗


@Hephi2 Second question, if you don't mind, does docker-socket-proxy require modification to support this?

@Hephi2
Copy link
Contributor Author

Hephi2 commented Sep 26, 2025

@oleksandr-nc
That's strange, it works fine for me, I can't reproduce this problem.
Therefore, I can't really debug it. Perhaps you could tell me something about your configuration and the browser you are using, etc., then I might be able to reproduce it.
I can't really explain why this would happen either. Only if somehow the deployConfig object is replaced or something like that, but I don't know why this should be happening.

Regarding your second question: docker-socket-proxy does not need to be updated because, with this configuration, the Docker container is created in app_api, more specifically in lib/DeployActions/DockerActions.php.

@oleksandr-nc
Copy link
Contributor

Are you using Vue2 and not building this with Vue3?
Could you please create a new Deploy Daemon and try to reproduce it by repeating the steps in the video (when initial params are not defined for memory/cpu)?

@kyteinsky
Copy link
Collaborator

When I edit the daemon deploy page and fill the Memory limit and then start changing the CPU limit, the Memory limit gets reset.

I can't reproduce this. Which browser do you use and does any other browser have this issue too?

@kyteinsky
Copy link
Collaborator

kyteinsky commented Sep 29, 2025

@Hephi2 Also,
MB -> MiB (mebibyte)
GB -> GiB (gebibyte)

see https://www.corsair.com/us/en/explorer/diy-builder/storage/mebibyte-vs-megabyte-whats-the-difference/
in windows mebibytes (MiB) are incorrectly labelled as MB.

@oleksandr-nc
Copy link
Contributor

I can't reproduce this. Which browser do you use and does any other browser have this issue too?

Firefox. But reactivity in Vue2 should work the same among all browsers?

@oleksandr-nc
Copy link
Contributor

Description what happens on video:

On mount, when editing a daemon whose resourceLimits are empty/Unlimited, the code does not create the memoryMB/cpus keys (it only converts them if existing values are truthy). So the first time you type, those keys are added after creation (non‑reactively), and the next UI update (typing in CPU) causes the Memory input to re-render using the (still empty) computed getter, resetting the field.

@DaphneMuller
Copy link
Collaborator

@Hephi2 would you be up for giving it one more go to see if you can reproduce it with the additional hints?

@Hephi2
Copy link
Contributor Author

Hephi2 commented Sep 30, 2025

Yes, sure.
I didn't have time yesterday, but I planned to take a closer look at it today.

@kyteinsky
Copy link
Collaborator

When I edit the daemon deploy page and fill the Memory limit and then start changing the CPU limit, the Memory limit gets reset.
I can't reproduce this. Which browser do you use and does any other browser have this issue too?

So I was able to reproduce this issue. The steps were:

  1. create a deploy daemon with no resource limit set
  2. edit the daemon and add the cpu limit only
  3. save it
  4. edit the daemon and try to set the memory limit
  5. and then try to adjust the cpu limit

the fields should be empty now.

@Hephi2
Copy link
Contributor Author

Hephi2 commented Sep 30, 2025

On mount, when editing a daemon whose resourceLimits are empty/Unlimited, the code does not create the memoryMB/cpus keys (it only converts them if existing values are truthy). So the first time you type, those keys are added after creation (non‑reactively), and the next UI update (typing in CPU) causes the Memory input to re-render using the (still empty) computed getter, resetting the field.

Actually, this was covered if both were not set. However, in the edge case described by @kyteinsky, the corresponding other key was not initialised.
This should now be fixed. Please let me know if this is not the case.

@oleksandr-nc
Copy link
Contributor

With latest changes editing Deploy Config works fine for me. @kyteinsky can you check on your side as well?

@kyteinsky
Copy link
Collaborator

confirmed, that is fixed.

Copy link
Collaborator

@kyteinsky kyteinsky left a comment

Choose a reason for hiding this comment

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

🚀

@oleksandr-nc
Copy link
Contributor

/compile

@oleksandr-nc
Copy link
Contributor

@Hephi2 please squash three first commits and after that we can merge this

    - Adds fields in admin UI
    - Sets HostConfig.Memory and HostConfig.NanoCPUs fields for Docker Socket Proxy
    - Passes memory and nanoCPU values to HaRP Proxy (requires changes in HaRP repo)

Signed-off-by: Hephi2 <[email protected]>

Update built assets after source changes

Signed-off-by: Hephi2 <[email protected]>

Fixes resetting memory limit bug, MB -> MiB

Signed-off-by: Hephi2 <[email protected]>
@Hephi2 Hephi2 force-pushed the enh/resource-limits branch from 8c6c85d to 40ecdd0 Compare October 2, 2025 07:41
@oleksandr-nc
Copy link
Contributor

/compile

Signed-off-by: nextcloud-command <[email protected]>
@oleksandr-nc oleksandr-nc merged commit 2157e13 into main Oct 2, 2025
35 checks passed
@oleksandr-nc oleksandr-nc deleted the enh/resource-limits branch October 2, 2025 12:02
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.

5 participants