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

DataSourceRef: Support legacy string parsing when used in an embedded struct. #981

Merged
merged 1 commit into from
May 7, 2024

Conversation

ryantxu
Copy link
Member

@ryantxu ryantxu commented May 7, 2024

See: grafana/grafana#87224 -- this "fixed" the issue by avoiding the ref alltogether, but this PR will make it work even when embedded.

This PR moves the special legacy string|object handling into the DataSourceRef code rather than in DataQuery. This means the legacy mode will be supported even when the ref is added as embedded fields.

@ryantxu ryantxu requested a review from a team as a code owner May 7, 2024 07:59
@ryantxu ryantxu requested review from wbrowne, marefr, oshirohugo and itsmylife and removed request for a team May 7, 2024 07:59
Copy link
Member

@marefr marefr left a comment

Choose a reason for hiding this comment

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

LGTM with questions

ref := &DataSourceRef{}
err = json.Unmarshal([]byte(`"aaa"`), ref) // string as reference
require.NoError(t, err)
require.Equal(t, "aaa", ref.UID)
Copy link
Member

Choose a reason for hiding this comment

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

So ds name is moved into Ref.uid? No longer possible to know if there's a name or a uid I guess. Do we need to be able to distinguish/handle this legacy case? Can we fail instead getting this legacy format? Hard to know where these legacy forms comes from, imagine it should be migrated in dashboards?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes they should be migrated! but what do we do when they are not? Currently the logic to look up by UID will fallback to lookup by name, so this works OK.

Currently dashboard frontend always does this migration, the place we see issues is in very old alert definitions.

@ryantxu ryantxu merged commit 21f2303 into main May 7, 2024
3 checks passed
@ryantxu ryantxu deleted the datasource-ref-marshal branch May 7, 2024 08:28
@itsmylife
Copy link
Contributor

@ryantxu The changes look good. I am a bit late to review. When we have this in grafana/grafana, are we going to remove what was introduced in this PR grafana/grafana#87224 ?

@marefr
Copy link
Member

marefr commented May 14, 2024

We already have this in grafana/grafana

@itsmylife
Copy link
Contributor

Ah I see, It was in v0.229.0. Thank you.
So it looks like we still need the changes from grafana/grafana#87224

@ryantxu
Copy link
Member Author

ryantxu commented May 14, 2024

@itsmylife -- the changes in grafana/grafana#87224 are no longer required, but are fine to keep (it really just skipped reading properties that were immediately ignored).

@itsmylife
Copy link
Contributor

@ryantxu thanks for the info. Then, I'll keep it.

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.

None yet

3 participants