Skip to content

Commit

Permalink
Merge pull request vmware#2973 from yi0909/topic/yijiang/fix-task-rec…
Browse files Browse the repository at this point in the history
…ent-tasks

Fix: use latestPages in task HistoryCollector
  • Loading branch information
dougm committed Oct 17, 2022
2 parents 634e88f + 63980ff commit 5a40bd9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions task/history_collector.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015 VMware, Inc. All Rights Reserved.
Copyright (c) 2015-2022 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,12 +38,15 @@ func newHistoryCollector(c *vim25.Client, ref types.ManagedObjectReference) *His
}
}

// RecentTasks returns a list of task managed objects that completed recently,
// that are currently running, or that are queued to run.
func (h HistoryCollector) RecentTasks(ctx context.Context) ([]types.TaskInfo, error) {
// LatestPage returns items in the 'viewable latest page' of the task history collector.
// As new tasks that match the collector's TaskFilterSpec are created,
// they are added to this page, and the oldest tasks are removed from the collector to keep
// the size of the page to that allowed by SetCollectorPageSize.
// The "oldest task" is the one with the oldest creation time. The tasks in the returned page are unordered.
func (h HistoryCollector) LatestPage(ctx context.Context) ([]types.TaskInfo, error) {
var o mo.TaskHistoryCollector

err := h.Properties(ctx, h.Reference(), []string{"recentTask"}, &o)
err := h.Properties(ctx, h.Reference(), []string{"latestPage"}, &o)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 5a40bd9

Please sign in to comment.