Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: version log change #7401

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If our version source changes, should we also add a log here?

log.FromContext(ctx).WithValues("version", version).V(1).Info("discovered kubernetes version")
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")
}
Expand Down
Loading