Skip to content
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

Checking whether CG_MEM_SWAP is enabled at the moment. #28634

Merged
merged 1 commit into from Jan 27, 2017

Conversation

ghostplant
Copy link
Contributor

- What I did
Checking whether CG_MEM_SWAP is enabled at the current system session.
- How I did it
The original checking script only describes the method to enable CG_MEM_SWAP, while doesn't tell whether current system session already enables it or not.
- How to verify it
If current system session already enables CG_MEM_SWAP, the script should report 'currently enabled', otherwise report 'currently not enabled, you can enable it by ..'

Signed-off-by: CUI Wei ghostplant@qq.com

@vdemeester
Copy link
Member

/cc @justincormack

@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Nov 21, 2016
@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Nov 21, 2016
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Nov 21, 2016
if [ -e /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes ]; then
echo " $(wrap_color '(cgroup swap accounting is currently enabled)' bold black)"
elif is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then
echo " $(wrap_color '(cgroup swap accounting is currently not enabled, you can enable it by setting boot option "swapaccount=1")' bold black)"
Copy link
Contributor

Choose a reason for hiding this comment

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

This could cause the script to fail, to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What kind of fail is reported?

Copy link
Contributor

Choose a reason for hiding this comment

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

its just an exit code, 0 for ok, 1 for there is a problem you should fix. Lets you use it in CI tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and I have updated the code whose root-cause is check_flags missing.
If the exit code is still not 0 after the fix, it must be caused by other checking flags missing, not relevant to this change. Thanks!

@ghostplant
Copy link
Contributor Author

Any comments?
It seems that many cases such as 'no zfs' could also make EXITCODE=1

@justincormack
Copy link
Contributor

justincormack commented Nov 24, 2016 via email

echo " $(wrap_color '(note that cgroup swap accounting is not enabled in your kernel config, you can enable it by setting boot option "swapaccount=1")' bold black)"
if [ -e /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes ]; then
echo " $(wrap_color '(cgroup swap accounting is currently enabled)' bold black)"
EXITCODE=${CODE}
Copy link
Contributor

Choose a reason for hiding this comment

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

you dont need this

echo " $(wrap_color '(cgroup swap accounting is currently enabled)' bold black)"
EXITCODE=${CODE}
elif is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then
echo " $(wrap_color '(cgroup swap accounting is currently not enabled, you can enable it by setting boot option "swapaccount=1")' bold black)"
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just set EXITCODE=1 here instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that Line-95 in this script wrap_bad "CONFIG_$1" 'missing' ; EXITCODE=1 indicates that EXITCODE=1 is set when OS misses this flag, so the script will exit with code 1 even if CG_MEM_SWAP flag is enabled manually.

The current change will fix this case said above, though it seems to a little strange but actually not because it is referenced from Line-284. : )

@ghostplant
Copy link
Contributor Author

Any other concern?

@ghostplant
Copy link
Contributor Author

ghostplant commented Nov 28, 2016

'check-config.sh' in Docker 1.12.x branch doesn't fail on Ubuntu >=16.04, but 'check-config.sh' in Docker 1.14 branch will always fail even if all required configs are enabled.
This flag is the only root-cause that makes the script fail on Ubuntu >=16.04.

@thaJeztah
Copy link
Member

ping @justincormack PTAL

@LK4D4
Copy link
Contributor

LK4D4 commented Jan 26, 2017

ping @justincormack

@justincormack
Copy link
Contributor

Ok this is fine, it fixes that issue.

However on a Ubuntu 16.04 machine I had on Digital Ocean, CONFIG_RT_GROUP_SCHED is also failing in the optional section - is this the case for you?

@justincormack
Copy link
Contributor

Happy to merge this anyway as it is correct.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

ok let's merge this one @ghostplant can you do a follow-up for @justincormack's note?

LGTM

@thaJeztah thaJeztah merged commit e2de212 into moby:master Jan 27, 2017
@GordonTheTurtle GordonTheTurtle added this to the 1.14.0 milestone Jan 27, 2017
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.

None yet

7 participants