Skip to content

fix: add a guardrail for TSDB requirement #47

Open
tremes wants to merge 3 commits intorhobs:mainfrom
tremes:obsinta-1177-n
Open

fix: add a guardrail for TSDB requirement #47
tremes wants to merge 3 commits intorhobs:mainfrom
tremes:obsinta-1177-n

Conversation

@tremes
Copy link
Contributor

@tremes tremes commented Mar 13, 2026

No description provided.

@openshift-ci
Copy link

openshift-ci bot commented Mar 13, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link

openshift-ci bot commented Mar 13, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tremes
Once this PR has been reviewed and has the lgtm label, please assign inecas for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

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

Thanks, this is quite better already, just some comments

Comment on lines +22 to +29
var (
// guard rails with their default values
disallowExplicitNameLabel = &Guardrail{Name: GuardrailDisallowExplicitNameLabel, RequireTSDBEndpoint: false, Value: true}
requireLabelMatcher = &Guardrail{Name: GuardrailRequireLabelMatcher, RequireTSDBEndpoint: false, Value: true}
disallowBlanketRegex = &Guardrail{Name: GuardrailDisallowBlanketRegex, RequireTSDBEndpoint: true, Value: true}
maxMetricCardinality = &Guardrail{Name: GuardrailMaxMetricCardinality, RequireTSDBEndpoint: true, Value: 20000}
maxLabelCardinality = &Guardrail{Name: GuardrailMaxLabelCardinality, RequireTSDBEndpoint: true, Value: 500}
)
Copy link
Member

Choose a reason for hiding this comment

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

How about creating a NewGuardrail constructor for these instead of global.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe event maintaing them in a type, with get/set methods. Looks like we already have set methods :)

Copy link
Member

Choose a reason for hiding this comment

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

This way, when a flag for no tsdb endpoint is passed, we just don't init the guardrails, and instead create no-op guardrails on that field.

So the check would just be a passthrough in IsSafeQuery, and we don't need to keep checking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1 for the constructor, although not 100% sure if I understand the rest. Do you mean something like:

  func NewDefaultGuardrails(hasTSDB bool) Guardrails 

and check/get the TSDB availability in the caller (loader.go)?

@tremes tremes marked this pull request as ready for review March 16, 2026 10:47
@tremes tremes requested a review from a team March 16, 2026 10:47
@openshift-ci openshift-ci bot requested review from saswatamcode and slashpai March 16, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants