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

Docker containerId - cgroupv1 & v2 compatible #1434

Closed
wants to merge 17 commits into from

Conversation

VonOx
Copy link
Contributor

@VonOx VonOx commented Feb 16, 2022

Rework on the getNetworkMode, more precisely getting the container Id:

  • Getting container id from cid file if exist
  • Updateing command to be cgroups v2 compliant

⚠️ If host system is using cgroupv2 , gladys container must be created with specific argument

--cgroupns=host 
-v /sys/fs/cgroup:/sys/fs/cgroup:rw

So documentation and rpi image need to be updated too and cgroup "usage" deprecated

@codecov
Copy link

codecov bot commented Feb 17, 2022

Codecov Report

Merging #1434 (aeaa6bb) into master (b345e65) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1434   +/-   ##
=======================================
  Coverage   96.56%   96.56%           
=======================================
  Files         614      614           
  Lines        8814     8818    +4     
=======================================
+ Hits         8511     8515    +4     
  Misses        303      303           
Impacted Files Coverage Δ
server/lib/system/index.js 100.00% <100.00%> (ø)
server/lib/system/system.getNetworkMode.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b345e65...aeaa6bb. Read the comment docs.

@VonOx VonOx marked this pull request as ready for review February 17, 2022 09:59
@VonOx VonOx requested a review from Pierre-Gilles February 17, 2022 10:27
@VonOx VonOx marked this pull request as draft February 17, 2022 10:42
@VonOx VonOx marked this pull request as ready for review February 18, 2022 07:38
@Pierre-Gilles
Copy link
Contributor

Do we agree that this PR is no longer up to date after what we said on friday?

@VonOx
Copy link
Contributor Author

VonOx commented Feb 21, 2022

Yes you are right, I need to push the part concerning cidfile

@VonOx VonOx marked this pull request as draft February 21, 2022 10:38
@VonOx
Copy link
Contributor Author

VonOx commented Feb 24, 2022

@Pierre-Gilles @atrovato , I don't really understand why test fail on bluetooth here, any clue ?

@Pierre-Gilles
Copy link
Contributor

No idea for the bluetooth, I just restarted the build because sometimes the bluetooth fails for no reason (noble is not very stable)

@atrovato
Copy link
Contributor

@VonOx
This comes from your test, and stub on fs.
You should better fake and mock fs instead of using real one.

See changes in patch here ;)

fix-test-patch.txt

@VonOx
Copy link
Contributor Author

VonOx commented Feb 27, 2022

Thank you @atrovato , but I'm not sure to understand how my test can have an impact on bluetooth test. ( on my view completly independant , in reality not 😦 )

@VonOx VonOx marked this pull request as ready for review February 27, 2022 12:23
@VonOx VonOx requested a review from Pierre-Gilles February 27, 2022 12:23
Copy link
Contributor

@Pierre-Gilles Pierre-Gilles left a comment

Choose a reason for hiding this comment

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

I wrote a few feedbacks regarding the callback pattern used here.

Let me know if you have any questions :)

'cat /proc/self/cgroup | grep -o -e "docker.*" | head -n 1 | sed -e "s/.scope//g;s/docker-//g;s!docker/!!g"',
);
} else {
this.containerId = fs.readFile('/var/lib/gladysassistant/containerId', 'utf8');
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work, you are using a callback (async) function, the result won't be there.

You need to use async/await.

Two possibilities:

In Gladys 4 we don't use the callback pattern (because of the famous callback hell issue), and we rely only on async/await.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK understood

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Pierre-Gilles what about const { promises: fs } = require("fs"); ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed! I didn't know about this one, I learned something :D

You'll need to change the access too btw

server/package.json Show resolved Hide resolved
let fsError = false;
const fsMock = {
...fs,
access: (file, options, callback) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need to mock this as a async function

You can use fake.resolves() to do this (search in the codebase for fake.resolves and you will see some examples :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

No!

One example:

@Pierre-Gilles
Copy link
Contributor

Thank you @atrovato , but I'm not sure to understand how my test can have an impact on bluetooth test. ( on my view completly independant , in reality not 😦 )

You stubbed some functions globally in your test, so it affected other tests too.

@Pierre-Gilles
Copy link
Contributor

I improved this PR here: #1459

@VonOx VonOx closed this Mar 9, 2022
@VonOx VonOx deleted the fix-getNetworkMode branch April 7, 2022 14:14
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.

3 participants