Переглянути джерело

HPCC-23992 File.getEspURL() failing in container mode

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 роки тому
батько
коміт
aa179f28d6

+ 1 - 0
dockerfiles/hpcc/templates/_helpers.tpl

@@ -49,6 +49,7 @@ Pass in root as .
 {{- define "hpcc.generateGlobalConfigMap" -}}
 imageVersion: {{ required "Please specify .global.image.version" .Values.global.image.version | quote }}
 singleNode: {{ .Values.global.singleNode | default false }}
+defaultEsp: {{ .Values.global.defaultEsp | default (index .Values.esp 0).name }}
 {{- end -}}
 
 {{/*

+ 3 - 0
dockerfiles/hpcc/values.schema.json

@@ -77,6 +77,9 @@
         },
         "logging": {
           "$ref": "#/definitions/logging"
+        },
+        "defaultEsp": {
+          "type": "string"
         }
       },
       "additionalProperties": false

+ 5 - 0
dockerfiles/hpcc/values.yaml

@@ -39,6 +39,11 @@ global:
   logging:
     detail: 100
 
+  # Specify a defauleEsp to control which EclWatch service is returned from Std.File.GetEspURL, and other uses
+  # If not specified, the first esp component present is assumed.
+  # Can also be overridden locally in individual components
+  ## defaultEsp: myesp
+
 dali:
 - name: mydali
   storage:

+ 18 - 0
plugins/fileservices/fileservices.cpp

@@ -2800,6 +2800,23 @@ FILESERVICES_API void FILESERVICES_CALL fsDfuPlusExec(ICodeContext * ctx,const c
 
 FILESERVICES_API char * FILESERVICES_CALL fsGetEspURL(const char *username, const char *userPW)
 {
+#ifdef _CONTAINERIZED
+    const char *defaultEsp = queryComponentConfig().queryProp("@defaultEsp");
+    if (!defaultEsp)
+        defaultEsp = queryGlobalConfig().queryProp("@defaultEsp");
+    if (defaultEsp)
+    {
+        StringBuffer credentials;
+        if (username && username[0] && userPW && userPW[0])
+            credentials.setf("%s:%s@", username, userPW);
+        else if (username && username[0])
+            credentials.setf("%s@", username);
+
+        // MORE - do we want to make such things as port and protocol configurable?
+        VStringBuffer espURL("http://%s%s:8010", credentials.str(), defaultEsp);
+        return espURL.detach();
+    }
+#else
     Owned<IConstEnvironment> daliEnv = openDaliEnvironment();
     Owned<IPropertyTree> env = getEnvironmentTree(daliEnv);
 
@@ -2858,6 +2875,7 @@ FILESERVICES_API char * FILESERVICES_CALL fsGetEspURL(const char *username, cons
             }
         }
     }
+#endif
     return strdup("");
 }