Skip to content

DB2 Module

The db2 module provides functions for DB2 database configuration and validation.

db2

Functions

get_db2u_instance_cr(custom_objects_api, mas_instance_id, mas_app_id, database_role='primary')

Retrieve the Db2uInstance custom resource for a specific MAS application database.

Parameters:

Name Type Description Default
custom_objects_api CustomObjectsApi

Kubernetes custom objects API client

required
mas_instance_id str

The ID of the MAS instance

required
mas_app_id str

The ID of the MAS application (e.g., "manage", "iot")

required
database_role str

The database role, either 'primary' or 'standby'. Defaults to 'primary'.

'primary'

Returns:

Name Type Description
dict dict

The Db2uInstance custom resource as a dictionary

Raises:

Type Description
ApiException

If the custom resource is not found or cannot be retrieved

Source code in src/mas/devops/db2.py
def get_db2u_instance_cr(custom_objects_api: client.CustomObjectsApi, mas_instance_id: str, mas_app_id: str, database_role='primary') -> dict:
    """
    Retrieve the Db2uInstance custom resource for a specific MAS application database.

    Parameters:
        custom_objects_api (client.CustomObjectsApi): Kubernetes custom objects API client
        mas_instance_id (str): The ID of the MAS instance
        mas_app_id (str): The ID of the MAS application (e.g., "manage", "iot")
        database_role (str, optional): The database role, either 'primary' or 'standby'. Defaults to 'primary'.

    Returns:
        dict: The Db2uInstance custom resource as a dictionary

    Raises:
        kubernetes.client.exceptions.ApiException: If the custom resource is not found or cannot be retrieved
    """
    cr_name = {'primary': f"db2wh-{mas_instance_id}-{mas_app_id}", 'standby': f"db2wh-{mas_instance_id}-{mas_app_id}-sdb"}[database_role]
    namespace = f"db2u-{mas_instance_id}"
    logger.debug(f"Getting Db2uInstance CR {cr_name} in {namespace}")

    db2u_instance_cr = custom_objects_api.get_namespaced_custom_object(
        group="db2u.databases.ibm.com",
        version="v1",
        namespace=namespace,
        plural="db2uinstances",
        name=cr_name
    )

    return db2u_instance_cr

db2_pod_exec(core_v1_api, mas_instance_id, mas_app_id, command, database_role='primary')

Execute a command in a DB2 pod for a specific MAS application database.

Parameters:

Name Type Description Default
core_v1_api CoreV1Api

Kubernetes Core V1 API client

required
mas_instance_id str

The ID of the MAS instance

required
mas_app_id str

The ID of the MAS application (e.g., "manage", "iot")

required
command list

The command to execute as a list of strings

required
database_role str

The database role, either 'primary' or 'standby'. Defaults to 'primary'.

'primary'

Returns:

Name Type Description
str str

The standard output from the command execution

Raises:

Type Description
Exception

If the command execution fails

Source code in src/mas/devops/db2.py
def db2_pod_exec(core_v1_api: client.CoreV1Api, mas_instance_id: str, mas_app_id: str, command: list, database_role='primary') -> str:
    """
    Execute a command in a DB2 pod for a specific MAS application database.

    Parameters:
        core_v1_api (client.CoreV1Api): Kubernetes Core V1 API client
        mas_instance_id (str): The ID of the MAS instance
        mas_app_id (str): The ID of the MAS application (e.g., "manage", "iot")
        command (list): The command to execute as a list of strings
        database_role (str, optional): The database role, either 'primary' or 'standby'. Defaults to 'primary'.

    Returns:
        str: The standard output from the command execution

    Raises:
        Exception: If the command execution fails
    """
    pod_name = {'primary': f"c-db2wh-{mas_instance_id}-{mas_app_id}-db2u-0", 'standby': f"c-db2wh-{mas_instance_id}-{mas_app_id}-sdb-db2u-0"}[database_role]
    namespace = f"db2u-{mas_instance_id}"
    return execInPod(core_v1_api, pod_name, namespace, command)

db2_pod_exec_db2_get_db_cfg(core_v1_api, mas_instance_id, mas_app_id, db_name, database_role='primary')

Execute 'db2 get db cfg' command in a DB2 pod to retrieve database configuration.

Parameters:

Name Type Description Default
core_v1_api CoreV1Api

Kubernetes Core V1 API client

required
mas_instance_id str

The ID of the MAS instance

required
mas_app_id str

The ID of the MAS application (e.g., "manage", "iot")

required
db_name str

The name of the database to query

required
database_role str

The database role, either 'primary' or 'standby'. Defaults to 'primary'.

'primary'

Returns:

Name Type Description
str str

The output of the 'db2 get db cfg' command

Raises:

Type Description
Exception

If the command execution fails

Source code in src/mas/devops/db2.py
def db2_pod_exec_db2_get_db_cfg(core_v1_api: client.CoreV1Api, mas_instance_id: str, mas_app_id: str, db_name: str, database_role='primary') -> str:
    """
    Execute 'db2 get db cfg' command in a DB2 pod to retrieve database configuration.

    Parameters:
        core_v1_api (client.CoreV1Api): Kubernetes Core V1 API client
        mas_instance_id (str): The ID of the MAS instance
        mas_app_id (str): The ID of the MAS application (e.g., "manage", "iot")
        db_name (str): The name of the database to query
        database_role (str, optional): The database role, either 'primary' or 'standby'. Defaults to 'primary'.

    Returns:
        str: The output of the 'db2 get db cfg' command

    Raises:
        Exception: If the command execution fails
    """
    command = ["su", "-lc", f"db2 get db cfg for {db_name}", "db2inst1"]
    return db2_pod_exec(core_v1_api, mas_instance_id, mas_app_id, command, database_role)

db2_pod_exec_db2_get_dbm_cfg(core_v1_api, mas_instance_id, mas_app_id, database_role='primary')

Execute 'db2 get dbm cfg' command in a DB2 pod to retrieve database manager configuration.

Parameters:

Name Type Description Default
core_v1_api CoreV1Api

Kubernetes Core V1 API client

required
mas_instance_id str

The ID of the MAS instance

required
mas_app_id str

The ID of the MAS application (e.g., "manage", "iot")

required
database_role str

The database role, either 'primary' or 'standby'. Defaults to 'primary'.

'primary'

Returns:

Name Type Description
str str

The output of the 'db2 get dbm cfg' command

Raises:

Type Description
Exception

If the command execution fails

Source code in src/mas/devops/db2.py
def db2_pod_exec_db2_get_dbm_cfg(core_v1_api: client.CoreV1Api, mas_instance_id: str, mas_app_id: str, database_role='primary') -> str:
    """
    Execute 'db2 get dbm cfg' command in a DB2 pod to retrieve database manager configuration.

    Parameters:
        core_v1_api (client.CoreV1Api): Kubernetes Core V1 API client
        mas_instance_id (str): The ID of the MAS instance
        mas_app_id (str): The ID of the MAS application (e.g., "manage", "iot")
        database_role (str, optional): The database role, either 'primary' or 'standby'. Defaults to 'primary'.

    Returns:
        str: The output of the 'db2 get dbm cfg' command

    Raises:
        Exception: If the command execution fails
    """
    command = ["su", "-lc", "db2 get dbm cfg", "db2inst1"]
    return db2_pod_exec(core_v1_api, mas_instance_id, mas_app_id, command, database_role)

db2_pod_exec_db2set(core_v1_api, mas_instance_id, mas_app_id, database_role='primary')

Execute 'db2set' command in a DB2 pod to retrieve registry configuration variables.

Parameters:

Name Type Description Default
core_v1_api CoreV1Api

Kubernetes Core V1 API client

required
mas_instance_id str

The ID of the MAS instance

required
mas_app_id str

The ID of the MAS application (e.g., "manage", "iot")

required
database_role str

The database role, either 'primary' or 'standby'. Defaults to 'primary'.

'primary'

Returns:

Name Type Description
str str

The output of the 'db2set' command

Raises:

Type Description
Exception

If the command execution fails

Source code in src/mas/devops/db2.py
def db2_pod_exec_db2set(core_v1_api: client.CoreV1Api, mas_instance_id: str, mas_app_id: str, database_role='primary') -> str:
    """
    Execute 'db2set' command in a DB2 pod to retrieve registry configuration variables.

    Parameters:
        core_v1_api (client.CoreV1Api): Kubernetes Core V1 API client
        mas_instance_id (str): The ID of the MAS instance
        mas_app_id (str): The ID of the MAS application (e.g., "manage", "iot")
        database_role (str, optional): The database role, either 'primary' or 'standby'. Defaults to 'primary'.

    Returns:
        str: The output of the 'db2set' command

    Raises:
        Exception: If the command execution fails
    """
    command = ["su", "-lc", "db2set", "db2inst1"]
    return db2_pod_exec(core_v1_api, mas_instance_id, mas_app_id, command, database_role)

cr_pod_v_matches(cr_k, cr_v, pod_v)

Compare a configuration value from the Db2uInstance CR with the actual value from the DB2 pod.

This function handles special cases where the CR and pod values are expressed differently even when they represent the same configuration (e.g., "8192 AUTOMATIC" vs "AUTOMATIC(8192)").

Parameters:

Name Type Description Default
cr_k str

The configuration parameter key/name

required
cr_v str

The configuration value from the Db2uInstance CR

required
pod_v str

The actual configuration value from the DB2 pod

required

Returns:

Name Type Description
bool bool

True if the values match (considering special cases), False otherwise

Source code in src/mas/devops/db2.py
def cr_pod_v_matches(cr_k: str, cr_v: str, pod_v: str) -> bool:
    """
    Compare a configuration value from the Db2uInstance CR with the actual value from the DB2 pod.

    This function handles special cases where the CR and pod values are expressed differently
    even when they represent the same configuration (e.g., "8192 AUTOMATIC" vs "AUTOMATIC(8192)").

    Parameters:
        cr_k (str): The configuration parameter key/name
        cr_v (str): The configuration value from the Db2uInstance CR
        pod_v (str): The actual configuration value from the DB2 pod

    Returns:
        bool: True if the values match (considering special cases), False otherwise
    """
    logger.debug(f"[{cr_k}] '{cr_v}' ~= '{pod_v}'")
    # special cases where cr_v and pod_v values are expressed differently even if they mean the same thing
    if cr_k in ["MIRRORLOGPATH"]:
        # db2 appends something like "/NODE0000/LOGSTREAM0000/" to the cr_v in these cases
        return pod_v.startswith(cr_v)

    # Look for e.g. 8192 AUTOMATIC -> AUTOMATIC(8192)
    matches = re.search(r"(\d+)\s*AUTOMATIC", cr_v, re.IGNORECASE)
    if matches is not None:
        cr_v_num = int(matches.group(1))
        return pod_v == f"AUTOMATIC({cr_v_num})"

    # Look for e.g. AUTOMATIC -> AUTOMATIC(6554) or AUTOMATIC
    if cr_v.upper() == "AUTOMATIC":
        return pod_v == "AUTOMATIC" or re.search(r"AUTOMATIC\(\d+\)", pod_v) is not None

    return pod_v == cr_v

check_db_cfgs(db2u_instance_cr, core_v1_api, mas_instance_id, mas_app_id, database_role='primary')

Runs check_db_cfg for each database in the provided Db2uInstance CR

Parameters:

Name Type Description Default
db2u_instance_cr dict

