diff --git a/.github/workflows/crd-validation.yml b/.github/workflows/crd-validation.yml index f43e4b7d8..b674bde65 100644 --- a/.github/workflows/crd-validation.yml +++ b/.github/workflows/crd-validation.yml @@ -2,14 +2,28 @@ name: CRD Validation on: pull_request: - types: [opened, edited, synchronize, reopened] + types: [opened, edited, synchronize, reopened, labeled, unlabeled] permissions: contents: read + pull-requests: write jobs: + ack-breaking-changes: + name: Ack Breaking Changes Labeler + if: github.event.issue.pull_request && contains(github.event.comment.body, '/ack-breaking-changes') + runs-on: ubuntu-latest + steps: + - name: Add Label + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr edit ${{ github.event.issue.number }} --add-label "ack-breaking-changes" + echo "✅ Added 'ack-breaking-changes' label based on comment." + crd-validation: name: CRD Validation Check + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - name: Checkout code @@ -28,7 +42,17 @@ jobs: run: | go install sigs.k8s.io/crdify@latest + - name: Reset Validation Approval + if: github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ack-breaking-changes') + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr edit ${{ github.event.pull_request.number }} --remove-label "ack-breaking-changes" + echo "⚠️ Removed 'ack-breaking-changes' label due to new changes. Re-approval required." + - name: Run CRD Validation Check + env: + ALLOW_BREAKING: ${{ contains(github.event.pull_request.labels.*.name, 'ack-breaking-changes') && github.event.action != 'synchronize' }} run: | git fetch origin ${{ github.base_ref }}:upstream_base BASE_SHA=$(git rev-parse upstream_base) @@ -37,15 +61,21 @@ jobs: for crd in config/crd/bases/*.yaml; do if ! crdify "git://${BASE_SHA}?path=$crd" "git://HEAD?path=$crd"; then echo "❌ Incompatible change detected in $crd" - ((FAILED++)) + FAILED=$((FAILED + 1)) else echo "✅ $crd is valid" fi done if [ "$FAILED" -gt 0 ]; then - echo "::error::Validation failed! Found $FAILED incompatible CRD change(s)." - exit 1 + if [[ "$ALLOW_BREAKING" == "true" ]]; then + echo "⚠️ Validation failed with $FAILED incompatible change(s), but allowed via 'ack-breaking-changes' label." + exit 0 + else + echo "❌ error: Validation failed! Found $FAILED incompatible CRD change(s)." + echo "⚠️ notice: To allow these changes, a reviewer must add the 'ack-breaking-changes' label to the PR." + exit 1 + fi fi - echo "All CRDs are compatible." + echo "All CRDs are compatible." \ No newline at end of file diff --git a/apix/v1alpha2/inferencemodelrewrite_types.go b/apix/v1alpha2/inferencemodelrewrite_types.go index ef68d8366..a7a4f532c 100644 --- a/apix/v1alpha2/inferencemodelrewrite_types.go +++ b/apix/v1alpha2/inferencemodelrewrite_types.go @@ -87,7 +87,7 @@ type InferenceModelRewriteRule struct { // +optional // +kubebuilder:validation:MinItems=1 // - Targets []TargetModel `json:"split,omitempty"` + Targets []TargetModel `json:"targets,omitempty"` } // TargetModel defines a weighted model destination for traffic distribution. diff --git a/client-go/applyconfiguration/apix/v1alpha2/inferencemodelrewriterule.go b/client-go/applyconfiguration/apix/v1alpha2/inferencemodelrewriterule.go index 7e03c192d..80a69a83e 100644 --- a/client-go/applyconfiguration/apix/v1alpha2/inferencemodelrewriterule.go +++ b/client-go/applyconfiguration/apix/v1alpha2/inferencemodelrewriterule.go @@ -22,7 +22,7 @@ package v1alpha2 // with apply. type InferenceModelRewriteRuleApplyConfiguration struct { Matches []MatchApplyConfiguration `json:"matches,omitempty"` - Targets []TargetModelApplyConfiguration `json:"split,omitempty"` + Targets []TargetModelApplyConfiguration `json:"targets,omitempty"` } // InferenceModelRewriteRuleApplyConfiguration constructs a declarative configuration of the InferenceModelRewriteRule type for use with diff --git a/config/crd/bases/inference.networking.x-k8s.io_inferencemodelrewrites.yaml b/config/crd/bases/inference.networking.x-k8s.io_inferencemodelrewrites.yaml index bb9b3e6cf..2146d4388 100644 --- a/config/crd/bases/inference.networking.x-k8s.io_inferencemodelrewrites.yaml +++ b/config/crd/bases/inference.networking.x-k8s.io_inferencemodelrewrites.yaml @@ -110,7 +110,7 @@ spec: - model type: object type: array - split: + targets: items: description: TargetModel defines a weighted model destination for traffic distribution.