Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(controller, instrumenter): extract instrumentation logic #98

Merged

Conversation

basti1302
Copy link
Member

@basti1302 basti1302 commented Aug 18, 2024

Extract the controller's instrumentation logic into a separate module, called instrumentation/instrumenter. This will facilitate running the InstrumentAtStartup task with a separate client and ultimately move it into executeStartupTasks, getting rid of the arbitrary (and potentially problematic) 10 second wait.

@mmanciop mmanciop marked this pull request as ready for review August 19, 2024 17:12
cmd/main.go Outdated
Recorder: mgr.GetEventRecorderFor("dash0-controller"),
Images: images,
OTelCollectorBaseUrl: oTelCollectorBaseUrl,
}
go func() {
time.Sleep(10 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this sleep?

Copy link
Member Author

@basti1302 basti1302 Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sleep is a workaround for the following issue:

  • We need to kick this (InstrumentAtStartup) off before we call mgr.Start(), because mgr.Start() blocks.
  • If InstrumentAtStartup runs right away, before mgr.Start() has actually run, it will throw an error, since the Kubernetes client that we get from the mgr is not started yet.

As the PR description explains, the aim of this PR is get rid of this arbitrary 10 second sleep -- by using a dedicated Kubernetes client that is independent from mgr. I was working on that when you threw your latest PR over the wall :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sleep is gone now, as well as the goroutine -- which was the ultimate goal of the PR.

internal/dash0/util/controller_util.go Outdated Show resolved Hide resolved
@basti1302 basti1302 force-pushed the extract-instrumentation-machinery-to-separate-module branch 2 times, most recently from 615b9a0 to 54ee987 Compare August 19, 2024 19:21
@basti1302 basti1302 marked this pull request as draft August 19, 2024 19:21
@basti1302 basti1302 force-pushed the extract-instrumentation-machinery-to-separate-module branch from 54ee987 to f44d111 Compare August 19, 2024 20:35
Extract the controller's instrumentation logic into a separate module,
called instrumentation/instrumenter. This allows running the
InstrumentAtStartup task with a separate client and to move it into
executeStartupTasks; getting rid of the arbitrary (and potentially
problematic) 10 second wait, which we previously needed to wait until
the manager had finished initializing its Kubernetes API client.
@basti1302 basti1302 force-pushed the extract-instrumentation-machinery-to-separate-module branch from f44d111 to 8f0e756 Compare August 19, 2024 20:55
Copy link

sonarcloud bot commented Aug 19, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
1 Accepted issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@basti1302 basti1302 marked this pull request as ready for review August 19, 2024 20:56
@basti1302 basti1302 enabled auto-merge (rebase) August 19, 2024 20:57
@basti1302 basti1302 merged commit 001ede4 into main Aug 19, 2024
5 checks passed
@basti1302 basti1302 deleted the extract-instrumentation-machinery-to-separate-module branch August 19, 2024 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants