From f41bfb18650a2097b6650850355aa8d074dda9a7 Mon Sep 17 00:00:00 2001 From: Andrew Scribner Date: Thu, 16 Nov 2023 10:03:10 -0500 Subject: [PATCH] update kfp-api's apiserver configuration (#375) * update kfp-api's apiserver configuration This: * removes deprecated `DBCONFIG_USER`, etc, environment variables (they have been replaced by variables of name `DBCONFIG_[driver]CONFIG_*`) * adds `OBJECTSTORECONFIG_HOST`, `_PORT`, and `_REGION`, which previously were required. Although currently they seem to be ignored due to https://github.com/kubeflow/pipelines/issues/9689 - but in theory they'll matter again? Not sure exactly the scope of that issue. --- charms/kfp-api/src/charm.py | 20 +++++++++++++++----- charms/kfp-api/tests/unit/test_operator.py | 16 +++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/charms/kfp-api/src/charm.py b/charms/kfp-api/src/charm.py index 6a5eb73c..15da2061 100755 --- a/charms/kfp-api/src/charm.py +++ b/charms/kfp-api/src/charm.py @@ -222,6 +222,7 @@ def _generate_environment(self) -> dict: raise error env_vars = { + # Configurations that are also defined in the upstream manifests "AUTO_UPDATE_PIPELINE_DEFAULT_VERSION": self.model.config[ "auto-update-default-version" ], @@ -231,11 +232,6 @@ def _generate_environment(self) -> dict: "POD_NAMESPACE": self.model.name, "OBJECTSTORECONFIG_SECURE": "false", "OBJECTSTORECONFIG_BUCKETNAME": self.model.config["object-store-bucket-name"], - "DBCONFIG_USER": db_data["db_username"], - "DBCONFIG_PASSWORD": db_data["db_password"], - "DBCONFIG_DBNAME": db_data["db_name"], - "DBCONFIG_HOST": db_data["db_host"], - "DBCONFIG_PORT": db_data["db_port"], "DBCONFIG_CONMAXLIFETIME": "120s", "DB_DRIVER_NAME": "mysql", "DBCONFIG_MYSQLCONFIG_USER": db_data["db_username"], @@ -252,6 +248,20 @@ def _generate_environment(self) -> dict: "ML_PIPELINE_VISUALIZATIONSERVER_SERVICE_HOST": viz_data["service-name"], "ML_PIPELINE_VISUALIZATIONSERVER_SERVICE_PORT": viz_data["service-port"], "CACHE_IMAGE": self.model.config["cache-image"], + # Configurations charmed-kubeflow adds to those of upstream + "ARCHIVE_CONFIG_LOG_FILE_NAME": self.model.config["log-archive-filename"], + "ARCHIVE_CONFIG_LOG_PATH_PREFIX": self.model.config["log-archive-prefix"], + # OBJECTSTORECONFIG_HOST and _PORT set the object storage configurations, + # taking precedence over configuration in the config.json or + # MINIO_SERVICE_SERVICE_* environment variables. + # NOTE: While OBJECTSTORECONFIG_HOST and _PORT control the object store + # that the apiserver connects to, other parts of kfp currently cannot use + # object stores with arbitrary names. See + # https://github.com/kubeflow/pipelines/issues/9689 and + # https://github.com/canonical/minio-operator/pull/151 for more details. + "OBJECTSTORECONFIG_HOST": f"{object_storage['service']}.{object_storage['namespace']}", + "OBJECTSTORECONFIG_PORT": str(object_storage["port"]), + "OBJECTSTORECONFIG_REGION": "", } return env_vars diff --git a/charms/kfp-api/tests/unit/test_operator.py b/charms/kfp-api/tests/unit/test_operator.py index 75295589..d5b691f4 100644 --- a/charms/kfp-api/tests/unit/test_operator.py +++ b/charms/kfp-api/tests/unit/test_operator.py @@ -446,11 +446,6 @@ def test_install_with_all_inputs_and_pebble( "POD_NAMESPACE": harness.charm.model.name, "OBJECTSTORECONFIG_SECURE": "false", "OBJECTSTORECONFIG_BUCKETNAME": harness.charm.config["object-store-bucket-name"], - "DBCONFIG_USER": "root", - "DBCONFIG_PASSWORD": mysql_data["root_password"], - "DBCONFIG_DBNAME": mysql_data["database"], - "DBCONFIG_HOST": mysql_data["host"], - "DBCONFIG_PORT": mysql_data["port"], "DBCONFIG_CONMAXLIFETIME": "120s", "DB_DRIVER_NAME": "mysql", "DBCONFIG_MYSQLCONFIG_USER": "root", @@ -467,6 +462,17 @@ def test_install_with_all_inputs_and_pebble( "ML_PIPELINE_VISUALIZATIONSERVER_SERVICE_HOST": kfp_viz_data["service-name"], "ML_PIPELINE_VISUALIZATIONSERVER_SERVICE_PORT": kfp_viz_data["service-port"], "CACHE_IMAGE": harness.charm.config["cache-image"], + "ARCHIVE_CONFIG_LOG_FILE_NAME": harness.charm.config["log-archive-filename"], + "ARCHIVE_CONFIG_LOG_PATH_PREFIX": harness.charm.config["log-archive-prefix"], + # OBJECTSTORECONFIG_HOST and _PORT currently have no effect due to + # https://github.com/kubeflow/pipelines/issues/9689, described more in + # https://github.com/canonical/minio-operator/pull/151 + # They're included here so that when the upstream issue is fixed we don't break + "OBJECTSTORECONFIG_HOST": ( + f"{objectstorage_data['service']}.{objectstorage_data['namespace']}" + ), + "OBJECTSTORECONFIG_PORT": str(objectstorage_data["port"]), + "OBJECTSTORECONFIG_REGION": "", } test_env = pebble_plan_info["services"][KFP_API_SERVICE_NAME]["environment"]