@@ -26,6 +26,11 @@ import (
26
26
cadvisorfs "github.com/google/cadvisor/fs"
27
27
)
28
28
29
+ // LabelCrioContainers is a label to allow for cadvisor to track writeable layers
30
+ // separately from read-only layers.
31
+ // Once CAdvisor upstream changes are merged, we should remove this constant
32
+ const LabelCrioContainers string = "crio-containers"
33
+
29
34
// imageFsInfoProvider knows how to translate the configured runtime
30
35
// to its file system label for images.
31
36
type imageFsInfoProvider struct {
@@ -35,15 +40,28 @@ type imageFsInfoProvider struct {
35
40
// ImageFsInfoLabel returns the image fs label for the configured runtime.
36
41
// For remote runtimes, it handles additional runtimes natively understood by cAdvisor.
37
42
func (i * imageFsInfoProvider ) ImageFsInfoLabel () (string , error ) {
38
- // This is a temporary workaround to get stats for cri-o from cadvisor
39
- // and should be removed.
40
- // Related to https://github.com/kubernetes/kubernetes/issues/51798
41
- if strings .HasSuffix (i .runtimeEndpoint , CrioSocketSuffix ) {
43
+ if detectCrioWorkaround (i ) {
42
44
return cadvisorfs .LabelCrioImages , nil
43
45
}
44
46
return "" , fmt .Errorf ("no imagefs label for configured runtime" )
45
47
}
46
48
49
+ // ContainerFsInfoLabel returns the container fs label for the configured runtime.
50
+ // For remote runtimes, it handles addition runtimes natively understood by cAdvisor.
51
+ func (i * imageFsInfoProvider ) ContainerFsInfoLabel () (string , error ) {
52
+ if detectCrioWorkaround (i ) {
53
+ return LabelCrioContainers , nil
54
+ }
55
+ return "" , fmt .Errorf ("no containerfs label for configured runtime" )
56
+ }
57
+
58
+ // This is a temporary workaround to get stats for cri-o from cadvisor
59
+ // and should be removed.
60
+ // Related to https://github.com/kubernetes/kubernetes/issues/51798
61
+ func detectCrioWorkaround (i * imageFsInfoProvider ) bool {
62
+ return strings .HasSuffix (i .runtimeEndpoint , CrioSocketSuffix )
63
+ }
64
+
47
65
// NewImageFsInfoProvider returns a provider for the specified runtime configuration.
48
66
func NewImageFsInfoProvider (runtimeEndpoint string ) ImageFsInfoProvider {
49
67
return & imageFsInfoProvider {runtimeEndpoint : runtimeEndpoint }
0 commit comments