You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Add Node Volume Health Function](#add-node-volume-health-function)
@@ -136,11 +137,58 @@ Two main parts are involved here in the architecture.
136
137
- Kubelet already collects volume stats from CSI node plugin by calling CSI function NodeGetVolumeStats.
137
138
- 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.
138
139
- 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.
139
141
140
142
The volume health monitoring by Kubelet will be controlled by a new feature gate called `VolumeHealth`.
141
143
142
144
## Implementation
143
145
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):
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
+
144
192
### CSI changes
145
193
146
194
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._
695
743
For Kubelet, enabling/disabling the feature requires downtime of a node.
696
744
697
745
***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
699
747
generate events on Pods so it will change the default behavior.
700
748
Enabling the feature from the controller side will allow events to be reported on PVCs when
701
749
abnormal volume conditions are detected.
@@ -704,14 +752,14 @@ _This section must be completed when targeting alpha to a release._
704
752
the enablement)?**
705
753
Yes. Uninstalling the health monitoring controller sidecar will disable the feature from
706
754
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.
708
756
Existing events will not be removed but they will disappear after a period of time.
709
757
Disabling the feature should not break an existing application as these events are for humans
710
758
only, not for automation.
711
759
712
760
***What happens if we reenable the feature if it was previously rolled back?**
713
761
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.
715
763
716
764
***Are there any tests for feature enablement/disablement?**
717
765
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._
734
782
condition will be reported on PVCs.
735
783
736
784
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.
738
786
739
787
***What specific metrics should inform a rollback?**
740
788
An event will be recorded on the PVC when the controller has successfully retrieved an
741
789
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.
743
791
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
745
793
abnormal volume condition. If the call to `NodeGetVolumeStats` fails for other reasons,
746
794
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.
748
796
749
797
***Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?**
750
798
Describe manual testing that was done and the outcomes.
751
799
Longer term, we may want to require automated upgrade/rollback tests, but we
752
800
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.
754
802
755
803
***Is the rollout accompanied by any deprecations and/or removals of features, APIs,
756
804
fields of API types, flags, etc.?**
@@ -775,16 +823,16 @@ _This section must be completed when targeting beta graduation to a release._
775
823
they are aggregated to show metrics for different sidecars.
776
824
777
825
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.
779
827
780
828
***What are the SLIs (Service Level Indicators) an operator can use to determine
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`.
788
836
-[ ] Other (treat as last resort)
789
837
- Details:
790
838
@@ -804,12 +852,15 @@ the health of the service?**
804
852
can look at the ratio of successful vs non-successful statue codes to figure out
805
853
the success/failure ratio.
806
854
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
+
807
857
***Are there any missing metrics that would be useful to have to improve observability
808
858
of this feature?**
809
859
<!--
810
860
Describe the metrics themselves and the reasons why they weren't added (e.g., cost,
811
861
implementation difficulties, etc.).
812
862
-->
863
+
No.
813
864
814
865
### Dependencies
815
866
@@ -860,12 +911,13 @@ previous answers based on experience in the field._
860
911
call is needed.
861
912
- API calls that may be triggered by changes of some Kubernetes resources
862
913
(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.
863
915
- periodic API calls to reconcile state (e.g. periodic fetching state,
864
916
heartbeats, leader election, etc.)
865
917
866
918
***Will enabling / using this feature result in introducing new API types?**
867
919
Describe them, providing:
868
-
- API type: No
920
+
- API type: Adding 'Abnormal` and `Message` fields to Kubelet VolumeStats metrics API
869
921
- Supported number of objects per cluster: No
870
922
- Supported number of objects per namespace (for namespace-scoped objects): No
871
923
@@ -876,9 +928,9 @@ provider?**
876
928
***Will enabling / using this feature result in increasing size or count of
877
929
the existing API objects?**
878
930
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.
880
932
- 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.
882
934
- Estimated amount of new objects: (e.g., new Object X for every existing Pod)
883
935
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.
884
936
@@ -888,7 +940,8 @@ the existing API objects?**
888
940
operations covered by [existing SLIs/SLOs]?**
889
941
Think about adding additional work or introducing new steps in between
890
942
(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.
892
945
893
946
***Will enabling / using this feature result in non-negligible increase of
894
947
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._
921
974
- Diagnostics: What are the useful log messages and their required logging
922
975
levels that could help debug the issue?
923
976
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.
925
978
- Testing: Are there any tests for failure mode? If not, describe why.
926
979
927
980
***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._
932
985
933
986
## Implementation History
934
987
935
-
- 20210117: Update KEP for Beta
988
+
- 20210902: Update KEP to add volume health to Kublet metrics.
0 commit comments