zowe / zss

Zowe System Services Server for enabling low-level microservices
Eclipse Public License 2.0
13 stars 45 forks source link

ZSS does not respect HA config #737

Open 1000TurquoisePogs opened 2 weeks ago

1000TurquoisePogs commented 2 weeks ago

Consider the following config:

components:
  zss:
    port: 123

haInstances:
  first:
    components:
      zss:
        port: 456
  second:
    components:
      zss:
        port: 567

cfgGet functions such as here https://github.com/zowe/zss/blob/940ad1a5f111f4ade0061a9f810c908029e13801/c/zss.c#L1124

Do not check for HA. They just read the section they want, without considering the haInstances is an override.

In other servers, the haInstances section is respected by having the env vars they read be the result of a merge of haInstances over the standard config.

I expect that cfgGet functions should do the right thing rather than rely upon developers to remember this rule. So, I think something should be doing this merge prior to zss reading values.

To apply an ha override, you must know the ha instance name. That is captured as $ZWE_haInstance_id

I suggest a solution in zwe to create a file which has the HA override done, and place that in workspace/.env There are other such HA-overridden temp files there in .env and .json format, but not for .yaml Provided we have one, then zss can use it instead of the current ".zowe-merged.yaml" file which leaves the haInst as-is.

1000TurquoisePogs commented 2 weeks ago

I do not see a way to make configmgr functions be the writer of the HA yaml. They appear to function upon files, whereas the yaml that needs to be created is done by edits of a javascript object derived from the yaml on disk. There would need to be a way to load configmgr via string rather than file.

In absense of that, I find the yaml library on npm works in quickjs and can do yaml writes. It however would bypass configmgr to do so, so such a library should not be widely used to avoid misuse.