Skip to content

Commit

Permalink
Merge pull request #3420 from bharathappali/edit-running-in-container
Browse files Browse the repository at this point in the history
Added portlibrary global to make isRunningInContainer called at startup
  • Loading branch information
charliegracie authored Jan 23, 2019
2 parents b5bbf5d + 2c23672 commit cf3e1b6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions include_core/omrport.h
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ typedef struct OMRPortLibrary {
/** see @ref omrsysinfo.c::omrsysinfo_get_cgroup_subsystem_list "omrsysinfo_get_cgroup_subsystem_list"*/
struct OMRCgroupEntry *(*sysinfo_get_cgroup_subsystem_list)(struct OMRPortLibrary *portLibrary);
/** see @ref omrsysinfo.c::omrsysinfo_is_running_in_container "omrsysinfo_is_running_in_container"*/
BOOLEAN (*sysinfo_is_running_in_container)(struct OMRPortLibrary *portLibrary, int32_t *errorCode);
BOOLEAN (*sysinfo_is_running_in_container)(struct OMRPortLibrary *portLibrary);
/** see @ref omrsysinfo.c::omrsysinfo_cgroup_subsystem_iterator_init "omrsysinfo_cgroup_subsystem_iterator_init"*/
int32_t (*sysinfo_cgroup_subsystem_iterator_init)(struct OMRPortLibrary *portLibrary, uint64_t subsystem, struct OMRCgroupMetricIteratorState *state);
/** see @ref omrsysinfo.c::omrsysinfo_cgroup_subsystem_iterator_hasNext "omrsysinfo_cgroup_subsystem_iterator_hasNext"*/
Expand Down Expand Up @@ -2009,7 +2009,7 @@ extern J9_CFUNC int32_t omrport_getVersion(struct OMRPortLibrary *portLibrary);
#define omrsysinfo_cgroup_get_memlimit(param1) privateOmrPortLibrary->sysinfo_cgroup_get_memlimit(privateOmrPortLibrary, param1)
#define omrsysinfo_cgroup_is_memlimit_set() privateOmrPortLibrary->sysinfo_cgroup_is_memlimit_set(privateOmrPortLibrary)
#define omrsysinfo_get_cgroup_subsystem_list() privateOmrPortLibrary->sysinfo_get_cgroup_subsystem_list(privateOmrPortLibrary)
#define omrsysinfo_is_running_in_container(param1) privateOmrPortLibrary->sysinfo_is_running_in_container(privateOmrPortLibrary, param1)
#define omrsysinfo_is_running_in_container() privateOmrPortLibrary->sysinfo_is_running_in_container(privateOmrPortLibrary)
#define omrsysinfo_cgroup_subsystem_iterator_init(param1, param2) privateOmrPortLibrary->sysinfo_cgroup_subsystem_iterator_init(privateOmrPortLibrary, param1, param2)
#define omrsysinfo_cgroup_subsystem_iterator_hasNext(param1) privateOmrPortLibrary->sysinfo_cgroup_subsystem_iterator_hasNext(privateOmrPortLibrary, param1)
#define omrsysinfo_cgroup_subsystem_iterator_metricKey(param1, param2) privateOmrPortLibrary->sysinfo_cgroup_subsystem_iterator_metricKey(privateOmrPortLibrary, param1, param2)
Expand Down
7 changes: 3 additions & 4 deletions port/common/omrsysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ omrsysinfo_shutdown(struct OMRPortLibrary *portLibrary)
int32_t
omrsysinfo_startup(struct OMRPortLibrary *portLibrary)
{
PPG_isRunningInContainer = FALSE;
return 0;
}

Expand Down Expand Up @@ -955,14 +956,12 @@ omrsysinfo_get_cgroup_subsystem_list(struct OMRPortLibrary *portLibrary)
*
* @param[in] portLibrary pointer to OMRPortLibrary
*
* @param[in] errorCode int32_t pointer to state error code from internal calls
*
* @return TRUE if Runtime is running in a container and FALSE if not or if an error occurs
*/
BOOLEAN
omrsysinfo_is_running_in_container(struct OMRPortLibrary *portLibrary, int32_t *errorCode)
omrsysinfo_is_running_in_container(struct OMRPortLibrary *portLibrary)
{
return FALSE;
return PPG_isRunningInContainer;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions port/include/omrportpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ typedef struct OMRPortPlatformGlobals {
uintptr_t vmem_pageSize[OMRPORT_VMEM_PAGESIZE_COUNT]; /** <0 terminated array of supported page sizes */
uintptr_t vmem_pageFlags[OMRPORT_VMEM_PAGESIZE_COUNT]; /** <0 terminated array of flags describing type of the supported page sizes */
uintptr_t systemLoggingFlags;
BOOLEAN isRunningInContainer;
} OMRPortPlatformGlobals;

#define PPG_vmem_pageSize (portLibrary->portGlobals->platformGlobals.vmem_pageSize)
#define PPG_vmem_pageFlags (portLibrary->portGlobals->platformGlobals.vmem_pageFlags)
#define PPG_syslog_flags (portLibrary->portGlobals->platformGlobals.systemLoggingFlags)
#define PPG_isRunningInContainer (portLibrary->portGlobals->platformGlobals.isRunningInContainer)
#endif /* omrportpg_h */
2 changes: 1 addition & 1 deletion port/omrportpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ omrsysinfo_cgroup_is_memlimit_set(struct OMRPortLibrary *portLibrary);
extern J9_CFUNC struct OMRCgroupEntry *
omrsysinfo_get_cgroup_subsystem_list(struct OMRPortLibrary *portLibrary);
extern J9_CFUNC BOOLEAN
omrsysinfo_is_running_in_container(struct OMRPortLibrary *portLibrary, int32_t *errorCode);
omrsysinfo_is_running_in_container(struct OMRPortLibrary *portLibrary);
extern J9_CFUNC int32_t
omrsysinfo_cgroup_subsystem_iterator_init(struct OMRPortLibrary *portLibrary, uint64_t subsystem, struct OMRCgroupMetricIteratorState *state);
extern J9_CFUNC BOOLEAN
Expand Down
10 changes: 4 additions & 6 deletions port/unix/omrsysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,7 @@ omrsysinfo_shutdown(struct OMRPortLibrary *portLibrary)
int32_t
omrsysinfo_startup(struct OMRPortLibrary *portLibrary)
{
PPG_isRunningInContainer = FALSE;
/* Obtain and cache executable name; if this fails, executable name remains NULL, but
* shouldn't cause failure to startup port library. Failure will be noticed only
* when the omrsysinfo_get_executable_name() actually gets invoked.
Expand All @@ -2126,6 +2127,7 @@ omrsysinfo_startup(struct OMRPortLibrary *portLibrary)
}
}
attachedPortLibraries += 1;
isRunningInContainer(portLibrary, &PPG_isRunningInContainer);
#endif /* defined(LINUX) */
return 0;
}
Expand Down Expand Up @@ -4523,13 +4525,9 @@ omrsysinfo_get_cgroup_subsystem_list(struct OMRPortLibrary *portLibrary)
* Returns TRUE if running inside a container and FALSE if not or if an error occurs
*/
BOOLEAN
omrsysinfo_is_running_in_container(struct OMRPortLibrary *portLibrary, int32_t *errorCode)
omrsysinfo_is_running_in_container(struct OMRPortLibrary *portLibrary)
{
BOOLEAN inContainer = FALSE;
#if defined(LINUX) && !defined(OMRZTPF)
*errorCode = isRunningInContainer(portLibrary, &inContainer);
#endif /* defined(LINUX) && !defined(OMRZTPF) */
return inContainer;
return PPG_isRunningInContainer;
}

int32_t
Expand Down
2 changes: 2 additions & 0 deletions port/unix_include/omrportpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typedef struct OMRPortPlatformGlobals {
char *si_osVersion;
uintptr_t vmem_pageSize[OMRPORT_VMEM_PAGESIZE_COUNT]; /** <0 terminated array of supported page sizes */
uintptr_t vmem_pageFlags[OMRPORT_VMEM_PAGESIZE_COUNT]; /** <0 terminated array of flags describing type of the supported page sizes */
BOOLEAN isRunningInContainer;
#if defined(LINUX) && defined(S390)
int64_t last_clock_delta_update; /** hw clock microsecond timestamp of last clock delta adjustment */
int64_t software_msec_clock_delta; /** signed difference between hw and sw clocks in milliseconds */
Expand Down Expand Up @@ -108,6 +109,7 @@ typedef struct OMRPortPlatformGlobals {
#define PPG_si_osVersion (portLibrary->portGlobals->platformGlobals.si_osVersion)
#define PPG_vmem_pageSize (portLibrary->portGlobals->platformGlobals.vmem_pageSize)
#define PPG_vmem_pageFlags (portLibrary->portGlobals->platformGlobals.vmem_pageFlags)
#define PPG_isRunningInContainer (portLibrary->portGlobals->platformGlobals.isRunningInContainer)
#if defined(LINUX) && defined(S390)
#define PPG_last_clock_delta_update (portLibrary->portGlobals->platformGlobals.last_clock_delta_update)
#define PPG_software_msec_clock_delta (portLibrary->portGlobals->platformGlobals.software_msec_clock_delta)
Expand Down
5 changes: 3 additions & 2 deletions port/win32/omrsysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ omrsysinfo_shutdown(struct OMRPortLibrary *portLibrary)
int32_t
omrsysinfo_startup(struct OMRPortLibrary *portLibrary)
{
PPG_isRunningInContainer = FALSE;
/* Obtain and cache executable name; if this fails, executable name remains NULL, but
* shouldn't cause failure to startup port library. Failure will be noticed only
* when the omrsysinfo_get_executable_name() actually gets invoked.
Expand Down Expand Up @@ -1679,9 +1680,9 @@ omrsysinfo_get_cgroup_subsystem_list(struct OMRPortLibrary *portLibrary)
}

BOOLEAN
omrsysinfo_is_running_in_container(struct OMRPortLibrary *portLibrary, int32_t *errorCode)
omrsysinfo_is_running_in_container(struct OMRPortLibrary *portLibrary)
{
return FALSE;
return PPG_isRunningInContainer;
}

int32_t
Expand Down
2 changes: 2 additions & 0 deletions port/win32_include/omrportpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ typedef struct OMRPortPlatformGlobals {
HANDLE mem_heap;
uintptr_t vmem_pageSize[OMRPORT_VMEM_PAGESIZE_COUNT]; /** <0 terminated array of supported page sizes */
uintptr_t vmem_pageFlags[OMRPORT_VMEM_PAGESIZE_COUNT]; /** <0 terminated array of flags describing type of the supported page sizes */
BOOLEAN isRunningInContainer;
char *si_osType;
char *si_osTypeOnHeap;
char *si_osVersion;
Expand Down Expand Up @@ -164,6 +165,7 @@ typedef struct OMRPortPlatformGlobals {
#define PPG_mem_heap (portLibrary->portGlobals->platformGlobals.mem_heap)
#define PPG_vmem_pageSize (portLibrary->portGlobals->platformGlobals.vmem_pageSize)
#define PPG_vmem_pageFlags (portLibrary->portGlobals->platformGlobals.vmem_pageFlags)
#define PPG_isRunningInContainer (portLibrary->portGlobals->platformGlobals.isRunningInContainer)
#define PPG_si_osType (portLibrary->portGlobals->platformGlobals.si_osType)
#define PPG_si_osTypeOnHeap (portLibrary->portGlobals->platformGlobals.si_osTypeOnHeap)
#define PPG_si_osVersion (portLibrary->portGlobals->platformGlobals.si_osVersion)
Expand Down
2 changes: 2 additions & 0 deletions port/zos390/omrportpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ typedef struct OMRPortPlatformGlobals {
char *si_osVersion;
uintptr_t vmem_pageSize[OMRPORT_VMEM_PAGESIZE_COUNT]; /** <0 terminated array of supported page sizes */
uintptr_t vmem_pageFlags[OMRPORT_VMEM_PAGESIZE_COUNT]; /** <0 terminated array of flags describing type of the supported page sizes */
BOOLEAN isRunningInContainer;
#if defined(OMR_ENV_DATA64)
J9SubAllocateHeapMem32 subAllocHeapMem32;
#endif
Expand All @@ -76,6 +77,7 @@ typedef struct OMRPortPlatformGlobals {
#define PPG_si_osVersion (portLibrary->portGlobals->platformGlobals.si_osVersion)
#define PPG_vmem_pageSize (portLibrary->portGlobals->platformGlobals.vmem_pageSize)
#define PPG_vmem_pageFlags (portLibrary->portGlobals->platformGlobals.vmem_pageFlags)
#define PPG_isRunningInContainer (portLibrary->portGlobals->platformGlobals.isRunningInContainer)
#if defined(OMR_ENV_DATA64)
#define PPG_mem_mem32_subAllocHeapMem32 (portLibrary->portGlobals->platformGlobals.subAllocHeapMem32)
#endif
Expand Down

0 comments on commit cf3e1b6

Please sign in to comment.