Multiple K8s integration issues
- Fixed config loading issue on remote env
- Fixed kube.conf path passing
- Fixed skip.list handling
Related-PROD: PROD-35903
Change-Id: I4c22607dcbfab7dfe15d86b5a6ece77c32aaac2c
diff --git a/cfg_checker/common/settings.py b/cfg_checker/common/settings.py
index c681114..c654970 100644
--- a/cfg_checker/common/settings.py
+++ b/cfg_checker/common/settings.py
@@ -3,6 +3,10 @@
import pwd
import sys
+from cfg_checker.common.const import ENV_TYPE_GLOB, ENV_TYPE_SALT
+from cfg_checker.common.const import ENV_TYPE_KUBE, ENV_TYPE_LINUX, ENV_LOCAL
+from cfg_checker.common.const import supported_envs
+
from cfg_checker.common.exception import ConfigException
from cfg_checker.common.log import logger_cli
@@ -18,15 +22,6 @@
_default_work_folder = os.path.normpath(pkg_dir)
-ENV_TYPE_GLOB = "MCP"
-ENV_TYPE_SALT = "SALT"
-ENV_TYPE_KUBE = "KUBE"
-ENV_TYPE_LINUX = "LINUX"
-
-ENV_LOCAL = "local"
-
-supported_envs = [ENV_TYPE_LINUX, ENV_TYPE_SALT, ENV_TYPE_KUBE]
-
def _extract_salt_return(_raw):
if not isinstance(_raw, str):
@@ -93,6 +88,19 @@
return False
elif _type == ENV_TYPE_KUBE:
_kube = get_kube_remote(self)
+ if not _kube.initialized:
+ logger_cli.debug(
+ "... failed to load config from '{}'".format(
+ _kube.kConfigPath
+ )
+ )
+ return False
+ else:
+ logger_cli.debug(
+ "... config loaded from '{}'".format(
+ _kube.kConfigPath
+ )
+ )
try:
_vApi = _kube.get_versions_api()
_v = _vApi.get_code()
@@ -111,8 +119,8 @@
else:
return False
except Exception as e:
- logger_cli.warn(
- "# Unexpected error finding Kube env: '{}' ".format(
+ logger_cli.debug(
+ "... kube env error: '{}' ".format(
str(e)
)
)
@@ -178,7 +186,7 @@
self.pkg_versions_map = 'versions_map.csv'
- self.ssh_uses_sudo = False
+ # self.ssh_uses_sudo = False
self.ssh_key = os.environ.get('MCP_SSH_KEY', None)
self.ssh_user = os.environ.get('MCP_SSH_USER', None)
self.ssh_host = os.environ.get('MCP_SSH_HOST', None)
@@ -347,11 +355,13 @@
if args.env_name == ENV_LOCAL:
_env = os.getenv('MCP_ENV', None)
_env = _env if _env else args.env_name
+ _env_config_path = os.path.join(pkg_dir, 'etc', _env + '.env')
else:
_env = args.env_name
+ _env_config_path = args.env_config
# Init environment variables from file, validate
- self._init_env(args.env_config, env_name=_env)
+ self._init_env(_env_config_path, env_name=_env)
# Load Common vars for any type of the env
self._init_mcp_values()
# Detect env types present