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

mimir-mixin: Fix "unexpected type object, expected array" #7457

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

narqo
Copy link
Contributor

@narqo narqo commented Feb 23, 2024

What this PR does

This is a fixup for #7413

When show_rejected_requests_on_writes_dashboard is set in the config, the code path in writes.libjsonnet fails with

2024/02/23 19:48:38 RUNTIME ERROR: Unexpected type object, expected array
	operations/mimir-mixin/dashboards/writes.libsonnet:(139:20)-(151:22)
	During manifestation

This is due to how I originally misinterpreted the {} in the if C then {} as condition C's block:

TIL (1) the {} is an actual object, inserted into the resulting JSON.
TIL (2) jsonnet's linter doesn't catch a broken syntax, i.e. [] + {}, when this happens inside a dead code.

Note there are no assets to rebuild for the PR, because the mentioned config is unset in mimir. But the problem showed itself in the internal build.

Which issue(s) this PR fixes or relates to

Fixes n/a

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
@narqo narqo requested a review from a team as a code owner February 23, 2024 19:59
Comment on lines +138 to +153
if $._config.show_rejected_requests_on_writes_dashboard then
{
targets: [
{
legendLink: null,
expr: 'sum (rate(cortex_distributor_instance_rejected_requests_total{%s}[$__rate_interval]))' % [$.jobMatcher($._config.job_names.distributor)],
format: 'time_series',
intervalFactor: 2,
legendFormat: 'rejected',
refId: 'B',
},
] + super.targets,
} + $.aliasColors({
rejected: '#EAB839',
})
else {},
Copy link
Contributor Author

@narqo narqo Feb 23, 2024

Choose a reason for hiding this comment

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

tl;dr; of these changes:

- if C { targets: [···] + {···} }
+ if C { targets: [···] } + {···}

Copy link
Contributor

@56quarters 56quarters left a comment

Choose a reason for hiding this comment

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

LGTM. Tested by building locally and confirming the changes here fix the error in main when show_rejected_requests_on_writes_dashboard: true

@56quarters 56quarters merged commit a3e4ac7 into main Feb 23, 2024
28 checks passed
@56quarters 56quarters deleted the narqo/fix-mixin branch February 23, 2024 20:19
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