sillsdev / TheCombine

This is a tool for supporting the rapid word collection workshop and post workshop clean-up
https://sillsdev.github.io/TheCombine/
MIT License
16 stars 13 forks source link

[setup_cluster] `--type development` errors without HONEYCOMB_API_KEY #3409

Open imnasnainaec opened 1 day ago

imnasnainaec commented 1 day ago

If the environment variable HONEYCOMB_API_KEY is not set, then

(venv) $ python deploy/scripts/setup_cluster.py --type development

fails:

Traceback (most recent call last):
  File "[...]/TheCombine/deploy/scripts/setup_cluster.py", line 185, in <module>
    main()
  File "[...]/TheCombine/deploy/scripts/setup_cluster.py", line 170, in main
    helm_cmd.append(arg.format(**os.environ))
                    ^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'HONEYCOMB_API_KEY'

because deploy/scripts/setup_files/cluster_config.yaml has

    additional_args:
      - --values
      - "{SCRIPTS_DIR}/setup_files/collector_config.yaml"
      - --set
      - config.exporters.otlp.headers.x-honeycomb-team={HONEYCOMB_API_KEY}

We need to allow for that environment variable to be undefined, so that devs can work on a local Docker/Kubernetes deployment without having the analytics secret key.

imnasnainaec commented 1 day ago

A solution would be in deploy/scripts/setup_files/cluster_config.yaml to add:

    # Add an empty analytics key if not defined in the OS Environment variables
    if "HONEYCOMB_API_KEY" not in os.environ:
        os.environ["HONEYCOMB_API_KEY"] = ""

in an appropriate place before the line helm_cmd.append(arg.format(**os.environ)).

However, there might be a better, more general solution.