@@ -20,6 +20,7 @@ limitations under the License.
20
20
package cadvisor
21
21
22
22
import (
23
+ "context"
23
24
"flag"
24
25
"fmt"
25
26
"net/http"
@@ -71,7 +72,8 @@ func init() {
71
72
f .DefValue = defaultValue
72
73
f .Value .Set (defaultValue )
73
74
} else {
74
- klog .ErrorS (nil , "Expected cAdvisor flag not found" , "flag" , name )
75
+ ctx := context .Background ()
76
+ klog .FromContext (ctx ).Error (nil , "Expected cAdvisor flag not found" , "flag" , name )
75
77
}
76
78
}
77
79
}
@@ -140,19 +142,19 @@ func (cc *cadvisorClient) MachineInfo() (*cadvisorapi.MachineInfo, error) {
140
142
return cc .GetMachineInfo ()
141
143
}
142
144
143
- func (cc * cadvisorClient ) ImagesFsInfo () (cadvisorapiv2.FsInfo , error ) {
145
+ func (cc * cadvisorClient ) ImagesFsInfo (ctx context. Context ) (cadvisorapiv2.FsInfo , error ) {
144
146
label , err := cc .imageFsInfoProvider .ImageFsInfoLabel ()
145
147
if err != nil {
146
148
return cadvisorapiv2.FsInfo {}, err
147
149
}
148
- return cc .getFsInfo (label )
150
+ return cc .getFsInfo (ctx , label )
149
151
}
150
152
151
153
func (cc * cadvisorClient ) RootFsInfo () (cadvisorapiv2.FsInfo , error ) {
152
154
return cc .GetDirFsInfo (cc .rootPath )
153
155
}
154
156
155
- func (cc * cadvisorClient ) getFsInfo (label string ) (cadvisorapiv2.FsInfo , error ) {
157
+ func (cc * cadvisorClient ) getFsInfo (ctx context. Context , label string ) (cadvisorapiv2.FsInfo , error ) {
156
158
res , err := cc .GetFsInfo (label )
157
159
if err != nil {
158
160
return cadvisorapiv2.FsInfo {}, err
@@ -162,16 +164,16 @@ func (cc *cadvisorClient) getFsInfo(label string) (cadvisorapiv2.FsInfo, error)
162
164
}
163
165
// TODO(vmarmol): Handle this better when a label has more than one image filesystem.
164
166
if len (res ) > 1 {
165
- klog .InfoS ("More than one filesystem labeled. Only using the first one" , "label" , label , "fileSystem" , res )
167
+ klog .FromContext ( ctx ). Info ("More than one filesystem labeled. Only using the first one" , "label" , label , "fileSystem" , res )
166
168
}
167
169
168
170
return res [0 ], nil
169
171
}
170
172
171
- func (cc * cadvisorClient ) ContainerFsInfo () (cadvisorapiv2.FsInfo , error ) {
173
+ func (cc * cadvisorClient ) ContainerFsInfo (ctx context. Context ) (cadvisorapiv2.FsInfo , error ) {
172
174
label , err := cc .imageFsInfoProvider .ContainerFsInfoLabel ()
173
175
if err != nil {
174
176
return cadvisorapiv2.FsInfo {}, err
175
177
}
176
- return cc .getFsInfo (label )
178
+ return cc .getFsInfo (ctx , label )
177
179
}
0 commit comments