@@ -48,8 +48,8 @@ type FileSystems struct {
48
48
Filsystem []ContainerFileSystem `json:"filesystems"`
49
49
}
50
50
51
- func checkSourcePathExist ( sourcePath string ) (bool , error ) {
52
- _ , err := os .Stat (sourcePath )
51
+ func checkPathExist ( path string ) (bool , error ) {
52
+ _ , err := os .Stat (path )
53
53
if err != nil {
54
54
if os .IsNotExist (err ) {
55
55
return false , nil
@@ -77,7 +77,7 @@ func parseMountInfo(originalMountInfo []byte) ([]MountPointInfo, error) {
77
77
return fs .Filsystem [0 ].Children , nil
78
78
}
79
79
80
- func checkMountPointExist (sourcePath string ) (bool , error ) {
80
+ func checkMountPointExist (volumePath string ) (bool , error ) {
81
81
cmdPath , err := exec .LookPath ("findmnt" )
82
82
if err != nil {
83
83
return false , fmt .Errorf ("findmnt not found: %w" , err )
@@ -107,7 +107,7 @@ func checkMountPointExist(sourcePath string) (bool, error) {
107
107
}
108
108
109
109
for _ , mountInfo := range mountInfosOfPod .ContainerFileSystem {
110
- if ! strings .Contains (mountInfo .Source , sourcePath ) {
110
+ if ! strings .Contains (mountInfo .Source , volumePath ) {
111
111
continue
112
112
}
113
113
@@ -127,8 +127,8 @@ func checkMountPointExist(sourcePath string) (bool, error) {
127
127
}
128
128
129
129
func (hp * hostPath ) checkPVCapacityValid (volID string ) (bool , error ) {
130
- sourcePath := hp .getVolumePath (volID )
131
- _ , fscapacity , _ , _ , _ , _ , err := fs .FsInfo (sourcePath )
130
+ volumePath := hp .getVolumePath (volID )
131
+ _ , fscapacity , _ , _ , _ , _ , err := fs .FsInfo (volumePath )
132
132
if err != nil {
133
133
return false , fmt .Errorf ("failed to get capacity info: %+v" , err )
134
134
}
@@ -147,8 +147,8 @@ func getPVStats(volumePath string) (available int64, capacity int64, used int64,
147
147
}
148
148
149
149
func (hp * hostPath ) checkPVUsage (volID string ) (bool , error ) {
150
- sourcePath := hp .getVolumePath (volID )
151
- fsavailable , _ , _ , _ , _ , _ , err := fs .FsInfo (sourcePath )
150
+ volumePath := hp .getVolumePath (volID )
151
+ fsavailable , _ , _ , _ , _ , _ , err := fs .FsInfo (volumePath )
152
152
if err != nil {
153
153
return false , err
154
154
}
@@ -158,9 +158,9 @@ func (hp *hostPath) checkPVUsage(volID string) (bool, error) {
158
158
}
159
159
160
160
func (hp * hostPath ) doHealthCheckInControllerSide (volID string ) (bool , string ) {
161
- sourcePath := hp .getVolumePath (volID )
162
- glog .V (3 ).Infof ("Volume: %s Source path is: %s " , volID , sourcePath )
163
- spExist , err := checkSourcePathExist ( sourcePath )
161
+ volumePath := hp .getVolumePath (volID )
162
+ glog .V (3 ).Infof ("Volume with ID %s has path %s. " , volID , volumePath )
163
+ spExist , err := checkPathExist ( volumePath )
164
164
if err != nil {
165
165
return false , err .Error ()
166
166
}
@@ -191,8 +191,8 @@ func (hp *hostPath) doHealthCheckInControllerSide(volID string) (bool, string) {
191
191
}
192
192
193
193
func (hp * hostPath ) doHealthCheckInNodeSide (volID string ) (bool , string ) {
194
- sourcePath := hp .getVolumePath (volID )
195
- mpExist , err := checkMountPointExist (sourcePath )
194
+ volumePath := hp .getVolumePath (volID )
195
+ mpExist , err := checkMountPointExist (volumePath )
196
196
if err != nil {
197
197
return false , err .Error ()
198
198
}
0 commit comments