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

Re-license and export pkg/ingester WAL code to be used in Promtail's WAL #8315

Merged
merged 10 commits into from
Jan 30, 2023

Conversation

thepalbi
Copy link
Contributor

@thepalbi thepalbi commented Jan 27, 2023

What this PR does / why we need it:

In PRs mentioned in #8197 , we are adding WAL support for Promtail. Since under-the-cover structure of the WAL will be much like Loki's, we need to re-use some bits from Loki's code:

This two bits have the default Loki license applies (AGPL), which is not compatible with Promtail's , ALv2. This PR moves them to a new package, and re-licenses it.

Also, some other bits are needed which due to its package pkg/util , fall under ALv2 so we are ok with them:

They are also shown in this commit in of the related PRs.

Also, since the new package is called wal, the main WALRecord struct has been renamed to wal.Record to avoid repetition in the name itself.

Which issue(s) this PR fixes:
Required for #8197

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

@thepalbi thepalbi changed the title Relicense pkg/ingester WAL code to be used in Promtail's WAL Relicense and export pkg/ingester WAL code to be used in Promtail's WAL Jan 27, 2023
@thepalbi
Copy link
Contributor Author

thepalbi commented Jan 27, 2023

I'd like to, as part of this PR, rename WALRecord to Record, since due to the new package name, it's imported reference will be wal.Record. Also the linter doesn't seem to like having wal.WALRecord, but we can omit it if not.

pkg/ingester/wal/encoding.go:40:6: exported: type name will be used as wal.WALRecord by other packages, and that stutters; consider calling this Record (revive)
type WALRecord struct {
     ^

What do you think @cstyan ?

@thepalbi thepalbi marked this pull request as ready for review January 27, 2023 17:16
@thepalbi thepalbi requested a review from a team as a code owner January 27, 2023 17:16
@thepalbi thepalbi mentioned this pull request Jan 27, 2023
11 tasks
@thepalbi thepalbi changed the title Relicense and export pkg/ingester WAL code to be used in Promtail's WAL Re-license and export pkg/ingester WAL code to be used in Promtail's WAL Jan 27, 2023
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@thepalbi
Copy link
Contributor Author

I'd like to, as part of this PR, rename WALRecord to Record, since due to the new package name, it's imported reference will be wal.Record. Also the linter doesn't seem to like having wal.WALRecord, but we can omit it if not.

pkg/ingester/wal/encoding.go:40:6: exported: type name will be used as wal.WALRecord by other packages, and that stutters; consider calling this Record (revive)
type WALRecord struct {
     ^

What do you think @cstyan ?

Agreed on yes

clients/pkg/promtail/targets/gcplog/pull_target.go Outdated Show resolved Hide resolved
pkg/ingester/wal/encoding.go Outdated Show resolved Hide resolved
Comment on lines 14 to 18
var (
// shared pool for WALRecords and []logproto.Entries
recordPool = NewRecordPool()
)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need this package global here? it was just used in the actual ingester package, so we can create one with NewRecordPool there if we really need a global

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yhea, just found the dependency why I created that in that file:

  • It was used in encoding_test, so created one as global there for the tests themselves to use
  • Used in Record#Reset. Inverted the dependency, and moved that to the pool itself, since it was the only caller of reset

Also, created one as global in pkg/ingester/wal.go since it's used a bunch there

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Copy link
Contributor

@cstyan cstyan left a comment

Choose a reason for hiding this comment

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

lets just clean up the imports ordering for consistency's sake

after that it looks like you'll need to merge in main or rebase but after that we're good to go IMO

pkg/ingester/encoding_test.go Outdated Show resolved Hide resolved
pkg/ingester/flush_test.go Outdated Show resolved Hide resolved
pkg/ingester/checkpoint.go Outdated Show resolved Hide resolved
@thepalbi
Copy link
Contributor Author

thepalbi commented Jan 27, 2023

@cstyan all import orders should be fixed now 😀

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@thepalbi
Copy link
Contributor Author

@cstyan this PR should be good to go right?

@cstyan cstyan merged commit fda14ca into main Jan 30, 2023
@cstyan cstyan deleted the pablo/wal-part-0 branch January 30, 2023 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants