Skip to content

Conversation

@osmman
Copy link
Collaborator

@osmman osmman commented Jun 30, 2025

Summary by Sourcery

Extend the TUF and Securesign APIs with new PodRequirements fields (affinity, tolerations, resources, replicas), enforce validation on scaling, update the deployment controller to apply these settings, and surface them in the operator’s UI via CSV descriptors.

New Features:

  • Allow setting affinity, tolerations, resource requirements, and replica count in TUF and Securesign CRDs

Enhancements:

  • Embed PodRequirements in TufSpec and SecuresignSpec with XValidation to enforce ReadWriteMany PVC access mode when scaling beyond one replica
  • Propagate PodRequirements into the TUF deployment so custom scheduling and sizing options take effect

Build:

  • Include tuf_descriptors.yaml patch and update kustomization to add UI descriptors for affinity, resources, and replicas in the CSV

Tests:

  • Add unit tests to validate replica counts and PVC access mode requirements

@sourcery-ai
Copy link

sourcery-ai bot commented Jun 30, 2025

Reviewer's Guide

This PR extends the TUF component by introducing a generic PodRequirements abstraction—comprising affinity rules, tolerations, resource constraints, and replica settings—across CRD schemas, Go API types, controller deployment logic, OLM UI descriptors, and validation rules, backed by new unit tests.

ER diagram for new PodRequirements fields in Tuf CRD

erDiagram
    TUF_SPEC ||--o{ POD_REQUIREMENTS : inlines
    POD_REQUIREMENTS ||--o| AFFINITY : has
    POD_REQUIREMENTS ||--o{ TOLERATION : has
    POD_REQUIREMENTS ||--o| RESOURCE_REQUIREMENTS : has
    POD_REQUIREMENTS {
        int replicas
    }
    AFFINITY {
        NodeAffinity nodeAffinity
        PodAffinity podAffinity
        PodAntiAffinity podAntiAffinity
    }
    TOLERATION {
        string key
        string operator
        string value
        string effect
        int tolerationSeconds
    }
    RESOURCE_REQUIREMENTS {
        map limits
        map requests
        ResourceClaim[] claims
    }
Loading

Class diagram for extended TufSpec with PodRequirements

classDiagram
    class TufSpec {
        +PodRequirements (inlined)
        +ExternalAccess externalAccess
        +int port
        +[]Key keys
        +TufPvc pvc
        +RootKeySecretRef rootKeySecretRef
        +string image
        +string serviceAccountName
    }
    class PodRequirements {
        +Affinity affinity
        +[]Toleration tolerations
        +ResourceRequirements resources
        +int replicas
    }
    class Affinity {
        +NodeAffinity nodeAffinity
        +PodAffinity podAffinity
        +PodAntiAffinity podAntiAffinity
    }
    class Toleration {
        +string key
        +string operator
        +string value
        +string effect
        +int tolerationSeconds
    }
    class ResourceRequirements {
        +map~string, any~ limits
        +map~string, any~ requests
        +[]ResourceClaim claims
    }
    TufSpec --|> PodRequirements : inlined
    PodRequirements o-- Affinity
    PodRequirements o-- Toleration
    PodRequirements o-- ResourceRequirements
    Affinity o-- NodeAffinity
    Affinity o-- PodAffinity
    Affinity o-- PodAntiAffinity
    ResourceRequirements o-- ResourceClaim
Loading

File-Level Changes

Change Details Files
Extend CRD definitions with PodRequirements fields
  • Added affinity properties including nodeAffinity, podAffinity, and podAntiAffinity
  • Introduced replicas field with default value, minimum constraint, and XValidation rule
  • Defined resources (requests, limits, resource claims) and tolerations sections
  • Added cross-field validation for replica count versus PVC accessModes
config/crd/bases/rhtas.redhat.com_securesigns.yaml
config/crd/bases/rhtas.redhat.com_tufs.yaml
Embed PodRequirements in Go API types and add validation annotations
  • Inlined PodRequirements struct into TufSpec
  • Added XValidation annotations on Tuf and Securesign specs
  • Updated deepcopy generation to include PodRequirements
api/v1alpha1/tuf_types.go
api/v1alpha1/securesign_types.go
api/v1alpha1/zz_generated.deepcopy.go
Integrate PodRequirements into controller deployment logic
  • Removed hardcoded default replica assignment
  • Integrated deployment.PodRequirements helper in ensure call
  • Cleaned up unused utils import
internal/controller/tuf/actions/deployment.go
Expose PodRequirements fields in OLM UI descriptors
  • Created tuf_descriptors.yaml patch for replicas, resources, and affinity descriptors
  • Updated kustomization.yaml to include the new patch
config/manifests/kustomization.yaml
config/manifests/patches/tuf_descriptors.yaml
Add unit tests covering replica behavior and validations
  • Added test cases for nil, zero, negative, and positive replicas
  • Confirmed validation error when replicas>1 without ReadWriteMany PVC mode
  • Verified successful creation for valid ReadWriteMany configurations
api/v1alpha1/tuf_types_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@red-hat-konflux
Copy link
Contributor

red-hat-konflux bot commented Jun 30, 2025

Caution

There are some errors in your PipelineRun template.

PipelineRun Error
operator no kind "Project" is registered for version "projctl.konflux.dev/v1beta1" in scheme "k8s.io/client-go/kubernetes/scheme/register.go:83"
operator-template no kind "ProjectDevelopmentStreamTemplate" is registered for version "projctl.konflux.dev/v1beta1" in scheme "k8s.io/client-go/kubernetes/scheme/register.go:83"
operator-v1-0 no kind "ProjectDevelopmentStream" is registered for version "projctl.konflux.dev/v1beta1" in scheme "k8s.io/client-go/kubernetes/scheme/register.go:83"

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @osmman - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@osmman osmman force-pushed the tturek/tuf-pod-requirements branch from 5f11fd7 to 8067c01 Compare June 30, 2025 16:02
Signed-off-by: Tomas Turek <tturek@redhat.com>
@osmman osmman force-pushed the tturek/tuf-pod-requirements branch from 8067c01 to 92cc34c Compare June 30, 2025 16:13
@osmman osmman requested a review from JasonPowr July 1, 2025 07:47
@osmman osmman merged commit d8b3f63 into main Jul 1, 2025
27 of 28 checks passed
@osmman osmman deleted the tturek/tuf-pod-requirements branch July 1, 2025 13:23
@osmman osmman added the enhancement New feature or request label Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants