@@ -16,16 +16,20 @@ import (
1616)
1717
1818// Bootstrap inits all dependencies for a full-fledged AddonOperator instance.
19+ // It initializes the debug server and assembles all components needed for operation.
1920func (op * AddonOperator ) bootstrap () error {
21+ // Log application startup message
2022 log .Info (shapp .AppStartMessage )
2123
24+ // Log the path where modules will be searched
2225 log .Info ("Search modules" ,
2326 slog .String ("path" , app .ModulesDir ))
2427
28+ // Log the namespace in which the operator will work
2529 log .Info ("Addon-operator namespace" ,
2630 slog .String ("namespace" , op .DefaultNamespace ))
2731
28- // Debug server.
32+ // Initialize the debug server for troubleshooting and monitoring
2933 // TODO: rewrite shapp global variables to the addon-operator ones
3034 var err error
3135 op .DebugServer , err = shell_operator .RunDefaultDebugServer (shapp .DebugUnixSocket , shapp .DebugHttpServerAddr , op .Logger .Named ("debug-server" ))
@@ -34,6 +38,7 @@ func (op *AddonOperator) bootstrap() error {
3438 return fmt .Errorf ("start Debug server: %w" , err )
3539 }
3640
41+ // Assemble all operator components including routes, admission server, metrics updaters, and module management
3742 err = op .Assemble (op .DebugServer )
3843 if err != nil {
3944 log .Error ("Fatal" , log .Err (err ))
@@ -43,25 +48,34 @@ func (op *AddonOperator) bootstrap() error {
4348 return nil
4449}
4550
51+ // Assemble initializes and connects components of the AddonOperator.
52+ // It sets up debugging http endpoints, starts netrics services, and initializes the module manager.
4653func (op * AddonOperator ) Assemble (debugServer * debug.Server ) error {
54+ // Register default HTTP routes for the operator
4755 op .registerDefaultRoutes ()
56+
57+ // Start the admission server if enabled in application configuration
4858 if app .AdmissionServerEnabled {
4959 op .AdmissionServer .start (op .ctx )
5060 }
61+
62+ // Start background updaters for metrics
5163 StartLiveTicksUpdater (op .engine .MetricStorage )
5264 StartTasksQueueLengthUpdater (op .engine .MetricStorage , op .engine .TaskQueues )
5365
54- // Register routes in debug server.
66+ // Register debug HTTP endpoints to inspect internal state
5567 op .engine .RegisterDebugQueueRoutes (debugServer )
5668 op .engine .RegisterDebugConfigRoutes (debugServer , op .runtimeConfig )
5769 op .RegisterDebugGlobalRoutes (debugServer )
5870 op .RegisterDebugModuleRoutes (debugServer )
5971 op .RegisterDiscoveryRoute (debugServer )
6072
73+ // Initialize the module manager which handles modules lifecycle
6174 if err := op .InitModuleManager (); err != nil {
6275 return err
6376 }
6477
78+ // Register graph visualization routes after module manager is initialized
6579 op .RegisterDebugGraphRoutes (debugServer )
6680
6781 return nil
@@ -86,6 +100,7 @@ func (op *AddonOperator) SetupModuleManager(modulesDir string, globalHooksDir st
86100 TempDir : tempDir ,
87101 ChrootDir : app .ShellChrootDir ,
88102 }
103+
89104 deps := module_manager.ModuleManagerDependencies {
90105 KubeObjectPatcher : op .engine .ObjectPatcher ,
91106 KubeEventsManager : op .engine .KubeEventsManager ,
0 commit comments