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

WaitForReady should check for event type before trying to read generation number #1389

Closed
cardil opened this issue Jul 19, 2021 · 2 comments · Fixed by #1390
Closed

WaitForReady should check for event type before trying to read generation number #1389

cardil opened this issue Jul 19, 2021 · 2 comments · Fixed by #1390
Assignees
Labels
good first issue Denotes an issue ready for a new contributor. kind/bug Categorizes issue or PR as related to a bug.

Comments

@cardil
Copy link
Contributor

cardil commented Jul 19, 2021

Bug report

The code at location supplied behaves badly in a situation when it receives an event of type different from MODIFIED, in which the underlying object doesn't contain a status field yet.

That situation is completely normal, as ADDED event can be received first, and the resource at that point may not possess a status field yet.

// 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
// the initial state. See https://kubernetes.io/docs/reference/using-api/api-concepts/#the-resourceversion-parameter
// for details:
// "Get State and Start at Most Recent: Start a watch at the most recent resource version,
// which must be consistent (i.e. served from etcd via a quorum read). To establish initial state,
// the watch begins with synthetic “Added” events of all resources instances that exist at the starting
// resource version. All following watch events are for all changes that occurred after the resource
// version the watch started at."
if event.Type != watch.Modified {
continue
}

Such situation I've observed while developing wait on ready based on dynamic client at knative-extensions/kn-plugin-event#38

The actual error that is being returned is similar to:

cannot extract status from &{map[metadata:map[creationTimestamp:<nil> generation:1 name:test-service] spec:map[template:map[metadata:map[creationTimestamp:<nil>] spec:map[containers:<nil>]]]]}

Expected behavior

When WaitForReady receives an event of type different from MODIFIED, it should skip it first, before checking anything in the underlying object structure.

Steps to reproduce the problem

cardil@7ca0769

Knative (serving/eventing) version

Nightly
0.24

@cardil
Copy link
Contributor Author

cardil commented Jul 19, 2021

/kind bug
/kind good-first-issue

@knative-prow-robot knative-prow-robot added kind/bug Categorizes issue or PR as related to a bug. good first issue Denotes an issue ready for a new contributor. labels Jul 19, 2021
@cardil
Copy link
Contributor Author

cardil commented Jul 19, 2021

/assign

cardil added a commit to cardil/knative-client that referenced this issue Jul 19, 2021
cardil added a commit to cardil/knative-client that referenced this issue Jul 19, 2021
cardil added a commit to cardil/knative-client that referenced this issue Jul 19, 2021
@cardil cardil changed the title WaitForReady should chack for event type before trying to check generation number WaitForReady should check for event type before trying to read generation number Jul 19, 2021
cardil added a commit to cardil/kn-plugin-event that referenced this issue Jul 19, 2021
knative-prow-robot pushed a commit that referenced this issue Jul 21, 2021
* Reproduction of #1389

* Fixing #1389

* Removal of panic in test

* Cover the "impossible" missing generation case
knative-prow-robot pushed a commit to knative-extensions/kn-plugin-event that referenced this issue Jul 22, 2021
* Fixing the addressable resolver

* Properly working address resolver

* Working fake & it tests (apart those affected by knative/client#1389)

* Upgrade to latest knative

* Use interim fork until merge of knative/client#1390

* Allow addressable URI to be empty, and by default

* Remove interim personal fork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants