From 2de333fdd3d5f5856d395aadd61b265e6f510113 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 13 Jun 2023 10:29:22 +0200 Subject: [PATCH] check history api support once Signed-off-by: CrazyMax --- driver/manager.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/driver/manager.go b/driver/manager.go index 6d798974..657e5094 100644 --- a/driver/manager.go +++ b/driver/manager.go @@ -147,11 +147,13 @@ func GetFactories(instanceRequired bool) []Factory { type DriverHandle struct { Driver - client *client.Client - err error - once sync.Once - featuresOnce sync.Once - features map[Feature]bool + client *client.Client + err error + once sync.Once + featuresOnce sync.Once + features map[Feature]bool + historyAPISupportedOnce sync.Once + historyAPISupported bool } func (d *DriverHandle) Client(ctx context.Context) (*client.Client, error) { @@ -169,9 +171,10 @@ func (d *DriverHandle) Features(ctx context.Context) map[Feature]bool { } func (d *DriverHandle) HistoryAPISupported(ctx context.Context) bool { - client, err := d.Client(ctx) - if err != nil { - return false - } - return historyAPISupported(ctx, client) + d.historyAPISupportedOnce.Do(func() { + if c, err := d.Client(ctx); err == nil { + d.historyAPISupported = historyAPISupported(ctx, c) + } + }) + return d.historyAPISupported }