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

fix: lambda-promtail, update s3 filename regex to allow finding of log files from AWS GovCloud regions #12482

Merged
merged 1 commit into from
Apr 15, 2024
Merged

fix: lambda-promtail, update s3 filename regex to allow finding of log files from AWS GovCloud regions #12482

merged 1 commit into from
Apr 15, 2024

Conversation

Overflow0xFFFF
Copy link
Contributor

What this PR does / why we need it:

A broken regex prevents AWS GovCloud regions from properly being supported with Lambda Promtail. The regex matches only on regions with three parts in their filenames (e.g., us-east-1), and the GovCloud regions have four parts (e.g., us-gov-east-1).

Which issue(s) this PR fixes:

No issue found.

Special notes for your reviewer:

The fix is to add an additional, non-greedy, non-capturing group to match on the fourth parth. Initially, I attempted to use (?:[\w-]+) for its simplicity and to match on the region-parsing logic we already have. However, this breaks the tests for vpcflowlogs because of the greediness of the + operator. As such, I opted to write something more verbose, but non-greedy.

Tests have been added to prevent future breakages, as this tends to be an edge case.

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

A broken regex prevents AWS GovCloud regions from properly being
supported with Lambda Promtail. The regex matches only on regions with
three parts in their filenames (e.g., us-east-1), and the GovCloud
regions have four parts (e.g., us-gov-east-1).

The fix is to add an additional, non-greedy, non-capturing group to
match on the fourth parth. Initially, I attempted to use `(?:[\w-]+)`
for its simplicity and to match on the region-parsing logic we already
have. However, this breaks the tests for vpcflowlogs because of the
greediness of the `+` operator. As such, I opted to write something more
verbose, but non-greedy.

Tests have been added to prevent future breakages, as this tends to be
an edge case.
@Overflow0xFFFF Overflow0xFFFF requested a review from a team as a code owner April 5, 2024 00:30
@CLAassistant
Copy link

CLAassistant commented Apr 5, 2024

CLA assistant check
All committers have signed the CLA.

@cstyan cstyan changed the title fix: Support AWS GovCloud regions in lambda-promtail fix: lambda-promtail, update s3 filename regex to allow finding of log files from AWS GovCloud regions Apr 15, 2024
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.

👍 thanks @Overflow0xFFFF

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