Skip to content

Commit

Permalink
17370 Ship python package "oracledb" with omd
Browse files Browse the repository at this point in the history
The active check <tt>check_sql</tt> uses the python package <tt>oracledb</tt>.
Previously, the user needed to install this package by hand. This situation may have caused issues during an omd update regarding python requirements resolution.

In order to avoid such issues, we simply now ship the python package and avoid the need for a user to install the package by hand.

CMK-19517

Change-Id: Ica0bc04a741cef671adb906dc5e19c90db62754b
  • Loading branch information
TimotheusBachinger committed Feb 25, 2025
1 parent 52997df commit c04367d
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 30 deletions.
17 changes: 17 additions & 0 deletions .werks/17370.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[//]: # (werk v2)
# Ship python package "oracledb" with omd

key | value
---------- | ---
compatible | yes
version | 2.3.0p28
date | 2025-02-25T13:43:32+00:00
level | 1
class | feature
component | checks
edition | cre

The active check <tt>check_sql</tt> uses the python package <tt>oracledb</tt>.
Previously, the user needed to install this package by hand. This situation may have caused issues during an omd update regarding python requirements resolution.

In order to avoid such issues, we simply now ship the python package and avoid the need for a user to install the package by hand.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ psycopg2-binary = "==2.9.6" # needed by check_sql active check
apispec = "==6.4.0" # direct dependency
marshmallow = "==3.19.0" # direct dependency
marshmallow-oneofschema = "==3.0.1" # direct dependency
oracledb = "==2.5.1" # used by active check_sql
apispec-oneofschema = "==3.0.0" # direct dependency
pydantic = "==2.5.2"
pydantic_core = "==2.14.5" # used by pydantic and by us
Expand Down
74 changes: 54 additions & 20 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions active_checks/check_sql
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,7 @@ def oracle_connect(host: str, port: int, db_name: str, user: str, pwd: str) -> A
sys.path.append(
f"/usr/lib/python{sys.version_info.major}.{sys.version_info.minor}/site-packages"
)
try:
import oracledb # type: ignore[import] # pylint: disable=import-error,import-outside-toplevel
except ImportError as exc:
bail_out(3, "%s. Please install it via 'pip install oracledb'." % exc)
import oracledb

try:
oracledb.init_oracle_client()
Expand All @@ -301,10 +298,7 @@ def oracle_connect(host: str, port: int, db_name: str, user: str, pwd: str) -> A
def oracle_execute(
cursor: Any, cmd: str, inpt: Sequence[str], procedure: bool
) -> list[tuple[Any, ...]]:
try:
import oracledb # pylint: disable=import-error,import-outside-toplevel
except ImportError as exc:
bail_out(3, "%s. Please install it via 'pip install oracledb'." % exc)
import oracledb

if procedure:
LOG.info("SQL Procedure Name: %s", cmd)
Expand Down
1 change: 1 addition & 0 deletions tests/code_quality/test_pipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def get_undeclared_dependencies() -> Iterable[Import]:
"markupsafe",
"more-itertools",
"multidict",
"oracledb", # actually used now by check_sql but those files are not yet checked to to missing .py extension (CMK-21797)
"pbr",
"ply",
"psycopg2-binary",
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/omd/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ def test_04_pip_user_can_install_non_wheel_packages(site: Site) -> None:

@pytest.mark.parametrize("pip_cmd", SUPPORTED_PIP_CMDS)
def test_05_pip_user_can_install_wheel_packages(site: Site, pip_cmd: PipCommand) -> None:
# We're using here another package which is needed for check_sql but not deployed by us
package_name = "oracledb"
package_name = "trickkiste"
if pip_cmd.needs_target_as_commandline:
command = pip_cmd.command + [
"install",
Expand Down

0 comments on commit c04367d

Please sign in to comment.