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

Skip non modified event first while waiting for ready #1390

Merged
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
17 changes: 11 additions & 6 deletions pkg/wait/test_wait_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ package wait
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"knative.dev/pkg/apis"
duck "knative.dev/pkg/apis/duck/v1"
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
)

Expand Down Expand Up @@ -63,8 +61,15 @@ func (f *FakeWatch) fireEvents() {
}
}

// Create a service skeleton with a given ConditionReady status and all other statuses set to otherReadyStatus. Optionally a single generation can be added.
func CreateTestServiceWithConditions(name string, readyStatus corev1.ConditionStatus, otherReadyStatus corev1.ConditionStatus, reason string, message string, generations ...int64) runtime.Object {
// CreateTestServiceWithConditions create a service skeleton with a given
// ConditionReady status and all other statuses set to otherReadyStatus.
// Optionally a single generation can be added.
func CreateTestServiceWithConditions(
name string,
readyStatus, otherReadyStatus corev1.ConditionStatus,
reason, message string,
generations ...int64,
) *servingv1.Service {
service := servingv1.Service{ObjectMeta: metav1.ObjectMeta{Name: name}}
if len(generations) == 2 {
service.Generation = generations[0]
Expand All @@ -73,10 +78,10 @@ func CreateTestServiceWithConditions(name string, readyStatus corev1.ConditionSt
service.Generation = 1
service.Status.ObservedGeneration = 1
}
service.Status.Conditions = duck.Conditions([]apis.Condition{
service.Status.Conditions = []apis.Condition{
{Type: "RoutesReady", Status: otherReadyStatus},
{Type: apis.ConditionReady, Status: readyStatus, Reason: reason, Message: message},
{Type: "ConfigurationsReady", Status: otherReadyStatus},
})
}
return &service
}
24 changes: 12 additions & 12 deletions pkg/wait/wait_for_ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,6 @@ func (w *waitForReadyConfig) waitForReadyCondition(ctx context.Context, name str
return true, false, nil
}

// Check whether resource is in sync already (meta.generation == status.observedGeneration)
inSync, err := generationCheck(event.Object)
if err != nil {
return false, false, err
}

// Skip events if generations has not yet been consolidated, regardless of type.
// Wait for the next event to come in until the generations align
if !inSync {
continue
}

// Skip event if its not a MODIFIED event, as only MODIFIED events update the condition
// we are looking for.
// This will filter out all synthetic ADDED events that created bt the API server for
Expand All @@ -206,6 +194,18 @@ func (w *waitForReadyConfig) waitForReadyCondition(ctx context.Context, name str
continue
}

// Check whether resource is in sync already (meta.generation == status.observedGeneration)
inSync, err := generationCheck(event.Object)
if err != nil {
return false, false, err
}

// Skip events if generations has not yet been consolidated, regardless of type.
// Wait for the next event to come in until the generations align
if !inSync {
continue
}

conditions, err := w.conditionsExtractor(event.Object)
if err != nil {
return false, false, err
Expand Down
Loading