nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: numaproj/numaflow
Pull request #1500 (2024-02-12 05:27:12)

chore: scale.max can not be 0
Explain what this PR does.

<!--

Before you push your changes:

* Run `make pre-push -B` to fix codegen and lint problems.

Then, you MUST:

* Sign-off your commit (otherwise the DCO check will fail).
* Use [a conventional commit message](https://www.conventionalcommits.org/en/v1.0.0/) (otherwise the commit message check will fail).

If you did not do this, reset all your commit and replace them with a single commit:

```
git reset HEAD~1 ;# change 1 to how many commits you made
git commit --signoff -m 'feat: my feat. Fixes #1234'
```

When creating your PR: 

* Make sure that "Fixes #" or "Closes #" is in both the PR title (for release notes) and description (to automatically link and close the issue).
* Say how you tested your changes. If you changed the UI, attach screenshots.
* Set your PR as a draft initially.
* Your PR needs to pass the required checks before it can be approved. 
* Once required tests have passed, mark your PR "Ready for review".

If changes were requested, once you've made them, you MUST dismiss the review to get it reviewed again.

-->



Patch:
diff --git a/pkg/reconciler/pipeline/validate.go b/pkg/reconciler/pipeline/validate.go
index d0c1d707..80bcb96f 100644
--- a/pkg/reconciler/pipeline/validate.go
+++ b/pkg/reconciler/pipeline/validate.go
@@ -242,6 +242,9 @@ func validateVertex(v dfv1.AbstractVertex) error {
 	if min > max {
 		return fmt.Errorf("vertex %q: max number of replicas should be greater than or equal to min", v.Name)
 	}
+	if max == 0 {
+		return fmt.Errorf("vertex %q: max number of replicas can not be 0", v.Name)
+	}
 	if v.Partitions != nil {
 		if *v.Partitions < 0 {
 			return fmt.Errorf("vertex %q: number of partitions should not be smaller than 0", v.Name)


Test patch:
diff --git a/pkg/reconciler/pipeline/validate_test.go b/pkg/reconciler/pipeline/validate_test.go
index 7de84d32..bbdb6578 100644
--- a/pkg/reconciler/pipeline/validate_test.go
+++ b/pkg/reconciler/pipeline/validate_test.go
@@ -627,6 +627,18 @@ func TestValidateVertex(t *testing.T) {
 		assert.Contains(t, err.Error(), "or equal to")
 	})
 
+	t.Run("max == 0", func(t *testing.T) {
+		v := dfv1.AbstractVertex{
+			Name: "my-vertex",
+			Scale: dfv1.Scale{
+				Max: pointer.Int32(0),
+			},
+		}
+		err := validateVertex(v)
+		assert.Error(t, err)
+		assert.Contains(t, err.Error(), "can not be 0")
+	})
+
 	t.Run("good init container", func(t *testing.T) {
 		v := dfv1.AbstractVertex{Name: "my-vertex", InitContainers: goodContainers}
 		err := validateVertex(v)