@@ -51,11 +51,11 @@ func RunKubeStateMetricsWrapper(opts *options.Options) {
51
51
var cfgViperReadInConfigErr error
52
52
if cfgViperReadInConfigErr = cfgViper .ReadInConfig (); cfgViperReadInConfigErr != nil {
53
53
if errors .Is (cfgViperReadInConfigErr , viper.ConfigFileNotFoundError {}) {
54
- klog .InfoS ( "Options configuration file not found at startup" , "file" , file )
54
+ klog .ErrorS ( cfgViperReadInConfigErr , "Options configuration file not found at startup" , "file" , file )
55
55
} else if _ , isNotExisterr := os .Stat (filepath .Clean (file )); os .IsNotExist (isNotExisterr ) {
56
56
// TODO: Remove this check once viper.ConfigFileNotFoundError is working as expected, see this issue -
57
57
// https://github.com/spf13/viper/issues/1783
58
- klog .InfoS ( "Options configuration file not found at startup" , "file" , file )
58
+ klog .ErrorS ( isNotExisterr , "Options configuration file not found at startup" , "file" , file )
59
59
} else {
60
60
klog .ErrorS (cfgViperReadInConfigErr , "Error reading options configuration file" , "file" , file )
61
61
}
@@ -87,15 +87,15 @@ func RunKubeStateMetricsWrapper(opts *options.Options) {
87
87
crcViper := viper .New ()
88
88
crcViper .SetConfigType ("yaml" )
89
89
crcViper .SetConfigFile (opts .CustomResourceConfigFile )
90
- if err := crcViper .ReadInConfig (); err != nil {
91
- if errors .Is (err , viper.ConfigFileNotFoundError {}) {
92
- klog .InfoS ( "Custom resource configuration file not found at startup" , "file" , opts .CustomResourceConfigFile )
93
- } else if _ , err = os .Stat (filepath .Clean (opts .CustomResourceConfigFile )); os .IsNotExist (err ) {
90
+ if cfgViperReadInConfigErr := crcViper .ReadInConfig (); cfgViperReadInConfigErr != nil {
91
+ if errors .Is (cfgViperReadInConfigErr , viper.ConfigFileNotFoundError {}) {
92
+ klog .ErrorS ( cfgViperReadInConfigErr , "Custom resource configuration file not found at startup" , "file" , opts .CustomResourceConfigFile )
93
+ } else if _ , isNotExisterr = os .Stat (filepath .Clean (opts .CustomResourceConfigFile )); os .IsNotExist (isNotExisterr ) {
94
94
// Adding this check in addition to the above since viper.ConfigFileNotFoundError is not working as expected due to this issue -
95
95
// https://github.com/spf13/viper/issues/1783
96
- klog .InfoS ( "Custom resource configuration file not found at startup" , "file" , opts .CustomResourceConfigFile )
96
+ klog .ErrorS ( isNotExisterr , "Custom resource configuration file not found at startup" , "file" , opts .CustomResourceConfigFile )
97
97
} else {
98
- klog .ErrorS (err , "Error reading Custom resource configuration file" , "file" , opts .CustomResourceConfigFile )
98
+ klog .ErrorS (cfgViperReadInConfigErr , "Error reading Custom resource configuration file" , "file" , opts .CustomResourceConfigFile )
99
99
}
100
100
if ! opts .ContinueWithoutCustomResourceConfigFile {
101
101
klog .FlushAndExit (klog .ExitFlushTimeout , 1 )
0 commit comments