-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
vpa-recommender: Log object's namespace #6909
vpa-recommender: Log object's namespace #6909
Conversation
Not a maintainer: but this PR looks good to me. I think the additional namespaces will help in the logs. |
Does it make sense to add a change log entry for this? I think it's useful for users to know that logs have improved if this lands. |
Done. |
Sorry, I can't approve, I'm not an approver for the project. Just someone trying to get involved. |
@@ -359,7 +359,7 @@ func (feeder *clusterStateFeeder) LoadVPAs() { | |||
} | |||
|
|||
selector, conditions := feeder.getSelector(vpaCRD) | |||
klog.V(4).Infof("Using selector %s for VPA %s/%s", selector.String(), vpaCRD.Namespace, vpaCRD.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some lines above you added that they are namespace/name. Is there a specific rule when to print namespacedName vs. the whole resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not printing the whole resource. As explained in #6909 (comment) klog.KObj
only prints <namespace>/<name>
.
If you are asking why in some places we use klog.KObj
and in some places we have to use %s/%s
and pass the namespace and name: KObj
accepts the interface KMetadata
:
autoscaler/vertical-pod-autoscaler/vendor/k8s.io/klog/v2/k8s_references.go
Lines 72 to 75 in f03e98f
type KMetadata interface { | |
GetName() string | |
GetNamespace() string | |
} |
autoscaler/vertical-pod-autoscaler/pkg/recommender/model/types.go
Lines 160 to 163 in 8bc327e
type VpaID struct { | |
Namespace string | |
VpaName string | |
} |
autoscaler/vertical-pod-autoscaler/pkg/recommender/model/types.go
Lines 144 to 150 in 8bc327e
// PodID contains information needed to identify a Pod within a cluster. | |
type PodID struct { | |
// Namespaces where the Pod is defined. | |
Namespace string | |
// PodName is the name of the pod unique within a namespace. | |
PodName string | |
} |
%s/%s
for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks. I wonder if it's worth implementing that interface on those types instead for consistency. But I'm good with this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm Thanks for making this consistent! |
/lgtm |
/hold cancel |
@kwiesmueller could you have a look when you have time? Thanks in advance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
Left a last safety question, otherwise great.
If the answer to my question is no, please just unhold.
/hold
@@ -113,10 +114,10 @@ func (s *externalMetricsClient) List(ctx context.Context, namespace string, opts | |||
return nil, err | |||
} | |||
if m == nil || len(m.Items) == 0 { | |||
klog.V(4).Infof("External Metrics Query for VPA %+v: resource %+v, metric %+v, No items,", vpa.ID, resourceName, metricName) | |||
klog.V(4).Infof("External Metrics Query for VPA %s: resource %+v, metric %+v, No items,", klog.KRef(vpa.ID.Namespace, vpa.ID.VpaName), resourceName, metricName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a sanity check as I can't dive deeper on my current device. Can ID be nil?
/hold
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
func (cluster *ClusterState) AddOrUpdateVpa(apiObject *vpa_types.VerticalPodAutoscaler, selector labels.Selector) error { |
If vpa.ID
is nil, it would panic earlier at
autoscaler/vertical-pod-autoscaler/pkg/recommender/input/metrics/metrics_source.go
Line 105 in 1739a71
ObjectMeta: v1.ObjectMeta{Namespace: vpa.ID.Namespace, Name: pod.PodName}, |
/hold cancel
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ialidzhikov, kwiesmueller The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Similar to #6903 but for the vpa-recommender. The Pod/VPA resources are namespaced and logging only the name does not allow these objections to be unambiguously identified in the cluster.
Which issue(s) this PR fixes:
N/A
Special notes for your reviewer:
N/A
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: