From cb30f668628066453049ede5bac0af5329290b5e Mon Sep 17 00:00:00 2001 From: parth-gr Date: Tue, 16 Jul 2024 19:34:36 +0530 Subject: [PATCH] external: fix the output of user config currently the output in the cm was not human readable and can not easily used to create a config.ini file Also for now removed the support of printing arg in upstream Signed-off-by: parth-gr --- .../create-external-cluster-resources.py | 16 +++++----------- deploy/examples/import-external-cluster.sh | 8 +------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/deploy/examples/create-external-cluster-resources.py b/deploy/examples/create-external-cluster-resources.py index bb9a95375..2bc360200 100644 --- a/deploy/examples/create-external-cluster-resources.py +++ b/deploy/examples/create-external-cluster-resources.py @@ -1558,23 +1558,19 @@ class RadosJSON: for pool in topology_rbd_pools: self.init_rbd_pool(pool) - def getScriptCliFlags(self): - return " ".join(sys.argv[1:]) - # this will return the final args that script uses to process # the priority to set a particular value is, # command-line-args > config.ini file values > default values def getFinalUsedArgs(self): - list = [] + argument = f"[Configurations]\n" for arg in vars(self._arg_parser): if str(getattr(self._arg_parser, arg)): # python treats flag-name as flag_name internally, so converting back to flag-name, # so we can get those values from config file - argument = ( - arg.replace("_", "-") + ": " + str(getattr(self._arg_parser, arg)) - ) - list.append(argument) - return list + argValue = arg.replace("_", "-") + if argValue != "config-file": + argument += f"{argValue} = {str(getattr(self._arg_parser, arg))}\n" + return argument def _gen_output_map(self): if self.out_map: @@ -1591,7 +1587,6 @@ class RadosJSON: self._excluded_keys.add("K8S_CLUSTER_NAME") self.get_cephfs_data_pool_details() # double string needed for upstream exports of flags - self.out_map["EXTERNAL_CLUSTER_USER_COMMAND"] = f'"{self.getScriptCliFlags()}"' self.out_map["ARGS"] = f'"{self.getFinalUsedArgs()}"' self.out_map["NAMESPACE"] = self._arg_parser.namespace self.out_map["K8S_CLUSTER_NAME"] = self._arg_parser.k8s_cluster_name @@ -1757,7 +1752,6 @@ class RadosJSON: "name": "external-cluster-user-command", "kind": "ConfigMap", "data": { - "command": self.out_map["EXTERNAL_CLUSTER_USER_COMMAND"], "args": self.out_map["ARGS"], }, }, diff --git a/deploy/examples/import-external-cluster.sh b/deploy/examples/import-external-cluster.sh index 642c2011a..f13c10931 100644 --- a/deploy/examples/import-external-cluster.sh +++ b/deploy/examples/import-external-cluster.sh @@ -174,7 +174,6 @@ function createInputCommadConfigMap() { create \ configmap \ "$EXTERNAL_COMMAND_CONFIGMAP_NAME" \ - --from-literal=command="$EXTERNAL_CLUSTER_USER_COMMAND" \ --from-literal=args="$ARGS" else echo "configmap $EXTERNAL_COMMAND_CONFIGMAP_NAME already exists, updating it" @@ -182,12 +181,7 @@ function createInputCommadConfigMap() { patch \ configmap \ "$EXTERNAL_COMMAND_CONFIGMAP_NAME" \ - -p "{\"data\":{\"command\":\"$EXTERNAL_CLUSTER_USER_COMMAND\"}}" - $KUBECTL -n "$NAMESPACE" \ - patch \ - configmap \ - "$EXTERNAL_COMMAND_CONFIGMAP_NAME" \ - -p "{\"data\":{\"args\":\"$ARGS\"}}" + -p "$(jq -n --arg args "$ARGS" '{"data": {"args": $args}}')" fi }