open-horizon / anax

Horizon agent control system
https://open-horizon.github.io/docs/anax/docs/
Apache License 2.0
72 stars 98 forks source link

Bug: agent-install.sh breaks on some k8s environments when when looking for HZN_NAMESPACE_SCOPED env variable #3944

Open dlarson04 opened 9 months ago

dlarson04 commented 9 months ago

Describe the bug.

agent-install.sh runs a command

kubectl get deployment agent -n mesh-ns01 -o 'jsonpath={.spec.template.spec.containers[0].env}'

to check for an environment variable. The script is expecting json as an output but my environment returns

# kubectl get deployment agent -n mesh-ns01 -o 'jsonpath={.spec.template.spec.containers[0].env}'
[map[name:HZN_ORG_ID value:saasops] map[name:AGENT_NAMESPACE value:mesh-ns01] map[name:HZN_NAMESPACE_SCOPED value:true] map[name:AGENT_CLUSTER_IMAGE_REGISTRY_HOST value:__ImageRegistryHost__] map[name:HZN_MGMT_HUB_CERT_PATH value:/etc/default/cert/agent-install.crt]]

that is not json

so the next part of the that script

 jq -r '.[] | select(.name=="HZN_NAMESPACE_SCOPED").value'

fails.

I changed it to

             local namespace_scoped_env_value_in_use=$($KUBECTL get deployment agent -n ${namespace_to_check} -o json | jq '.spec.template.spec.containers[0].env' | jq -r '.[] | select(.name=="HZN_NAMESPACE_SCOPED").value')

and that worked...

Describe the steps to reproduce the behavior.

No response

Expected behavior.

No response

Screenshots.

No response

Operating Environment

Linux

Additional Information

No response