Skip to content

Conversation

@kruskall
Copy link
Member

@kruskall kruskall commented Jul 8, 2024

Proposed commit message

Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package to fully use the race detector, improved lsp hints and support.

Use pointers in sniffer struct to prevent copying the atomic struct and cause a race condition.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package
to fully use the race detector, improved lsp hints and support.

Use pointers in sniffer struct to prevent copying the atomic struct and cause
a race condition.
@kruskall kruskall requested review from a team as code owners July 8, 2024 01:19
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 8, 2024
@mergify
Copy link
Contributor

mergify bot commented Jul 8, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @kruskall? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

fix golangci-lint issue
@kruskall
Copy link
Member Author

kruskall commented Jul 8, 2024

import 'github.com/elastic/beats/v7/x-pack/dockerlogbeat/pipelinemock' is not allowed from list 'apache-licensed-code': Apache 2.0 licensed code cannot depend on Elastic licensed code (x-pack/). (depguard)

This doesn't look like an issue with this PR 🤔

Is it intended ?

Comment on lines +224 to +225
_serverRequestCount atomic.Int64 // Requests directly to the server
_proxyRequestCount atomic.Int64 // Requests via the proxy
Copy link
Contributor

Choose a reason for hiding this comment

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

The original is 32 bits wide. Do we care? There is almost no-one in the world who that would affect, and it would have affected them anyway. Raising only for awareness.

config config.InterfaceConfig

state atomic.Int32 // store snifferState
state *atomic.Int32 // store snifferState
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than making this a pointer, the child could be directly assigned to sniffers[i] at L105 and child be made a *sniffer from sniffers[i] for ergonomics immediately after. Your choice.

@pierrehilbert pierrehilbert added Team:obs-ds-hosted-services Label for the Observability Hosted Services team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:Cloud-Monitoring Label for the Cloud Monitoring team labels Jul 13, 2024
@cmacknz
Copy link
Member

cmacknz commented Jul 17, 2024

github.com/elastic/beats/v7/x-pack/dockerlogbeat/pipelinemock

We can just Apache license the package most likely and move it out of x-pack (or get rid of our use of this entirely).

@andrewkroh
Copy link
Member

@pkoutsovasilis Here's an issue for that. #40293

Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

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

One question on removal of closeOnce, otherwise I'm OK with this.

@andrzej-stencel
Copy link
Contributor

I think we should create an issue to handle this from the Linux linter

filebeat/input/filestream/internal/input-logfile/harvester_test.go:36:2: import 'github.com/elastic/beats/v7/x-pack/dockerlogbeat/pipelinemock' is not allowed from list 'apache-licensed-code': Apache 2.0 licensed code cannot depend on Elastic licensed code (x-pack/). (depguard)

This PR is blocked by the linter failure, as reported in this issue:

There's a PR up to fix that issue:

@leehinman perhaps you could take a look at that PR to unblock this one?

@ycombinator
Copy link
Contributor

#40483 has now been merged, so this PR here should now be unblocked.

@mergify
Copy link
Contributor

mergify bot commented Sep 21, 2024

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Sep 21, 2024
@kruskall
Copy link
Member Author

@elastic/obs-infraobs-integrations @elastic/obs-ds-hosted-services @elastic/obs-cloud-monitoring @elastic/sec-windows-platform friendly ping for review

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

Approving changes to winlogbeat/* on behalf of sec-windows-platform.

@kruskall
Copy link
Member Author

kruskall commented Dec 9, 2024

@elastic/obs-cloud-monitoring @elastic/obs-ds-hosted-services friendly ping 🙂

Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

Thanks @kruskall Heartbeat changes LGTM

@kruskall kruskall merged commit 296b83b into elastic:main Dec 10, 2024
2 checks passed
@kruskall kruskall deleted the feat/drop-custom-atomic branch December 10, 2024 22:08
mergify bot pushed a commit that referenced this pull request Dec 10, 2024
* feat: replace custom atomic with sync/atomic

Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package
to fully use the race detector, improved lsp hints and support.

Use pointers in sniffer struct to prevent copying the atomic struct and cause
a race condition.

* lint: time.Now().Sub -> time.Since

fix golangci-lint issue

* Apply suggestions from code review

Co-authored-by: Dan Kortschak <[email protected]>

* refactor: keep Swap usage as is

* lint: avoid unnecessary conversion

fix golangci-lint issue

* fix: update method reference to new atomic types

* fix: resolve more compile errors and test failures

* lint: fix linter issues

* lint: fix linter issues

* lint: fix linter issues

* lint: fix linter issues

* lint: more linting errors

* lint: fix linter issues

* lint: remove unused import

* lint: fix linter issue

* lint: fix linter issues

* lint: fix linter issues

---------

Co-authored-by: Dan Kortschak <[email protected]>
(cherry picked from commit 296b83b)

# Conflicts:
#	filebeat/inputsource/common/streaming/listener.go
michalpristas pushed a commit to michalpristas/beats that referenced this pull request Dec 13, 2024
* feat: replace custom atomic with sync/atomic

Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package
to fully use the race detector, improved lsp hints and support.

Use pointers in sniffer struct to prevent copying the atomic struct and cause
a race condition.

* lint: time.Now().Sub -> time.Since

fix golangci-lint issue

* Apply suggestions from code review

Co-authored-by: Dan Kortschak <[email protected]>

* refactor: keep Swap usage as is

* lint: avoid unnecessary conversion

fix golangci-lint issue

* fix: update method reference to new atomic types

* fix: resolve more compile errors and test failures

* lint: fix linter issues

* lint: fix linter issues

* lint: fix linter issues

* lint: fix linter issues

* lint: more linting errors

* lint: fix linter issues

* lint: remove unused import

* lint: fix linter issue

* lint: fix linter issues

* lint: fix linter issues

---------

Co-authored-by: Dan Kortschak <[email protected]>
andrzej-stencel pushed a commit that referenced this pull request Dec 24, 2024
…41979)

* feat: replace custom atomic with sync/atomic (#40132)

* feat: replace custom atomic with sync/atomic

Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package
to fully use the race detector, improved lsp hints and support.

Use pointers in sniffer struct to prevent copying the atomic struct and cause
a race condition.

* lint: time.Now().Sub -> time.Since

fix golangci-lint issue

* Apply suggestions from code review

Co-authored-by: Dan Kortschak <[email protected]>

* refactor: keep Swap usage as is

* lint: avoid unnecessary conversion

fix golangci-lint issue

* fix: update method reference to new atomic types

* fix: resolve more compile errors and test failures

* lint: fix linter issues

* lint: fix linter issues

* lint: fix linter issues

* lint: fix linter issues

* lint: more linting errors

* lint: fix linter issues

* lint: remove unused import

* lint: fix linter issue

* lint: fix linter issues

* lint: fix linter issues

---------

Co-authored-by: Dan Kortschak <[email protected]>
(cherry picked from commit 296b83b)

# Conflicts:
#	filebeat/inputsource/common/streaming/listener.go

* Update listener.go

---------

Co-authored-by: kruskall <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.x Automated backport to the 8.x branch with mergify enhancement Team:Cloud-Monitoring Label for the Cloud Monitoring team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:obs-ds-hosted-services Label for the Observability Hosted Services team Team:Obs-InfraObs Label for the Observability Infrastructure Monitoring team Team:Security-Deployment and Devices Deployment and Devices Team in Security Solution Team:Security-Linux Platform Linux Platform Team in Security Solution Team:Security-Windows Platform Windows Platform Team in Security Solution

Projects

None yet

Development

Successfully merging this pull request may close these issues.