Skip to content

Commit

Permalink
Chore: version log change (#7401)
Browse files Browse the repository at this point in the history
  • Loading branch information
edibble21 authored Nov 21, 2024
1 parent bbb4996 commit 83f7c74
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/providers/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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")
if p.cm.HasChanged("kubernetes-version", version) || p.cm.HasChanged("version-source", versionSource) {
log.FromContext(ctx).WithValues("version", version, "source", versionSource).V(1).Info("discovered kubernetes version")
if err := validateK8sVersion(version); err != nil {
log.FromContext(ctx).Error(err, "failed validating kubernetes version")
}
Expand Down

0 comments on commit 83f7c74

Please sign in to comment.