the Db2uInstanceCR as a dict (use get_db2u_instance_cr)

required
core_v1_api CoreV1Api

The Kubernetes API client

required
mas_instance_id str

The ID of the MAS instance.

required
mas_app_id str

The ID of the MAS app the DB2 database is for (e.g. "manage", "iot")

required

Returns:

Name Type Description
list list

The outputs of each call to check_db_cfg concatenated together

Source code in src/mas/devops/db2.py
def check_db_cfgs(db2u_instance_cr: dict, core_v1_api: client.CoreV1Api, mas_instance_id: str, mas_app_id: str, database_role='primary') -> list:
    """
    Runs check_db_cfg for each database in the provided Db2uInstance CR

    Parameters:
      db2u_instance_cr (dict): the Db2uInstanceCR as a dict (use get_db2u_instance_cr)
      core_v1_api (client.CoreV1Api): The Kubernetes API client
      mas_instance_id (str): The ID of the MAS instance.
      mas_app_id (str): The ID of the MAS app the DB2 database is for (e.g. "manage", "iot")

    Returns:
      list: The outputs of each call to check_db_cfg concatenated together
    """
    failures = []

    db2u_instance_cr_databases = db2u_instance_cr.get("spec", {}).get("environment", {}).get("databases", {})
    if len(db2u_instance_cr_databases) == 0:
        raise Exception("spec.environment.databases not found or empty")

    # Check each db cfg
    for cr_db in db2u_instance_cr_databases:
        failures = [*failures, *check_db_cfg(cr_db, core_v1_api, mas_instance_id, mas_app_id, database_role)]

    return failures

check_db_cfg(db_dr, core_v1_api, mas_instance_id, mas_app_id, database_role='primary')

Check that the parameters in the provided db dict taken from the Db2uInstance CR align with those in the output of the db2 get db cfg command (i.e. the configuration that is actually active in DB2).

Parameters:

Name Type Description Default
db_dr dict

one element under spec.environment.databases taken from the Db2uInstance CR

required
core_v1_api CoreV1Api

The Kubernetes API client

required
mas_instance_id str

The ID of the MAS instance.

required
mas_app_id str

The ID of the MAS app the DB2 database is for (e.g. "manage", "iot")

required

Returns:

Name Type Description
list list

A list of strings describing any mismatches found between the CR and active DB2 configuration. Any empty list implies all configuration matches.

Source code in src/mas/devops/db2.py
def check_db_cfg(db_dr: dict, core_v1_api: client.CoreV1Api, mas_instance_id: str, mas_app_id: str, database_role='primary') -> list:
    """
    Check that the parameters in the provided db dict taken from the Db2uInstance CR align with those in the output of the
    db2 get db cfg command (i.e. the configuration that is actually active in DB2).

    Parameters:
      db_dr (dict): one element under spec.environment.databases taken from the Db2uInstance CR
      core_v1_api (client.CoreV1Api): The Kubernetes API client
      mas_instance_id (str): The ID of the MAS instance.
      mas_app_id (str): The ID of the MAS app the DB2 database is for (e.g. "manage", "iot")

    Returns:
      list: A list of strings describing any mismatches found between the CR and active DB2 configuration.
            Any empty list implies all configuration matches.
    """
    failures = []

    db_name = db_dr["name"]
    db_cfg_pod = db2_pod_exec_db2_get_db_cfg(core_v1_api, mas_instance_id, mas_app_id, db_name, database_role)

    logger.info(f"Checking db cfg for {db_name}\n{H1_BREAK}")

    db_cfg_cr = db_dr.get('dbConfig', None)
    if db_cfg_cr is None or len(db_cfg_cr) == 0:
        logger.info(f"No dbConfig for db {db_name} found in CR, skipping db cfg checks for {db_name}\n")
        return []

    logger.debug(f"db2 db {db_name} cfg output:\n{H2_BREAK}{db_cfg_pod}{H2_BREAK}")
    logger.debug(f"db2 db {db_name} cr settings:\n{H2_BREAK}\n{yaml.dump(db_cfg_cr, sort_keys=False, default_flow_style=False)}{H2_BREAK}")

    logger.debug(f"Running checks\n{H2_BREAK}")
    for cr_k, cr_v in db_cfg_cr.items():
        matches = re.search(fr"\({cr_k}\)\s=\s(.*)$", db_cfg_pod, re.MULTILINE)
        if matches is None:
            failures.append(f"[db cfg for {db_name}] {cr_k} not found in output of db2 get db cfg command")
            continue
        pod_v = matches.group(1)

        if not cr_pod_v_matches(cr_k, cr_v, pod_v):
            failures.append(f"[db cfg for {db_name}] {cr_k}: {cr_v} != {pod_v}")
    logger.debug(f"\n{H2_BREAK}")

    if len(failures) > 0:
        logger.warning(f"{len(failures)} checks failed for db cfg {db_name}\n")
    else:
        logger.info(f"All db cfg checks for {db_name} passed\n")
    return failures

check_dbm_cfg(db2u_instance_cr, core_v1_api, mas_instance_id, mas_app_id, database_role='primary')

Check that the database manager (dbmConfig) parameters from the Db2uInstance CR align with those in the output of the db2 get dbm cfg command (i.e. the configuration that is actually active in DB2).

Parameters:

Name Type Description Default
db2u_instance_cr dict

the Db2uInstanceCR as a dict (use get_db2u_instance_cr)

required
core_v1_api CoreV1Api

The Kubernetes API client

required
mas_instance_id str

The ID of the MAS instance.

required
mas_app_id str

The ID of the MAS app the DB2 database is for (e.g. "manage", "iot")

required

Returns:

Name Type Description
list list

A list of strings describing any mismatches found between the CR and active DB2 configuration. Any empty list implies all configuration matches.

Source code in src/mas/devops/db2.py
def check_dbm_cfg(db2u_instance_cr: dict, core_v1_api: client.CoreV1Api, mas_instance_id: str, mas_app_id: str, database_role='primary') -> list:
    """
    Check that the database manager (dbmConfig) parameters from the Db2uInstance CR align with those in the output of the
    db2 get dbm cfg command (i.e. the configuration that is actually active in DB2).

    Parameters:
      db2u_instance_cr (dict): the Db2uInstanceCR as a dict (use get_db2u_instance_cr)
      core_v1_api (client.CoreV1Api): The Kubernetes API client
      mas_instance_id (str): The ID of the MAS instance.
      mas_app_id (str): The ID of the MAS app the DB2 database is for (e.g. "manage", "iot")

    Returns:
      list: A list of strings describing any mismatches found between the CR and active DB2 configuration.
            Any empty list implies all configuration matches.
    """
    failures = []

    # Check dbm config
    logger.info(f"Checking dbm cfg\n{H1_BREAK}")
    dbm_cfg_cr = db2u_instance_cr.get("spec", {}).get("environment", {}).get("instance", {}).get("dbmConfig", {})
    if len(dbm_cfg_cr) == 0:
        logger.info("spec.environment.instance.dbmConfig not found or empty, skipping dbm cfg checks\n")
        return []

    dbm_cfg_pod = db2_pod_exec_db2_get_dbm_cfg(core_v1_api, mas_instance_id, mas_app_id, database_role)

    logger.debug(f"db2 dbm cfg output:\n{H2_BREAK}{dbm_cfg_pod}{H2_BREAK}")
    logger.debug(f"db2 dbm cr settings:\n{H2_BREAK}\n{yaml.dump(dbm_cfg_cr, sort_keys=False, default_flow_style=False)}{H2_BREAK}")

    logger.debug(f"Running checks\n{H2_BREAK}")
    for cr_k, cr_v in dbm_cfg_cr.items():
        matches = re.search(fr"\({cr_k}\)\s=\s(.*)$", dbm_cfg_pod, re.MULTILINE)
        if matches is None:
            failures.append(f"[dbm cfg] {cr_k} not found in output of db2 get dbm cfg command")
            continue
        pod_v = matches.group(1)

        if not cr_pod_v_matches(cr_k, cr_v, pod_v):
            failures.append(f"[dbm cfg] {cr_k}: {cr_v} != {pod_v}")
    logger.debug(f"\n{H2_BREAK}")

    if len(failures) > 0:
        logger.warning(f"{len(failures)} checks failed for dbm cfg\n")
    else:
        logger.info("All dbm cfg checks passed\n")

    return failures

