Merge pull request #105009 from harjas27/printer_event_count

kubectl: remove extra +1 for printing event count
This commit is contained in:
Kubernetes Prow Robot 2021-09-27 16:24:43 -07:00 committed by GitHub
commit ce4958d908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View File

@ -1786,11 +1786,7 @@ func printEvent(obj *api.Event, options printers.GenerateOptions) ([]metav1.Tabl
count := obj.Count
if obj.Series != nil {
lastTimestamp = translateMicroTimestampSince(obj.Series.LastObservedTime)
// When a series is created for the first time, its count is set to 1.
// However, for a series to be created, there needs to be an isomorphic
// singleton event created beforehand. This singleton event is not
// counted in the series count which is why one is added here.
count = obj.Series.Count + 1
count = obj.Series.Count
} else if count == 0 {
// Singleton events don't have a count set in the new API.
count = 1

View File

@ -222,7 +222,7 @@ func TestPrintEvent(t *testing.T) {
FieldPath: "spec.containers{foo}",
},
Series: &api.EventSeries{
Count: 1,
Count: 2,
LastObservedTime: metav1.MicroTime{Time: time.Now().UTC().AddDate(0, 0, -2)},
},
Reason: "Event Reason",