Skip to content

API Improvements: Strong typing, Secret management, and Storage definitions #10

@xflops-bot

Description

@xflops-bot

Overview

Follow-up from PR #7 code review feedback. These are breaking API changes that were deferred from the initial implementation to manage risk properly.

Background

PR #7 implemented the initial FlameCluster CRD. During code review, architectural improvements were identified that require API structural changes. These have been deferred to this follow-up issue to:

  • Avoid breaking changes in the initial release
  • Allow proper design and migration planning
  • Bundle related changes together

Improvements

1. Strong Typing for Resources (Slot)

Current: SessionManagerSpec.Slot is a string ("cpu=1,mem=1g")
Proposed: Use dedicated struct with resource.Quantity fields

type SlotSpec struct {
    CPU    resource.Quantity `json:"cpu,omitempty"`
    Memory resource.Quantity `json:"memory,omitempty"`
    GPU    resource.Quantity `json:"gpu,omitempty"`
}

Benefits:

  • Standard K8s unit handling
  • Free validation
  • No custom parsing required

2. Secret Management (Storage)

Current: SessionManagerSpec.Storage accepts raw connection string
Proposed: Use SecretKeySelector for credentials

type StorageConfig struct {
    Type      string                    `json:"type"`
    SecretRef *corev1.SecretKeySelector `json:"secretRef,omitempty"`
    Path      string                    `json:"path,omitempty"`
}

Benefits:

  • No credentials exposed in CRD
  • Standard K8s Secret integration
  • Security best practice

⚠️ Security Note: Until this is implemented, users should be aware that storage connection strings are stored in plain text in the CRD.

3. Storage Definition Clarity (ObjectCache)

Current: ObjectCacheSpec.Storage is an ambiguous string
Proposed: Use corev1.VolumeSource for explicit storage configuration

VolumeSource corev1.VolumeSource `json:"volumeSource,omitempty"`

Benefits:

  • Clear semantics (EmptyDir vs PVC vs HostPath)
  • Standard K8s volume handling
  • Explicit persistence guarantees

4. Enum Validation Markers

Current: Shim and Policy are open strings
Proposed: Add kubebuilder validation markers

// +kubebuilder:validation:Enum=host;docker;kubernetes
Shim string `json:"shim,omitempty"`

// +kubebuilder:validation:Enum=priority;fifo;fair
Policy string `json:"policy,omitempty"`

Note: Requires confirmation of supported values.

Acceptance Criteria

  • SlotSpec struct implemented with resource.Quantity
  • StorageConfig with SecretKeySelector implemented
  • ObjectCacheSpec.VolumeSource implemented
  • Enum validation markers added for Shim and Policy
  • Migration documentation for existing CRs (if any)
  • Updated examples in docs

Priority

Medium-High - The Secret management improvement is security-critical and should be prioritized.

Related

Metadata

Metadata

Assignees

No one assigned

    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