check_reg_cfg(db2u_instance_cr, core_v1_api, mas_instance_id, mas_app_id, database_role='primary')

Check that the registry parameters from the Db2uInstance CR align with those in the output of the db2set command (i.e. the configuration that is actually active in DB2).

Parameters:

Name Type Description Default
db2u_instance_cr dict

the Db2uInstanceCR as a dict (use get_db2u_instance_cr)

required
core_v1_api CoreV1Api

The Kubernetes API client

required
mas_instance_id str

The ID of the MAS instance.

required
mas_app_id str

The ID of the MAS app the DB2 database is for (e.g. "manage", "iot")

required

Returns:

Name Type Description
list list

A list of strings describing any mismatches found between the CR and active DB2 configuration. Any empty list implies all configuration matches.

Source code in src/mas/devops/db2.py
def check_reg_cfg(db2u_instance_cr: dict, core_v1_api: client.CoreV1Api, mas_instance_id: str, mas_app_id: str, database_role='primary') -> list:
    """
    Check that the registry parameters from the Db2uInstance CR align with those in the output of the
    db2set command (i.e. the configuration that is actually active in DB2).

    Parameters:
      db2u_instance_cr (dict): the Db2uInstanceCR as a dict (use get_db2u_instance_cr)
      core_v1_api (client.CoreV1Api): The Kubernetes API client
      mas_instance_id (str): The ID of the MAS instance.
      mas_app_id (str): The ID of the MAS app the DB2 database is for (e.g. "manage", "iot")

    Returns:
      list: A list of strings describing any mismatches found between the CR and active DB2 configuration.
            Any empty list implies all configuration matches.
    """
    failures = []

    # Check registry cfg
    logger.info(f"Checking registry cfg\n{H1_BREAK}")

    reg_cfg_cr = db2u_instance_cr.get("spec", {}).get("environment", {}).get("instance", {}).get("registry", {})
    if len(reg_cfg_cr) == 0:
        logger.info("spec.environment.instance.registry not found or empty, skipping registry cfg checks\n")
        return []

    reg_cfg_pod = db2_pod_exec_db2set(core_v1_api, mas_instance_id, mas_app_id, database_role)

    logger.debug(f"db2set output:\n{H2_BREAK}{reg_cfg_pod}{H2_BREAK}")
    logger.debug(f"db2 cr registry settings:\n{H2_BREAK}\n{yaml.dump(reg_cfg_cr, sort_keys=False, default_flow_style=False)}{H2_BREAK}")

    logger.debug(f"Running checks\n{H2_BREAK}")
    for cr_k, cr_v in reg_cfg_cr.items():
        # regex ignores any trailing [O] (which indicates the param has been overridden I think)
        matches = re.search(fr"{cr_k}=(.*?)(?:\s\[O\])?$", reg_cfg_pod, re.MULTILINE)
        if matches is None and cr_v != '':
            failures.append(f"[registry cfg] {cr_k} not found in output of db2set command")
            continue
        pod_v = ''
        if cr_v != '':
            pod_v = matches.group(1)

        if not cr_pod_v_matches(cr_k, cr_v, pod_v):
            failures.append(f"[registry cfg] {cr_k}: {cr_v} != {pod_v}")
    logger.debug(f"\n{H2_BREAK}")

    if len(failures) > 0:
        logger.warning(f"{len(failures)} registry cfg checks failed\n")
    else:
        logger.info("All registry cfg checks passed\n")

    return failures

