Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Sep 25, 2020

Cast swapFree to integer to fix typeerror.

Fix total memory to use hw.realmem

Cast swapFree to integer to fix typeerror.

Fix total memory to use hw.realmem

Signed-off-by: Matthew Wener <[email protected]>
Signed-off-by: Matthew Wener <[email protected]>
@kesselb
Copy link
Collaborator

kesselb commented Oct 3, 2020

I don't see how to run into a type error? swapTotal is casted the line before and the free space is also casted.

Mind to add an example?

@kesselb
Copy link
Collaborator

kesselb commented Oct 3, 2020

['/sbin/sysctl -n hw.physmem hw.pagesize vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count', file_get_contents(__DIR__ . '/../data/freebsd_meminfo')],

if ($command === '/sbin/sysctl -n hw.physmem hw.pagesize vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count') {

Change hw.physmem to hw.realmem for a happy CI.

@ghost
Copy link
Author

ghost commented Oct 3, 2020

I don't see how to run into a type error? swapTotal is casted the line before and the free space is also casted.

Mind to add an example?

From my logs

{"Exception":"Exception","Message":"Argument 1 passed to OCA\\ServerInfo\\Resources\\Memory::setSwapFree() must be of the type int, float given, called in /usr/local/www/nextcloud/apps/serverinfo/lib/OperatingSystems/FreeBSD.php on line 57"

@kesselb
Copy link
Collaborator

kesselb commented Oct 3, 2020

Mind to share the output of /usr/sbin/swapinfo -k?

@ghost
Copy link
Author

ghost commented Oct 3, 2020

Mind to share the output of /usr/sbin/swapinfo -k?

Device          1K-blocks     Used    Avail Capacity
/dev/ada0p3       3744300   269052  3475248     7%

@kesselb
Copy link
Collaborator

kesselb commented Oct 3, 2020

(int)($matches['Used'][0]) / 1024

Ah. The closing bracket is wrong in the above code. It should be (int)($matches['Used'][0] / 1024). First divide by 1024 and cast afterwards: $data->setSwapFree((int)($data->getSwapTotal() - ($matches['Used'][0] / 1024)));

Mind to update your patch and adjust the tests for hw.realmem?

Signed-off-by: Matthew Wener <[email protected]>
Signed-off-by: Matthew Wener <[email protected]>
@kesselb
Copy link
Collaborator

kesselb commented Oct 3, 2020

if ($command === '/sbin/sysctl -n hw.physmem hw.pagesize vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count') {

Change hw.physmem to hw.realmem for a happy CI.

Please update this test case as well.

@kesselb
Copy link
Collaborator

kesselb commented Oct 3, 2020

/backport to stable20

Copy link
Collaborator

@kesselb kesselb left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@kesselb kesselb merged commit 49952d2 into nextcloud:master Oct 4, 2020
@backportbot-nextcloud
Copy link

The backport to stable20 failed. Please do this backport manually.

kesselb pushed a commit that referenced this pull request Oct 4, 2020
* Fix Memory

Cast swapFree to integer to fix typeerror.

Fix total memory to use hw.realmem

Signed-off-by: Matthew Wener <[email protected]>
Signed-off-by: Matthew Wener <[email protected]>

* Prevent float in swapinfo and update tests for hw.realmem

Signed-off-by: Matthew Wener <[email protected]>
Signed-off-by: Matthew Wener <[email protected]>

* Update testGetMemoryNoSwapinfo to hw.realmem

Signed-off-by: Matthew Wener <[email protected]>
(cherry picked from commit 49952d2)
@kesselb kesselb mentioned this pull request Oct 4, 2020
kesselb pushed a commit that referenced this pull request Oct 4, 2020
* Fix Memory

Cast swapFree to integer to fix typeerror.

Fix total memory to use hw.realmem

Signed-off-by: Matthew Wener <[email protected]>
Signed-off-by: Matthew Wener <[email protected]>

* Prevent float in swapinfo and update tests for hw.realmem

Signed-off-by: Matthew Wener <[email protected]>
Signed-off-by: Matthew Wener <[email protected]>

* Update testGetMemoryNoSwapinfo to hw.realmem

Signed-off-by: Matthew Wener <[email protected]>
(cherry picked from commit 49952d2)
Signed-off-by: Daniel Kesselberg <[email protected]>
nickvergessen added a commit that referenced this pull request Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants