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

feat(risedev): use jsonnet for profiles and templates #16659

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented May 9, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Jsonnet is a powerful tool to write reusable and extensible configurations.

In this PR, we introduced jsonnet-based RiseDev profiles and templates. Benefits are:

  • Get rid of the Rust "expanders" for manipulating profiles. All transformations are done in jsonnet.
  • Be able to reuse the service list between different profiles.
  • Code-completion and hints when writing new profiles or service templates.

The compatibility for old risedev.yml format is still kept through compat.libsonnet. We can migrate them in the future.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao BugenZhao marked this pull request as ready for review May 9, 2024 10:22
@BugenZhao BugenZhao requested a review from a team as a code owner May 9, 2024 10:22
Copy link
Member Author

Choose a reason for hiding this comment

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

This is where future risedev profiles will reside.

Copy link
Member Author

Choose a reason for hiding this comment

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

Migrated from the template section in risedev.yml.

// Advertise port of MinIO s3 endpoint
port: 9301,
// Listen address of MinIO endpoint
listenAddress: self.address,
Copy link
Member Author

Choose a reason for hiding this comment

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

No need to use DollarExpander anymore.


etcd: {
// Id of this instance
id: 'etcd-' + self.port,
Copy link
Member Author

Choose a reason for hiding this comment

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

No need to use IdExpander anymore.

Comment on lines +21 to +25
// Expand the provided steps.
// The nested `provide-xx` fields will not be used. Prune them.
pruneProvide(otherStep)
for otherStep in steps
if std.startsWith(otherStep.id, std.rstripChars(step[name], '*'))
Copy link
Member Author

Choose a reason for hiding this comment

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

No need for ProvideExpander anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the entrypoint of the jsonnet program to evaluate.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is to convert risedev.yml to the format of risedev-profiles.libsonnet.

Comment on lines +340 to +345
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
struct Input {
config_path: Option<String>,
steps: Vec<ServiceConfig>,
}
Copy link
Member Author

Choose a reason for hiding this comment

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

The generated JSON will be directly deserialized into this struct, then executed by risedev-dev.

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Copy link
Member

@xxchan xxchan left a comment

Choose a reason for hiding this comment

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

Generally LGTM (not delved into the details), although I don't see there's any compelling reasons to do the refactoring (risedev config expander works good enough).

Besides, please update src/risedevtool/README.md. src/risedevtool/risedev-schema.json may also need update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants