Menu

Why Warnings Disappeared in GitLab Runner's Instance Executor: Watch Your Logger Initialization Order in Go
📰

Why Warnings Disappeared in GitLab Runner's Instance Executor: Watch Your Logger Initialization Order in Go

DEV Community: go·Manish Kumar·about 11 hours ago
#RAvh7kUD
#devtogo#devto#dev#warning#buildlogger
Reading 0:00
15s threshold

A warning can be present in your code, execute under the expected condition, and still never appear in the logs.

In Go services, one possible reason is initialization order: a method attempts to write through a struct field before that field has been initialized.

That was the problem in GitLab Runner's instance executor. When users enabled use_common_build_dir = true without the required VM isolation or max_use_count = 1 configuration, the expected warning did not appear in their CI job logs.

In GitLab Runner MR !7813 , addressing issue #40194 , I traced the missing warning to the order in which the executor initialized its logger and fixed the logging path.

The Problem: A Warning That Never Reached the Job Trace

The affected code was in:

executors/instance/instance.go

Inside Prepare(options common.ExecutorPrepareOptions) , the executor checked whether UseCommonBuildDir could be used with the current autoscaler configuration.

The relevant logic was:

if options . Config . Autoscaler . VMIsolation .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.