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

Storage: Add mode reconciliation for modes 1 and 2 #87919

Merged
merged 11 commits into from
May 22, 2024

Conversation

suntala
Copy link
Contributor

@suntala suntala commented May 15, 2024

What is this feature?

Adds foundation for reconciling current dual writing mode with desired dual writing mode. In particular, adds support for setting current dual writing mode and reconciliation functionality to go from mode 1 to mode 2.

Why do we need this feature?

Required to implement proposal 4 in https://docs.google.com/document/d/1_FZ75QYoBqAW_7pC64fPN5GPUbHyRIWmemcO9SDhBJM/edit#heading=h.5sybau7waq2q

Who is this feature for?

US users, developers

Which issue(s) does this PR fix?:

Relates to https://github.com/grafana/search-and-storage-team/issues/16

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.1.x milestone May 15, 2024
@suntala suntala added no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels May 15, 2024
@suntala suntala marked this pull request as ready for review May 20, 2024 17:40
@suntala suntala requested review from a team as code owners May 20, 2024 17:40
pkg/apiserver/rest/dualwriter.go Show resolved Hide resolved
@@ -32,18 +33,21 @@ type PlaylistAPIBuilder struct {
namespacer request.NamespaceMapper
gv schema.GroupVersion
features featuremgmt.FeatureToggles
kvStore *kvstore.NamespacedKVStore
}

func RegisterAPIService(p playlistsvc.Service,
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: have you checked if we can modify this signature to have the first argument be a context.Context? I think it would require regenerating the wire files. In case it doesn't work:

  1. It may be because we don't yet have a wire provider return a context.Context. We could try to add a wire provider that provides a context.Context, simply returning context.Background() for now.
  2. In the worst case (e.g. if the above is too much work, or unrelated, etc.), we could just pass context.Background() to SetDualWritingMode here.

The idea is that we push the need for a proper context.Context as far above in dependencies as possible, so that when we take the step to properly providing a context.Context the refactor is not so big.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! That makes sense about pushing the need for the context.Context up. Ended up going with option 2 for now.

@suntala suntala force-pushed the suntala/mode-reconciliation branch from 3c47edd to 4490eda Compare May 22, 2024 12:46
}
}

currentMode := toMode[m]
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should probably make sure that toMode[m] exists and default to mode1 if it doesn't

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Added a check in dc147b9.

@suntala suntala merged commit 0ffc4c4 into main May 22, 2024
12 checks passed
@suntala suntala deleted the suntala/mode-reconciliation branch May 22, 2024 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants