Issue
A Kubernetes job responsible for indexing Bloomberg articles failed during startup due to an environment variable mismatch. The job crashed immediately with the error AZURE_OPENAI_API_KEY environment variable not set, despite the secret containing the correct key-value pair. This prevented the processing of Bloomberg articles and blocked the indexing pipeline.
Culprit
The issue stemmed from inconsistent naming across three components:
- Kubernetes Secret: Correctly stored the key as
AZURE_OPENAI_API_KEY. - Job YAML: Incorrectly referenced the environment variable as
AZURE_OPENAI_KEY(missing the_API_segment). - Python Script: Correctly validated for
AZURE_OPENAI_API_KEY.
This mismatch occurred because the job YAML was initially created with a shorter variable name, but the secret was later standardized to include _API_ for clarity. The script validation was updated to match the secret, but the job YAML was never updated to reflect this change.
Solution
Naming Alignment
Updated the job YAML to ensure consistency across all components:
- Job Configuration: Changed the environment variable name from
AZURE_OPENAI_KEYtoAZURE_OPENAI_API_KEYto match the secret and script. - Security: No secret values were exposed or modified; only the reference name was corrected.
Prevention Measures
- Standardized Naming: Added standardized environment variable names to a reference file (e.g.,
.env.example) to ensure consistency. - Validation Checklist: Created a checklist for new secrets to ensure that the secret key name, deployment/Job environment variable name, and code references all match exactly.
Technical Impact
- Validation: The script’s environment variable validation now receives the expected value.
- Compatibility: The change maintains backward compatibility with existing secret structures.
This fix resolved the job failure and ensured that all components use consistent environment variable naming conventions.