validate_db2_config(k8s_client, mas_instance_id, mas_app_id, database_role='primary')

Validate that the DB2 configuration in the Db2uInstance CR matches the actual configuration in the DB2 pods.

This function orchestrates validation of database configuration (db cfg), database manager configuration (dbm cfg), and registry configuration (db2set) by comparing values from the Db2uInstance custom resource against the actual running configuration in DB2.

Parameters:

Name Type Description Default
k8s_client ApiClient

Kubernetes API client

required
mas_instance_id str

The ID of the MAS instance

required
mas_app_id str

The ID of the MAS application (e.g., "manage", "iot")

required
database_role str

The database role, either 'primary' or 'standby'. Defaults to 'primary'.

'primary'

Returns:

Name Type Description
None

Logs results and raises an exception if any validation checks fail

Raises:

Type Description
Exception

If any configuration mismatches are detected between the CR and actual DB2 configuration. The exception contains a dict with 'message' and 'details' keys listing all failures.

Source code in src/mas/devops/db2.py
def validate_db2_config(k8s_client: client.api_client.ApiClient, mas_instance_id: str, mas_app_id: str, database_role='primary'):
    """
    Validate that the DB2 configuration in the Db2uInstance CR matches the actual configuration in the DB2 pods.

    This function orchestrates validation of database configuration (db cfg), database manager
    configuration (dbm cfg), and registry configuration (db2set) by comparing values from the
    Db2uInstance custom resource against the actual running configuration in DB2.

    Parameters:
        k8s_client (client.api_client.ApiClient): Kubernetes API client
        mas_instance_id (str): The ID of the MAS instance
        mas_app_id (str): The ID of the MAS application (e.g., "manage", "iot")
        database_role (str, optional): The database role, either 'primary' or 'standby'. Defaults to 'primary'.

    Returns:
        None: Logs results and raises an exception if any validation checks fail

    Raises:
        Exception: If any configuration mismatches are detected between the CR and actual DB2 configuration.
                  The exception contains a dict with 'message' and 'details' keys listing all failures.
    """
    core_v1_api = client.CoreV1Api(k8s_client)
    custom_objects_api = client.CustomObjectsApi(k8s_client)

    db2u_instance_cr = get_db2u_instance_cr(custom_objects_api, mas_instance_id, mas_app_id, database_role)
    db_failures = check_db_cfgs(db2u_instance_cr, core_v1_api, mas_instance_id, mas_app_id, database_role)
    dbm_failures = check_dbm_cfg(db2u_instance_cr, core_v1_api, mas_instance_id, mas_app_id, database_role)
    reg_failures = check_reg_cfg(db2u_instance_cr, core_v1_api, mas_instance_id, mas_app_id, database_role)

    all_failures = [*db_failures, *dbm_failures, *reg_failures]

    logger.info(f"Results\n{H1_BREAK}")
    if len(all_failures) > 0:

        logger.error(f"{len(all_failures)} checks failed:")

        logger.error(f" {len(db_failures)} db cfg failures:")
        for db_failure in db_failures:
            logger.error(f"    {db_failure}")

        logger.error(f" {len(dbm_failures)} dbm cfg failures:")
        for dbm_failure in dbm_failures:
            logger.error(f"    {dbm_failure}")

        logger.error(f" {len(reg_failures)} registry cfg failures:")
        for reg_failure in reg_failures:
            logger.error(f"    {reg_failure}")

        logger.info("Raising exception:")
        raise Exception(dict(
            message=f"{len(all_failures)} checks failed",
            details=all_failures
        ))
    else:
        logger.info("All checks passed")