Skip to content

Commit 81babc9

Browse files
committed
Update Volume Health KEP to support metrics
1 parent 1fd25ff commit 81babc9

File tree

1 file changed

+71
-17
lines changed
  • keps/sig-storage/1432-volume-health-monitor

1 file changed

+71
-17
lines changed

keps/sig-storage/1432-volume-health-monitor/README.md

Lines changed: 71 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Use Cases](#use-cases)
1010
- [Proposal](#proposal)
1111
- [Implementation](#implementation)
12+
- [Kubelet Metrics changes](#kubelet-metrics-changes)
1213
- [CSI changes](#csi-changes)
1314
- [Add ControllerGetVolume RPC](#add-controllergetvolume-rpc)
1415
- [Add Node Volume Health Function](#add-node-volume-health-function)
@@ -136,11 +137,58 @@ Two main parts are involved here in the architecture.
136137
- Kubelet already collects volume stats from CSI node plugin by calling CSI function NodeGetVolumeStats.
137138
- In addition to existing volume stats collected already, Kubelet will also check volume condition collected from the same CSI function and log events to Pods if volume condition is abnormal.
138139
- Note that currently we do not have CSI support for local storage. When the support is available, we will implement relavant CSI monitoring interfaces as well.
140+
- Expose Volume Health information as Kubelet VolumeStats Metrics.
139141

140142
The volume health monitoring by Kubelet will be controlled by a new feature gate called `VolumeHealth`.
141143

142144
## Implementation
143145

146+
### Kubelet Metrics changes
147+
148+
Add two new fields in the [VolumeStats metrics API](https://github.com/kubernetes/kubernetes/blob/v1.22.1/staging/src/k8s.io/kubelet/pkg/apis/stats/v1alpha1/types.go#L263).
149+
150+
```
151+
// VolumeStats contains data about Volume filesystem usage.
152+
type VolumeStats struct {
153+
// Embedded FsStats
154+
FsStats `json:",inline"`
155+
// Name is the name given to the Volume
156+
// +optional
157+
Name string `json:"name,omitempty"`
158+
// Reference to the PVC, if one exists
159+
// +optional
160+
PVCRef *PVCReference `json:"pvcRef,omitempty"`
161+
162+
// Note: Add the following new field
163+
// Normal volumes are available for use and operating optimally.
164+
// An abnormal volume does not meet these criteria.
165+
// +optional
166+
Abnormal *bool `json:"abnormal,omitempty"`
167+
168+
// Note: Add the following new field
169+
// The message describing the condition of the volume.
170+
// +optional
171+
Message *string `json:"message,omitempty"`
172+
}
173+
```
174+
175+
Modify [parsePodVolumeStats](https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/kubelet/server/stats/volume_stat_calculator.go#L172) to include the new fields in the returned `stats.VolumeStats`.
176+
177+
The newly added Volume Health stats will be stored in [persistentStats](https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/kubelet/server/stats/volume_stat_calculator.go#L168).
178+
179+
This is returned in [GetPodVolumeStats](https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/kubelet/server/stats/fs_resource_analyzer.go#L99).
180+
181+
Add new metrics [here](https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/kubelet/metrics/metrics.go#L50):
182+
183+
```
184+
VolumeStatsHealthAbnormal = "volume_stats_health_abnormal"
185+
VolumeStatsHealthMessage = "volume_stats_health_message"
186+
```
187+
188+
Update [CollectWithStability](https://github.com/kubernetes/kubernetes/blob/v1.22.1/pkg/kubelet/metrics/collectors/volume_stats.go#L117) to add a [NewLazyConstMetric](https://github.com/kubernetes/component-base/blob/v0.22.1/metrics/value.go#L33) with an [GaugeValue](https://github.com/kubernetes/component-base/blob/v0.22.1/metrics/value.go#L32).
189+
190+
Since Prometheus does not store string metrics, `VolumeStatsHealthAbnormal` will be stored as either 1 or 0 and `VolumeStatsHealthMessage` will be added as a label in the same metric named `VolumeStatsHealthAbnormal`.
191+
144192
### CSI changes
145193

146194
Container Storage Interface (CSI) specification will be modified to provide volume health check leveraging existing RPCs and adding new ones.
@@ -695,7 +743,7 @@ _This section must be completed when targeting alpha to a release._
695743
For Kubelet, enabling/disabling the feature requires downtime of a node.
696744

697745
* **Does enabling the feature change any default behavior?**
698-
Enabling the `VolumeHealth` feature gate will allow Kubelet to monitor volume health and
746+
Enabling the `VolumeHealth` feature gate will allow Kubelet to monitor volume health, emit new metric, and
699747
generate events on Pods so it will change the default behavior.
700748
Enabling the feature from the controller side will allow events to be reported on PVCs when
701749
abnormal volume conditions are detected.
@@ -704,14 +752,14 @@ _This section must be completed when targeting alpha to a release._
704752
the enablement)?**
705753
Yes. Uninstalling the health monitoring controller sidecar will disable the feature from
706754
the controller side.
707-
Disabling the feature gate on Kubelet will prevent Kubelet from monitoring volume health.
755+
Disabling the feature gate on Kubelet will prevent Kubelet from monitoring volume health and emitting the new metric.
708756
Existing events will not be removed but they will disappear after a period of time.
709757
Disabling the feature should not break an existing application as these events are for humans
710758
only, not for automation.
711759

712760
* **What happens if we reenable the feature if it was previously rolled back?**
713761
Events will be added to PVCs or Pods when abnormal volume conditions are
714-
detected again.
762+
detected again and the new metric will be emitted by Kubelet again.
715763

716764
* **Are there any tests for feature enablement/disablement?**
717765
There will be unit tests for the feature `VolumeHealth` enablement/disablement.
@@ -734,23 +782,23 @@ _This section must be completed when targeting beta graduation to a release._
734782
condition will be reported on PVCs.
735783

736784
If enabling the `VolumeHealth` feature fails, no event on volume condition will be
737-
reported on the pod.
785+
reported on the pod and the new `volume_stats_health_abnormal` metric won't be emitted.
738786

739787
* **What specific metrics should inform a rollback?**
740788
An event will be recorded on the PVC when the controller has successfully retrieved an
741789
abnormal volume condition from the storage system. When other errors occur in the controller,
742-
the errors will also be recorded as events.
790+
the errors will also be recorded as events. When a rollback happens on the controller side, that means the external health monitor controller is uninstalled. After that we won't see events on the PVC due to abnormal volume conditions.
743791

744-
In Kubelet, an event will be recorded on the Pod when Kubelet has successfully retrieved an
792+
In Kubelet, an event will be recorded on the Pod and a `volume_stats_health_abnormal` metric will be emitted when Kubelet has successfully retrieved an
745793
abnormal volume condition. If the call to `NodeGetVolumeStats` fails for other reasons,
746794
an error will be returned and whether this will be logged as an event on the Node is up to
747-
the existing Kubelet logic and will not be changed.
795+
the existing Kubelet logic and will not be changed. When a rollback happens, that means the feature gate is disabled again. The new metric won't be emitted after that.
748796

749797
* **Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?**
750798
Describe manual testing that was done and the outcomes.
751799
Longer term, we may want to require automated upgrade/rollback tests, but we
752800
are missing a bunch of machinery and tooling and can't do that now.
753-
Manual testing will be done.
801+
Manual testing will be done to upgrade from 1.22 to 1.23 and downgrade from 1.23 back to 1.22.
754802

755803
* **Is the rollout accompanied by any deprecations and/or removals of features, APIs,
756804
fields of API types, flags, etc.?**
@@ -775,16 +823,16 @@ _This section must be completed when targeting beta graduation to a release._
775823
they are aggregated to show metrics for different sidecars.
776824

777825
In Kubelet, an operator can check whether the feature gate `VolumeHealth`
778-
is enabled.
826+
is enabled and whether the new metric `volume_stats_health_abnormal` is emitted.
779827

780828
* **What are the SLIs (Service Level Indicators) an operator can use to determine
781829
the health of the service?**
782830
- [ ] Metrics
783-
- Metric name: csi_sidecar_operations_seconds
831+
- Metric name: csi_sidecar_operations_seconds, volume_stats_health_abnormal
784832
- [Optional] Aggregation method:
785833
- Components exposing the metric:
786834
csi-external-health-monitor-controller exposes the `csi_sidecar_operations_seconds` metric.
787-
In Kubelet, a call to `NodeGetVolumeStats` is meant to collect volume stats metrics.
835+
In Kubelet, a call to `NodeGetVolumeStats` is meant to collect volume stats metrics. The new metric name is `volume_stats_health_abnormal`.
788836
- [ ] Other (treat as last resort)
789837
- Details:
790838

@@ -804,12 +852,15 @@ the health of the service?**
804852
can look at the ratio of successful vs non-successful statue codes to figure out
805853
the success/failure ratio.
806854

855+
In Kubelet, the new metric `volume_stats_health_abnormal` will be emitted. Whether we can successfully retrieve this metric depending on the CSI call 'NodeGetVolumeStats'. This is an existing call in Kubelet. As long as the CSI driver has implemented this capability to provide volume health, it should be in the response of "NodeGetVolumeStats' call.
856+
807857
* **Are there any missing metrics that would be useful to have to improve observability
808858
of this feature?**
809859
<!--
810860
Describe the metrics themselves and the reasons why they weren't added (e.g., cost,
811861
implementation difficulties, etc.).
812862
-->
863+
No.
813864

814865
### Dependencies
815866

@@ -860,12 +911,13 @@ previous answers based on experience in the field._
860911
call is needed.
861912
- API calls that may be triggered by changes of some Kubernetes resources
862913
(e.g. update of object X triggers new updates of object Y)
914+
We are adding new `Abnormal` and `Message` fields to the existing Kubelet metrics API. It will be retrieved by the periodic metrics collection call. We are not changing the existing frequency of that call.
863915
- periodic API calls to reconcile state (e.g. periodic fetching state,
864916
heartbeats, leader election, etc.)
865917

866918
* **Will enabling / using this feature result in introducing new API types?**
867919
Describe them, providing:
868-
- API type: No
920+
- API type: Adding 'Abnormal` and `Message` fields to Kubelet VolumeStats metrics API
869921
- Supported number of objects per cluster: No
870922
- Supported number of objects per namespace (for namespace-scoped objects): No
871923

@@ -876,9 +928,9 @@ provider?**
876928
* **Will enabling / using this feature result in increasing size or count of
877929
the existing API objects?**
878930
Describe them, providing:
879-
- API type(s): No
931+
- API type(s): Yes. We are adding new 'Abnormal` and `Message` fields to Kubelet VolumeStats metrics API.
880932
- Estimated increase in size: (e.g., new annotation of size 32B):
881-
No
933+
New string of max length of 128 bytes; new int of 4 bytes.
882934
- Estimated amount of new objects: (e.g., new Object X for every existing Pod)
883935
The controller reports events on PVC while Kubelet reports events on Pod. They work independently of each other. It is recommended that CSI driver should not report duplicate information through the controller and Kubelet. For example, if the controller detects a failure on one volume, it should record just one event on one PVC. If Kubelet detects a failure, it should record an event on every pod used by the affected PVC.
884936

@@ -888,7 +940,8 @@ the existing API objects?**
888940
operations covered by [existing SLIs/SLOs]?**
889941
Think about adding additional work or introducing new steps in between
890942
(e.g. need to do X to start a container), etc. Please describe the details.
891-
This feature will periodically query storage systems to get the latest volume conditions. So this will have an impact on the performance of the operations running on the storage systems.
943+
On the controller side, this feature will periodically query storage systems to get the latest volume conditions. So this will have an impact on the performance of the operations running on the storage systems.
944+
In Kubelet, `NodeGetVolumeStats` is an existing call, so it won't have additional performance impact.
892945

893946
* **Will enabling / using this feature result in non-negligible increase of
894947
resource usage (CPU, RAM, disk, IO, ...) in any components?**
@@ -921,7 +974,7 @@ _This section must be completed when targeting beta graduation to a release._
921974
- Diagnostics: What are the useful log messages and their required logging
922975
levels that could help debug the issue?
923976
Not required until feature graduated to beta.
924-
If there are log messages indicating abnormal volume conditions but there are no events reported, we can check the timestamp of the messages to see if events have disappeared based on TTL or if they are never reported. If there are problems on the storage systems but they are not reported in logs or events, we can check the logs of the storage systems to figure out why this has happened.
977+
If there are log messages indicating abnormal volume conditions but there are no events reported or new metric emitted, we can check the timestamp of the messages to see if events have disappeared based on TTL or if they are never reported. If there are problems on the storage systems but they are not reported in logs or events, we can check the logs of the storage systems to figure out why this has happened.
925978
- Testing: Are there any tests for failure mode? If not, describe why.
926979

927980
* **What steps should be taken if SLOs are not being met to determine the problem?**
@@ -932,7 +985,8 @@ _This section must be completed when targeting beta graduation to a release._
932985

933986
## Implementation History
934987

935-
- 20210117: Update KEP for Beta
988+
- 20210902: Update KEP to add volume health to Kublet metrics.
989+
- 20210117: Update KEP for Alpha
936990

937991
- 20191021: KEP updated
938992

0 commit comments

Comments
 (0)