Updated how we check if Docker is running to work with the new cgroup v2 system. #1259
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.
Purpose of changes
While running CI tasks with Jenkins within a Docker environment, we encountered an unexpected behavior where the WDM returned the hostname as 'localhost' instead of the expected value. Upon further investigation, we discovered that the 'isRunningInsideDocker' method's command returned nothing when executed within a Docker container. This was attributed to the use of cgroup v2 on specific Linux operating systems, as the command is expected to only work with v1. Therefore, we identified and modified the command to be compatible with cgroup v2, and i anticipate that it will pass the validation checks correctly.
Types of changes
How has this been tested?
Setting up a testing environment on containers was very challenging. Instead, it will be replaced with the following resources.
Used a custom network, and the gateway is 172.20.0.1
Before the code change :
After the code change :
Confirmed that the results of the command are different inside and outside the container
Command Result (cgroup v2)
Inside Docker :
Outside Docker:
Reference:
https://stackoverflow.com/questions/68816329/how-to-get-docker-container-id-from-within-the-container-with-cgroup-v2
https://docs.docker.com/config/containers/runmetrics/