@@ -33,10 +33,10 @@ import (
33
33
"time"
34
34
35
35
"github.com/avast/retry-go"
36
+ "github.com/k0sproject/k0s/cmd/internal"
36
37
workercmd "github.com/k0sproject/k0s/cmd/worker"
37
38
"github.com/k0sproject/k0s/internal/pkg/dir"
38
39
"github.com/k0sproject/k0s/internal/pkg/file"
39
- internallog "github.com/k0sproject/k0s/internal/pkg/log"
40
40
"github.com/k0sproject/k0s/internal/pkg/sysinfo"
41
41
"github.com/k0sproject/k0s/internal/sync/value"
42
42
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
@@ -70,7 +70,10 @@ import (
70
70
type command config.CLIOptions
71
71
72
72
func NewControllerCmd () * cobra.Command {
73
- var ignorePreFlightChecks bool
73
+ var (
74
+ debugFlags internal.DebugFlags
75
+ ignorePreFlightChecks bool
76
+ )
74
77
75
78
cmd := & cobra.Command {
76
79
Use : "controller [join-token]" ,
@@ -83,12 +86,8 @@ func NewControllerCmd() *cobra.Command {
83
86
or CLI flag:
84
87
$ k0s controller --token-file [path_to_file]
85
88
Note: Token can be passed either as a CLI argument or as a flag` ,
86
- Args : cobra .MaximumNArgs (1 ),
87
- PersistentPreRunE : func (cmd * cobra.Command , args []string ) error {
88
- logrus .SetOutput (cmd .OutOrStdout ())
89
- internallog .SetInfoLevel ()
90
- return config .CallParentPersistentPreRun (cmd , args )
91
- },
89
+ Args : cobra .MaximumNArgs (1 ),
90
+ PersistentPreRun : debugFlags .Run ,
92
91
RunE : func (cmd * cobra.Command , args []string ) error {
93
92
opts , err := config .GetCmdOpts (cmd )
94
93
if err != nil {
@@ -117,10 +116,12 @@ func NewControllerCmd() *cobra.Command {
117
116
118
117
ctx , cancel := signal .NotifyContext (cmd .Context (), os .Interrupt , syscall .SIGINT , syscall .SIGTERM )
119
118
defer cancel ()
120
- return c .start (ctx )
119
+ return c .start (ctx , debugFlags . IsDebug () )
121
120
},
122
121
}
123
122
123
+ debugFlags .LongRunning ().AddToFlagSet (cmd .PersistentFlags ())
124
+
124
125
flags := cmd .Flags ()
125
126
flags .AddFlagSet (config .GetPersistentFlagSet ())
126
127
flags .AddFlagSet (config .GetControllerFlags ())
@@ -130,7 +131,7 @@ func NewControllerCmd() *cobra.Command {
130
131
return cmd
131
132
}
132
133
133
- func (c * command ) start (ctx context.Context ) error {
134
+ func (c * command ) start (ctx context.Context , debug bool ) error {
134
135
perfTimer := performance .NewTimer ("controller-start" ).Buffer ().Start ()
135
136
136
137
nodeConfig , err := c .K0sVars .NodeConfig ()
@@ -264,8 +265,8 @@ func (c *command) start(ctx context.Context) error {
264
265
nodeComponents .Add (ctx , & cplb.Keepalived {
265
266
K0sVars : c .K0sVars ,
266
267
Config : cplbCfg .Keepalived ,
267
- DetailedLogging : c . Debug ,
268
- LogConfig : c . Debug ,
268
+ DetailedLogging : debug ,
269
+ LogConfig : debug ,
269
270
KubeConfigPath : c .K0sVars .AdminKubeConfigPath ,
270
271
APIPort : nodeConfig .Spec .API .Port ,
271
272
})
0 commit comments