utils
drunc.process_manager.utils
Classes
Functions:
compute_role_from_boot_request(boot_request)
Determine the process role from a BootRequest.
Extracts tree_id from the process metadata and checks executable_and_arguments for the drunc-controller executable, then delegates to ProcessMetadata.compute_role_from_tree_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
boot_request
|
BootRequest
|
The BootRequest describing the process to launch. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Role string: "root-controller", "segment-controller", "application", "infrastructure-applications", or "unknown". |
Source code in drunc/process_manager/utils.py
format_hostname(hostname)
Format the host name to truly reflect what the host name is, removing any extensions that do not reflect the true host alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hostname
|
str
|
The hostname to format. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The formatted hostname. |
Raises:
| Type | Description |
|---|---|
DruncCommandException
|
If the hostname is empty or None. |
Example
If the input hostname is "np02-srv-005-1", the output will be "np02-srv-005".
Source code in drunc/process_manager/utils.py
get_pm_type_from_name(pm_name)
Get the ProcessManagerTypes enum value from a string name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pm_name
|
str
|
The name of the process manager type (e.g., "SSH", "K8s"). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ProcessManagerTypes |
ProcessManagerTypes
|
The corresponding enum value. |
Source code in drunc/process_manager/utils.py
on_parent_exit(signum)
Return a function to be run in a child process which will trigger SIGNAME to be sent when the parent process dies
Source code in drunc/process_manager/utils.py
order_process_by_name(processes)
Given a list of processes, perform a tiered order by the name
Source code in drunc/process_manager/utils.py
validate_k8s_session_name(session)
Validate that the session/namespace name is valid according to RFC1123 label standard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
str
|
The session/namespace name to validate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the session name is valid, False otherwise. |