-
Notifications
You must be signed in to change notification settings - Fork 397
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
Added portlibrary global to make isRunningInContainer called at startup #3420
Added portlibrary global to make isRunningInContainer called at startup #3420
Conversation
port/unix/omrsysinfo.c
Outdated
{ | ||
BOOLEAN inContainer = FALSE; | ||
#if defined(LINUX) && !defined(OMRZTPF) | ||
*errorCode = isRunningInContainer(portLibrary, &inContainer); | ||
inContainer = PPG_isRunningInContainer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can just return PPG_isRunningInContainer
. I don't think there is any need for inContainer
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but PPG_isRunningInContainer
is only in LINUX
and on other platforms it needs to return FALSE
so to avoid two returns i created a variable inContainer
and returning it.
Please correct me if i'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I didn't realize PPG_isRunningInContainer
is only in LINUX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have the global on all platforms and always just return the global? Platforms that do not support containers can just always set the global to false. This way in the future if other platforms do support containers there would be less code to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@charliegracie That sounds good to me, Will be making the changes. Thanks !
Can you please add a comment as to why the |
As the current implementation is making the result of Please provide your views on it @ashu-mehra . Thanks! |
@@ -960,7 +960,7 @@ omrsysinfo_get_cgroup_subsystem_list(struct OMRPortLibrary *portLibrary) | |||
* @return TRUE if Runtime is running in a container and FALSE if not or if an error occurs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param[in] errorCode int32_t pointer to state error code from internal calls
Needs to be removed as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed description for errorCode
param.
3580185
to
8e47fdd
Compare
@@ -2058,6 +2059,7 @@ omrsysinfo_startup(struct OMRPortLibrary *portLibrary) | |||
} | |||
} | |||
attachedPortLibraries += 1; | |||
isRunningInContainer(portLibrary, &PPG_isRunningInContainer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make more sense for this code to look like this:
PPG_isRunningInContainer = isRunningInContainer(portLibrary);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any update on this question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for delayed reply @charliegracie I have missed to reply to this question earlier.
isRunningInContainer
is an internal method which is used by many functions and some of them (now or in future) might need the return code
of it. So I'm thinking it would be better to have the current implementation to have the error code handy. Please let me know your views on it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem :). Ah I missed the other callers. Since the other callers are using the return value I think it makes sense to leave the code as is. Thanks!
…ibrary startup OMR PortLibrary api `omrsysinfo_is_running_in_container` is required by every runtime built on top of OMR and also might be having many places where this would be called, As this api internally calls other function `isRunningInContainer`, its get invoked everytime we make a call to the api so it would be good to have a PortLibrary global variable `PPG_isRunningInContainer` for is running in container check and also that function to be called at the portLibrary startup which assigns the value for the portlibrary global PPG_isRunningInContainer and would decrease the calls for `isRunningInContainer` function. Signed-off-by: bharathappali <bharath.appali@gmail.com>
8e47fdd
to
2c23672
Compare
@genie-omr build all |
@charliegracie continuous-integration is failing to fetch the origin. Will triggering the build again solves the problem ? |
@genie-omr build plinux |
OMR updated omrsysinfo_is_running_in_container() to remove the `errorCode` parameter in eclipse-omr/omr#3420 This change helps the openj9-omr to promote Signed-off-by: Dan Heidinga <daniel_heidinga@ca.ibm.com>
OMR updated omrsysinfo_is_running_in_container() to remove the `errorCode` parameter in eclipse-omr/omr#3420 This change helps the openj9-omr to promote Signed-off-by: Dan Heidinga <daniel_heidinga@ca.ibm.com>
OMR PortLibrary Api
omrsysinfo_is_running_in_container
is required by every runtime built on top of OMR and also might be having many places where this would be called, As this api internally calls other function, its get invoked everytime we make a call to the api so i thought it would be good to have a PortLibrary global variablePPG_isRunningInContainer
for is running in container check and also that function to be called at the portLibrary startup which assigns the value for the portlibrary globalPPG_isRunningInContainer
and would decrease the calls forisRunningInContainer
function.Signed-off-by: bharathappali bharath.appali@gmail.com