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

[chore][cmd/configschema] Enable goleak #30492

Merged
merged 5 commits into from
Mar 6, 2024

Conversation

crobert-1
Copy link
Member

@crobert-1 crobert-1 commented Jan 12, 2024

Description:

A lot of leaks were happening in this package because of the extensive list of indirect dependencies. I've filed issues and referenced them for each indirect leak.

This PR contains two main changes:

  1. Enable goleak checks for all tests within cmd/configschema.
  2. k8s.io/klog v1 has a leaking goroutine that was resolved in v2. I upgraded the dependency in recevier/awscontainerinsights to resolve this issue. This is a code change, but is totally internal and no user impact.

Link to tracking Issue:
#30438

Testing:
goleak test is passing

Thoughts

  1. Some of these indirect dependencies may never get fixed. For example, one source of a leaking goroutine is cihub/seelog, which hasn't had a commit in 8 years.
  2. Indirect dependencies that start goroutines in init() are the most common cause. For an example of how indirect it gets, we can look at the dbus leak.
crobert$ ~/dev/opentelemetry-collector-contrib/cmd/configschema $ go mod why github.com/godbus/dbus
# github.com/godbus/dbus
github.com/open-telemetry/opentelemetry-collector-contrib/cmd/configschema/cfgmetadatagen
github.com/open-telemetry/opentelemetry-collector-contrib/internal/components
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snowflakereceiver
github.com/snowflakedb/gosnowflake
github.com/99designs/keyring
github.com/godbus/dbus

The bug is in the 99designs/keyring dependency, and the goleak is detected as far back as cmd/configschema tests.

@crobert-1 crobert-1 requested a review from a team January 12, 2024 21:44
@crobert-1 crobert-1 changed the title [cmd/configschema] Enable goleak [chore][cmd/configschema] Enable goleak Jan 12, 2024
@crobert-1
Copy link
Member Author

If it's helpful, I can split out the klog v1 to v2 upgrade to a different PR, just let me know.

Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

Personally I am fine with keeping the klog change here if we get an approval from @Aneurysm9 or @pxaws before merging :)

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 20, 2024
@crobert-1 crobert-1 removed the Stale label Feb 26, 2024
@mx-psi
Copy link
Member

mx-psi commented Feb 29, 2024

Should we remove the klog update and merge the rest?

- Ignore datadog leaking goroutine, opened issue
- Upgrade k8s.io/klog dependency to v2 to avoid leaking goroutine.
  Relevant link: kubernetes/klog#188
@crobert-1
Copy link
Member Author

Should we remove the klog update and merge the rest?

I believe we still need it, as the leak is coming from the awscontainerinsightsreceiver usage. Without that change we need to add a goleak ignore, and we'll keep leaking the goroutine. Even though the klog dependency has been updated in contrib outside of this PR, the v1 reference still needs removed, as it's still a dependency alongside v2:

k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.110.1 // indirect

@mx-psi
Copy link
Member

mx-psi commented Feb 29, 2024

Okay, let's wait a week more for @Aneurysm9 or @Pwasx to chime in, if not I can merge this

@dmitryax dmitryax merged commit 7dd145a into open-telemetry:main Mar 6, 2024
142 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 6, 2024
@crobert-1 crobert-1 deleted the goleak_configschema branch March 6, 2024 10:51
DougManton pushed a commit to DougManton/opentelemetry-collector-contrib that referenced this pull request Mar 13, 2024
**Description:**
A lot of leaks were happening in this package because of the extensive
list of indirect dependencies. I've filed issues and referenced them for
each indirect leak.

This PR contains two main changes:
1. Enable `goleak` checks for all tests within `cmd/configschema`.
2. k8s.io/klog v1 has a leaking goroutine that was [resolved in
v2](kubernetes/klog#188). I upgraded the
dependency in `recevier/awscontainerinsights` to resolve this issue.
This is a code change, but is totally internal and no user impact.

**Link to tracking Issue:** <Issue number if applicable>
open-telemetry#30438

**Testing:**
goleak test is passing

**Thoughts**
1. Some of these indirect dependencies may never get fixed. For example,
one source of a leaking goroutine is
[cihub/seelog](https://github.com/cihub/seelog), which hasn't had a
commit in 8 years.
2. Indirect dependencies that start goroutines in `init()` are the most
common cause. For an example of how indirect it gets, we can look at the
dbus leak.
```
crobert$ ~/dev/opentelemetry-collector-contrib/cmd/configschema $ go mod why github.com/godbus/dbus
# github.com/godbus/dbus
github.com/open-telemetry/opentelemetry-collector-contrib/cmd/configschema/cfgmetadatagen
github.com/open-telemetry/opentelemetry-collector-contrib/internal/components
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snowflakereceiver
github.com/snowflakedb/gosnowflake
github.com/99designs/keyring
github.com/godbus/dbus
```
The bug is in the `99designs/keyring` dependency, and the `goleak` is
detected as far back as `cmd/configschema` tests.
XinRanZhAWS pushed a commit to XinRanZhAWS/opentelemetry-collector-contrib that referenced this pull request Mar 13, 2024
**Description:**
A lot of leaks were happening in this package because of the extensive
list of indirect dependencies. I've filed issues and referenced them for
each indirect leak.

This PR contains two main changes:
1. Enable `goleak` checks for all tests within `cmd/configschema`.
2. k8s.io/klog v1 has a leaking goroutine that was [resolved in
v2](kubernetes/klog#188). I upgraded the
dependency in `recevier/awscontainerinsights` to resolve this issue.
This is a code change, but is totally internal and no user impact.

**Link to tracking Issue:** <Issue number if applicable>
open-telemetry#30438

**Testing:**
goleak test is passing

**Thoughts**
1. Some of these indirect dependencies may never get fixed. For example,
one source of a leaking goroutine is
[cihub/seelog](https://github.com/cihub/seelog), which hasn't had a
commit in 8 years.
2. Indirect dependencies that start goroutines in `init()` are the most
common cause. For an example of how indirect it gets, we can look at the
dbus leak.
```
crobert$ ~/dev/opentelemetry-collector-contrib/cmd/configschema $ go mod why github.com/godbus/dbus
# github.com/godbus/dbus
github.com/open-telemetry/opentelemetry-collector-contrib/cmd/configschema/cfgmetadatagen
github.com/open-telemetry/opentelemetry-collector-contrib/internal/components
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snowflakereceiver
github.com/snowflakedb/gosnowflake
github.com/99designs/keyring
github.com/godbus/dbus
```
The bug is in the `99designs/keyring` dependency, and the `goleak` is
detected as far back as `cmd/configschema` tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants