diff --git a/cmd/oteld/manager/main.go b/cmd/oteld/manager/main.go index e59cbac73beb..c1d8cb1539ef 100644 --- a/cmd/oteld/manager/main.go +++ b/cmd/oteld/manager/main.go @@ -21,7 +21,6 @@ package main import ( "flag" - "fmt" "os" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) @@ -54,12 +53,12 @@ func init() { utilruntime.Must(monitorv1alpha1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme - viper.SetConfigName("config") - viper.SetConfigType("yaml") - viper.SetDefault(constant.MonitorNamespaceEnvName, "default") - viper.AddConfigPath(fmt.Sprintf("/etc/%s/", constant.OTeldAppName)) - viper.AddConfigPath(fmt.Sprintf("$HOME/.%s", constant.OTeldAppName)) - viper.AddConfigPath(".") + // viper.SetConfigName("config") + // viper.SetConfigType("yaml") + // viper.SetDefault(constant.MonitorNamespaceEnvName, "default") + // viper.AddConfigPath(fmt.Sprintf("/etc/%s/", constant.OTeldAppName)) + // viper.AddConfigPath(fmt.Sprintf("$HOME/.%s", constant.OTeldAppName)) + // viper.AddConfigPath(".") // set env default value viper.SetDefault(constant.CfgKeyCtrlrMgrNS, "default") @@ -83,16 +82,16 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - if err := viper.ReadInConfig(); err != nil { - setupLog.Error(err, "error reading config") - os.Exit(1) - } - setupLog.Info(fmt.Sprintf("oteld config file: %s", viper.ConfigFileUsed())) - config, err := types.LoadConfig(viper.ConfigFileUsed()) - if err != nil { - setupLog.Error(err, "unable to load config") - os.Exit(1) - } + // if err := viper.ReadInConfig(); err != nil { + // setupLog.Error(err, "error reading config") + // os.Exit(1) + // } + // setupLog.Info(fmt.Sprintf("oteld config file: %s", viper.ConfigFileUsed())) + // config, err := types.LoadConfig(viper.ConfigFileUsed()) + // if err != nil { + // setupLog.Error(err, "unable to load config") + // os.Exit(1) + // } mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, @@ -122,7 +121,7 @@ func main() { Client: mgr.GetClient(), Scheme: mgr.GetScheme(), Recorder: mgr.GetEventRecorderFor("oteld-controller"), - }, config).SetupWithManager(mgr); err != nil { + }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "OTeld") os.Exit(1) } diff --git a/controllers/monitor/oteld_controller.go b/controllers/monitor/oteld_controller.go index 33032460b12d..cddb46e1162f 100644 --- a/controllers/monitor/oteld_controller.go +++ b/controllers/monitor/oteld_controller.go @@ -21,10 +21,7 @@ package monitor import ( "context" - "fmt" - "github.com/fsnotify/fsnotify" - "github.com/spf13/viper" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" @@ -114,12 +111,12 @@ func (o *OTeldReconciler) runTasks(reqCtx intctrlutil.RequestCtx, oteld *monitor return nil } -func New(params monitortypes.OTeldParams, config *monitortypes.Config) *OTeldReconciler { +func New(params monitortypes.OTeldParams) *OTeldReconciler { reconcile := OTeldReconciler{ Client: params.Client, Scheme: params.Scheme, Recorder: params.Recorder, - Config: config, + // Config: config, // sub-controllers tasks: []monitortypes.ReconcileTask{ @@ -136,16 +133,6 @@ func New(params monitortypes.OTeldParams, config *monitortypes.Config) *OTeldRec }, } - viper.OnConfigChange(func(e fsnotify.Event) { - log.Log.Info(fmt.Sprintf("config file changed: %s", e.Name)) - newConfig, err := monitortypes.LoadConfig(viper.ConfigFileUsed()) - if err != nil { - log.Log.Error(err, fmt.Sprintf("failed to reload config: %s", e.Name)) - return - } - // TODO how to trigger the operator to reconcile - reconcile.Config = newConfig - }) return &reconcile }