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

rpk: handle duration in offset range properly #7971

Merged
merged 1 commit into from
Jan 9, 2023

Conversation

daisukebe
Copy link
Contributor

@daisukebe daisukebe commented Dec 25, 2022

This PR improves consume.go to handle scenarios when an offset range in rpk topic consume contains durations, e.g., 1h, 24h, or -48h, properly.

  • Say the offset range is specified like @2022-02-14T01:01:01Z:1h
  • When parseConsumeTimestamp parses the first half, start offset, it sets fromTimestamp to true as long as the first half is a given date format
  • Next time parseConsumeTimestamp is called to parse the second half, end offset, it adds a 1 hour duration since startAt
  • Additionally, changed consume_test.go to test if parseConsumeTimestamp parses different types of offset range properly

Fixes #7691

Backports Required

  • none - not a bug fix
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v22.3.x
  • v22.2.x
  • v22.1.x

Release Notes

Bug Fixes

  • rpk: --offset option parses duration properly, e.g. --offset @2022-02-14:1h

@daisukebe daisukebe removed the request for review from 0x5d December 25, 2022 02:30
Copy link
Contributor

@twmb twmb left a comment

Choose a reason for hiding this comment

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

good fix, a few comments

src/go/rpk/pkg/cli/cmd/topic/consume.go Outdated Show resolved Hide resolved
src/go/rpk/pkg/cli/cmd/topic/consume.go Outdated Show resolved Hide resolved
src/go/rpk/pkg/cli/cmd/topic/consume.go Outdated Show resolved Hide resolved
src/go/rpk/pkg/cli/cmd/topic/consume.go Outdated Show resolved Hide resolved
src/go/rpk/pkg/cli/cmd/topic/consume_test.go Show resolved Hide resolved
src/go/rpk/pkg/cli/cmd/topic/consume_test.go Outdated Show resolved Hide resolved
@daisukebe daisukebe force-pushed the handle-duration-in-offset branch 3 times, most recently from 410ec2f to bf66adf Compare January 6, 2023 05:42
@daisukebe daisukebe requested a review from twmb January 6, 2023 05:47
@daisukebe
Copy link
Contributor Author

The build error is unrelated?

@twmb
Copy link
Contributor

twmb commented Jan 9, 2023

Yes, looks like #7803 repeatedly. Going to run one more time, otherwise I'll ping @piyushredpanda to merge.

@twmb twmb merged commit 95d1992 into redpanda-data:dev Jan 9, 2023
@daisukebe
Copy link
Contributor Author

/backport v22.3.x

@daisukebe
Copy link
Contributor Author

/backport v22.2.x

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.

rpk: parseConsumeTimestamp doesn't set endAt properly when @<date>:<duration>
2 participants