97
97
EnvMemory = "CODER_MEMORY"
98
98
EnvAddGPU = "CODER_ADD_GPU"
99
99
EnvUsrLibDir = "CODER_USR_LIB_DIR"
100
+ EnvDebug = "CODER_DEBUG"
100
101
)
101
102
102
103
var envboxPrivateMounts = map [string ]struct {}{
@@ -126,14 +127,17 @@ type flags struct {
126
127
addTUN bool
127
128
addFUSE bool
128
129
addGPU bool
129
- noStartupLogs bool
130
130
dockerdBridgeCIDR string
131
131
boostrapScript string
132
- ethlink string
133
132
containerMounts string
134
133
hostUsrLibDir string
135
134
cpus int
136
135
memory int
136
+
137
+ // Test flags.
138
+ noStartupLogs bool
139
+ debug bool
140
+ ethlink string
137
141
}
138
142
139
143
func dockerCmd () * cobra.Command {
@@ -333,6 +337,7 @@ func dockerCmd() *cobra.Command {
333
337
334
338
// Test flags.
335
339
cliflag .BoolVarP (cmd .Flags (), & flags .noStartupLogs , "no-startup-log" , "" , "" , false , "Do not log startup logs. Useful for testing." )
340
+ cliflag .BoolVarP (cmd .Flags (), & flags .debug , "debug" , "" , EnvDebug , false , "Log additional output." )
336
341
cliflag .StringVarP (cmd .Flags (), & flags .ethlink , "ethlink" , "" , "" , defaultNetLink , "The ethernet link to query for the MTU that is passed to docerd. Used for tests." )
337
342
338
343
return cmd
@@ -644,6 +649,15 @@ func runDockerCVM(ctx context.Context, log slog.Logger, client dockerutil.Docker
644
649
645
650
blog .Info ("Envbox startup complete!" )
646
651
652
+ // The bootstrap script doesn't return since it execs the agent
653
+ // meaning that it can get pretty noisy if we were to log by default.
654
+ // In order to allow users to discern issues getting the bootstrap script
655
+ // to complete successfully we pipe the output to stdout if
656
+ // CODER_DEBUG=true.
657
+ debugWriter := io .Discard
658
+ if flags .debug {
659
+ debugWriter = os .Stdout
660
+ }
647
661
// Bootstrap the container if a script has been provided.
648
662
blog .Infof ("Bootstrapping workspace..." )
649
663
err = dockerutil .BootstrapContainer (ctx , client , dockerutil.BootstrapConfig {
@@ -654,7 +668,8 @@ func runDockerCVM(ctx context.Context, log slog.Logger, client dockerutil.Docker
654
668
// to /tmp/coder.XXXX. This causes a race to happen where we finish
655
669
// downloading the binary but before we can execute systemd remounts
656
670
// /tmp.
657
- Env : []string {fmt .Sprintf ("BINARY_DIR=%s" , bootDir )},
671
+ Env : []string {fmt .Sprintf ("BINARY_DIR=%s" , bootDir )},
672
+ StdOutErr : debugWriter ,
658
673
})
659
674
if err != nil {
660
675
return xerrors .Errorf ("boostrap container: %w" , err )
0 commit comments