From c8caab163da50bac4c6c912d8faa66b742d8c0fa Mon Sep 17 00:00:00 2001 From: edibble21 <85638465+edibble21@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:30:14 -0800 Subject: [PATCH 1/2] version log change --- pkg/providers/version/version.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/providers/version/version.go b/pkg/providers/version/version.go index afc0d9eb5ef0..78663c0153f0 100644 --- a/pkg/providers/version/version.go +++ b/pkg/providers/version/version.go @@ -70,6 +70,7 @@ func NewDefaultProvider(kubernetesInterface kubernetes.Interface, cache *cache.C func (p *DefaultProvider) Get(ctx context.Context) (string, error) { var version string + var versionSource string if version, ok := p.cache.Get(kubernetesVersionCacheKey); ok { return version.(string), nil } @@ -85,17 +86,17 @@ func (p *DefaultProvider) Get(ctx context.Context) (string, error) { return "", fmt.Errorf("getting kubernetes version from the kubernetes API") } else if output != nil { version = fmt.Sprintf("%s.%s", output.Major, strings.TrimSuffix(output.Minor, "+")) - log.FromContext(ctx).Info("retrieved Kubernetes version from Kubernetes API", "version", version) + versionSource = "Kubernetes API" } } else if lo.FromPtr(output.Cluster.Version) != "" { version = *output.Cluster.Version - log.FromContext(ctx).Info("retrieved Kubernetes version from EKS DescribeCluster", "version", version) + versionSource = "EKS DescribeCluster" } else { return "", fmt.Errorf("unable to retrieve Kubernetes version from EKS DescribeCluster") } p.cache.SetDefault(kubernetesVersionCacheKey, version) if p.cm.HasChanged("kubernetes-version", version) { - log.FromContext(ctx).WithValues("version", version).V(1).Info("discovered kubernetes version") + log.FromContext(ctx).WithValues("version", version).V(1).Info("discovered kubernetes version from" + versionSource) if err := validateK8sVersion(version); err != nil { log.FromContext(ctx).Error(err, "failed validating kubernetes version") } From 24eb666d9cc8bf57fac4fb523b94ccb6026fc68e Mon Sep 17 00:00:00 2001 From: edibble21 <85638465+edibble21@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:57:19 -0800 Subject: [PATCH 2/2] Addressed Feedback --- pkg/providers/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/providers/version/version.go b/pkg/providers/version/version.go index 78663c0153f0..b85255e8dcc9 100644 --- a/pkg/providers/version/version.go +++ b/pkg/providers/version/version.go @@ -96,7 +96,7 @@ func (p *DefaultProvider) Get(ctx context.Context) (string, error) { } p.cache.SetDefault(kubernetesVersionCacheKey, version) if p.cm.HasChanged("kubernetes-version", version) { - log.FromContext(ctx).WithValues("version", version).V(1).Info("discovered kubernetes version from" + versionSource) + log.FromContext(ctx).WithValues("version", version).V(1).Info(fmt.Sprintf("discovered kubernetes version from %s", versionSource)) if err := validateK8sVersion(version); err != nil { log.FromContext(ctx).Error(err, "failed validating kubernetes version") }