Skip to content

Commit

Permalink
invalid config file should not be ignored (kubesphere#5228)
Browse files Browse the repository at this point in the history
fix the invalid config file should not be ignored
  • Loading branch information
wansir authored and wanjunlei committed Aug 11, 2023
1 parent f46e9d4 commit f84b7de
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/controller-manager/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func NewControllerManagerCommand() *cobra.Command {
WebhookCertDir: s.WebhookCertDir,
}
} else {
klog.Fatal("Failed to load configuration from disk", err)
klog.Fatalf("Failed to load configuration from disk: %v", err)
}

cmd := &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/ks-apiserver/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewAPIServerCommand() *cobra.Command {
if err == nil {
s.Config = conf
} else {
klog.Fatal("Failed to load configuration from disk", err)
klog.Fatalf("Failed to load configuration from disk: %v", err)
}

cmd := &cobra.Command{
Expand Down
6 changes: 2 additions & 4 deletions pkg/apiserver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *config) watchConfig() <-chan Config {
viper.OnConfigChange(func(in fsnotify.Event) {
cfg := New()
if err := viper.Unmarshal(cfg); err != nil {
klog.Warning("config reload error", err)
klog.Warningf("config reload error: %v", err)
} else {
c.cfgChangeCh <- *cfg
}
Expand All @@ -123,9 +123,7 @@ func (c *config) loadFromDisk() (*Config, error) {
var err error
c.loadOnce.Do(func() {
if err = viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
err = fmt.Errorf("error parsing configuration file %s", err)
}
return
}
err = viper.Unmarshal(c.cfg)
})
Expand Down

0 comments on commit f84b7de

Please sign in to comment.