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
re-push "add volume kubelet_volume_stats_health_abnormal to kubelet #105585" #108758
re-push "add volume kubelet_volume_stats_health_abnormal to kubelet #105585" #108758
Conversation
/sig storage |
/kind bug |
/ok-to-test |
/assign @xing-yang |
oh. I see. the previous PR is reverted. I shouldn't rebase the current master branch |
/assign @dashpole |
/approve |
@@ -263,6 +267,13 @@ func expectedFSStats() kubestats.FsStats { | |||
} | |||
} | |||
|
|||
func expectedVolumeHealthStats() *kubestats.VolumeHealthStats { | |||
metric := expectedMetrics() |
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.
shouldn't you have the nil check here 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.
no. expectedMetrics is a function that is only used in test: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/server/stats/volume_stat_calculator_test.go#L235
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.
Event if you worry about the metric is nil in normal logic, we may need to check nil in here
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/server/stats/volume_stat_calculator.go#L136
But I checked implementations of GetMetrics function, when metric return value is nil, the error is not nil.
Before we used metric, we already checked error is not nil.
So, I think there is no issue.
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.
Even if it is a test, I think we should still check nil to be safe.
/triage accepted |
@@ -263,6 +267,13 @@ func expectedFSStats() kubestats.FsStats { | |||
} | |||
} | |||
|
|||
func expectedVolumeHealthStats() *kubestats.VolumeHealthStats { | |||
metric := expectedMetrics() |
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.
Even if it is a test, I think we should still check nil to be safe.
metric := expectedMetrics() | ||
return &kubestats.VolumeHealthStats{ | ||
Abnormal: *metric.Abnormal, | ||
} |
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 should check both metric and metric.Abnormal are not nil.
Also check if Abnormal or Message is nil before dereferencing them:
https://github.com/kubernetes/kubernetes/blob/v1.24.0-alpha.4/pkg/kubelet/server/stats/volume_stat_calculator_test.go#L243-L244
/lgtm |
/assign @mrunalp |
/assign @dims |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dashpole, fengzixu, mrunalp 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 feature
/kind bug
What this PR does / why we need it:
add
kubelet_volume_stats_health_abnormal
metrics to kubelet based on this kepFix panic bug when volumeHealthStatus is nil on [Failing test] gce-cos-master-scalability-100 #108715 (comment)
Which issue(s) this PR fixes:
Fixes kubernetes/enhancements#2900
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: