Skip to content

Add environment variable validation to PodCliqueSet webhook #240

@Ronkahn21

Description

@Ronkahn21

Context

Follow-up to #228. The PodCliqueSet webhook currently validates many aspects of the spec, but does not validate user-provided environment variables in the PodSpec.

Problem

Users can submit PodCliqueSet resources with:

  • Invalid environment variable names that don't conform to Kubernetes standards
  • Duplicate environment variable names within the same container

These issues aren't caught until runtime, potentially causing pod failures or unexpected behavior.

Proposed Solution

Extend the existing PCS validation webhook to validate environment variables in the PodSpec:

  1. Name format validation: Ensure env var names follow Kubernetes naming conventions:

    • Must consist of alphanumeric characters and underscores
    • Must start with a letter or underscore
    • Regex: ^[a-zA-Z_][a-zA-Z0-9_]*$
  2. Duplicate detection: Check for duplicate environment variable names within each container's env list

Acceptance Criteria

  • Webhook rejects PCS with invalid env var names (format validation)
  • Webhook rejects PCS with duplicate env var names in same container
  • Validation errors provide clear field paths and helpful messages
  • Unit tests cover all validation scenarios

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions