Skip to content

Commit 7cc8ec6

Browse files
authored
Merge pull request #748 from mmiranda96/fix/747
Split proc default and validation between Linux and Windows
2 parents 6e57ca6 + 22157af commit 7cc8ec6

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

pkg/systemstatsmonitor/types/config.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package types
1818

1919
import (
2020
"fmt"
21-
"os"
2221
"regexp"
2322
"time"
2423
)
@@ -27,7 +26,6 @@ var (
2726
defaultInvokeIntervalString = (60 * time.Second).String()
2827
defaultlsblkTimeoutString = (5 * time.Second).String()
2928
defaultKnownModulesConfigPath = "guestosconfig/known-modules.json"
30-
defaultProcPath = "/proc"
3129
)
3230

3331
type MetricConfig struct {
@@ -135,7 +133,7 @@ func (ssc *SystemStatsConfig) Validate() error {
135133
if ssc.InvokeInterval <= time.Duration(0) {
136134
return fmt.Errorf("InvokeInterval %v must be above 0s", ssc.InvokeInterval)
137135
}
138-
if _, err := os.Stat(ssc.ProcPath); err != nil {
136+
if err := ssc.validateProcPath(); err != nil {
139137
return fmt.Errorf("ProcPath %v check failed: %s", ssc.ProcPath, err)
140138
}
141139
if ssc.DiskConfig.LsblkTimeout <= time.Duration(0) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package types
18+
19+
import (
20+
"os"
21+
)
22+
23+
const defaultProcPath = "/proc"
24+
25+
func (ssc *SystemStatsConfig) validateProcPath() error {
26+
_, err := os.Stat(ssc.ProcPath)
27+
return err
28+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package types
18+
19+
const defaultProcPath = ""
20+
21+
func (ssc *SystemStatsConfig) validateProcPath() error {
22+
// not supported
23+
return nil
24+
}

0 commit comments

Comments
 (0)