Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configAPI: Implement waitForPodsReady validations #2214

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ apiVersion: config.kueue.x-k8s.io/v1beta1
kind: Configuration
waitForPodsReady:
enable: true
timeout: 50s
Copy link
Contributor

Choose a reason for hiding this comment

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

nit question: any reason for changes in this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

I modified this test data because there are no test cases to verify if overrided parameters are propagated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sgtm, I see this is what we do also for other fields

Copy link
Member Author

Choose a reason for hiding this comment

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

That's right. Maybe we forgot to add these fields here when we extend waitForPodsReadt feature :)

blockAdmission: false
requeuingStrategy:
timestamp: Creation
backoffLimitCount: 10
backoffBaseSeconds: 30
`), os.FileMode(0600)); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -547,12 +550,12 @@ multiKueue:
InternalCertManagement: enableDefaultInternalCertManagement,
WaitForPodsReady: &configapi.WaitForPodsReady{
Enable: true,
BlockAdmission: ptr.To(true),
Timeout: &metav1.Duration{Duration: 5 * time.Minute},
BlockAdmission: ptr.To(false),
Timeout: &metav1.Duration{Duration: 50 * time.Second},
RequeuingStrategy: &configapi.RequeuingStrategy{
Timestamp: ptr.To(configapi.CreationTimestamp),
BackoffLimitCount: ptr.To[int32](10),
BackoffBaseSeconds: ptr.To[int32](10),
BackoffBaseSeconds: ptr.To[int32](30),
},
},
ClientConnection: defaultClientConnection,
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func validateWaitForPodsReady(c *configapi.Configuration) field.ErrorList {
if !WaitForPodsReadyIsEnabled(c) {
return allErrs
}
if c.WaitForPodsReady.Timeout != nil && c.WaitForPodsReady.Timeout.Duration < 0 {
allErrs = append(allErrs, field.Invalid(waitForPodsReadyPath.Child("timeout"),
c.WaitForPodsReady.Timeout, constants.IsNegativeErrorMsg))
}
if strategy := c.WaitForPodsReady.RequeuingStrategy; strategy != nil {
if strategy.Timestamp != nil &&
*strategy.Timestamp != configapi.CreationTimestamp && *strategy.Timestamp != configapi.EvictionTimestamp {
Expand Down
24 changes: 17 additions & 7 deletions pkg/config/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,29 +324,39 @@ func TestValidate(t *testing.T) {
},
},
},
"supported waitForPodsReady.requeuingStrategy.timestamp": {
"negative waitForPodsReady.timeout": {
cfg: &configapi.Configuration{
Integrations: defaultIntegrations,
WaitForPodsReady: &configapi.WaitForPodsReady{
Enable: true,
RequeuingStrategy: &configapi.RequeuingStrategy{
Timestamp: ptr.To(configapi.CreationTimestamp),
Timeout: &metav1.Duration{
Duration: -1,
},
},
},
wantErr: nil,
wantErr: field.ErrorList{
&field.Error{
Type: field.ErrorTypeInvalid,
Field: "waitForPodsReady.timeout",
},
},
},
"non-negative waitForPodsReady.requeuingStrategy.backoffLimitCount": {
"valid waitForPodsReady": {
cfg: &configapi.Configuration{
Integrations: defaultIntegrations,
WaitForPodsReady: &configapi.WaitForPodsReady{
Enable: true,
Timeout: &metav1.Duration{
Duration: 50,
},
BlockAdmission: ptr.To(false),
RequeuingStrategy: &configapi.RequeuingStrategy{
BackoffLimitCount: ptr.To[int32](10),
Timestamp: ptr.To(configapi.CreationTimestamp),
BackoffLimitCount: ptr.To[int32](10),
BackoffBaseSeconds: ptr.To[int32](30),
},
},
},
wantErr: nil,
},
"negative waitForPodsReady.requeuingStrategy.backoffLimitCount": {
cfg: &configapi.Configuration{
Expand Down