Merge pull request #748 from mmiranda96/fix/747

Split proc default and validation between Linux and Windows
This commit is contained in:
Kubernetes Prow Robot
2023-05-02 16:04:16 -07:00
committed by GitHub
3 changed files with 53 additions and 3 deletions

View File

@@ -18,7 +18,6 @@ package types
import (
"fmt"
"os"
"regexp"
"time"
)
@@ -27,7 +26,6 @@ var (
defaultInvokeIntervalString = (60 * time.Second).String()
defaultlsblkTimeoutString = (5 * time.Second).String()
defaultKnownModulesConfigPath = "guestosconfig/known-modules.json"
defaultProcPath = "/proc"
)
type MetricConfig struct {
@@ -135,7 +133,7 @@ func (ssc *SystemStatsConfig) Validate() error {
if ssc.InvokeInterval <= time.Duration(0) {
return fmt.Errorf("InvokeInterval %v must be above 0s", ssc.InvokeInterval)
}
if _, err := os.Stat(ssc.ProcPath); err != nil {
if err := ssc.validateProcPath(); err != nil {
return fmt.Errorf("ProcPath %v check failed: %s", ssc.ProcPath, err)
}
if ssc.DiskConfig.LsblkTimeout <= time.Duration(0) {

View File

@@ -0,0 +1,28 @@
/*
Copyright 2019 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package types
import (
"os"
)
const defaultProcPath = "/proc"
func (ssc *SystemStatsConfig) validateProcPath() error {
_, err := os.Stat(ssc.ProcPath)
return err
}

View File

@@ -0,0 +1,24 @@
/*
Copyright 2019 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package types
const defaultProcPath = ""
func (ssc *SystemStatsConfig) validateProcPath() error {
// not supported
return nil
}