Skip to content

feat(runtime): support dataset auto-create policy#5674

Open
jakharmonika364 wants to merge 1 commit intofluid-cloudnative:masterfrom
jakharmonika364:feature-dataset-policy-auto-create
Open

feat(runtime): support dataset auto-create policy#5674
jakharmonika364 wants to merge 1 commit intofluid-cloudnative:masterfrom
jakharmonika364:feature-dataset-policy-auto-create

Conversation

@jakharmonika364
Copy link

Ⅰ. Describe what this PR does

  • Adds a runtime annotation fluid.io/dataset-policy: "auto-create" to let a Runtime start without a pre-created Dataset.
  • When this annotation is set and the matching Dataset is missing, the shared RuntimeReconciler auto-creates a minimal Dataset with the same name/namespace and keeps the existing binding flow unchanged for other cases.

Ⅱ. Does this pull request fix one issue?

fixes #4518


Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

No new tests in this PR. The change is confined to the shared controller logic; I’ve verified the basic flow manually as described below and can add unit tests around RuntimeReconciler in a follow-up if preferred.


Ⅳ. Describe how to verify it

  1. Deploy Fluid built from this branch.
  2. Create a JuiceFSRuntime (or another supported runtime) without a Dataset:
   apiVersion: data.fluid.io/v1alpha1
   kind: JuiceFSRuntime
   metadata:
     name: demo-juicefs
     namespace: default
     annotations:
       fluid.io/dataset-policy: "auto-create"
   spec:
     # minimal valid spec
  1. Check that Dataset demo-juicefs is created in default and has metadata.annotations["fluid.io/dataset-policy"] = "auto-create".
  2. Confirm the runtime reconciles as usual (ownerReferences/finalizers set, engine created) and DataLoad/DataMigrate still work on the auto-created Dataset.

Ⅴ. Special notes for reviews

  • The behavior is opt-in and only affects runtimes annotated with fluid.io/dataset-policy: "auto-create"; existing users see no change by default.

@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Mar 1, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ronggu for approval by writing /assign @ronggu in a comment. For more information see:The Kubernetes 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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Fluid runtime controller by enabling the automatic creation of Datasets. It simplifies the deployment process for users by removing the prerequisite of manually creating a Dataset before a Runtime. The change streamlines the workflow for new Runtimes, making them more self-sufficient in their initial setup.

Highlights

  • Dataset Auto-Creation Policy: Introduced a new runtime annotation, fluid.io/dataset-policy: "auto-create", allowing a Runtime to be created without a pre-existing Dataset.
  • Automated Dataset Provisioning: When the auto-create annotation is present and a matching Dataset is not found, the RuntimeReconciler automatically creates a minimal Dataset with the same name and namespace, ensuring the Runtime can proceed with its binding flow.
  • Opt-in Behavior: This new functionality is opt-in, meaning existing Runtimes without the specific annotation will behave as before, ensuring no breaking changes for current users.
Changelog
  • pkg/common/constants.go
    • Defined a new constant DatasetPolicyAutoCreate to represent the 'auto-create' policy value.
  • pkg/common/label.go
    • Added a new constant AnnotationDatasetPolicy for the fluid.io/dataset-policy annotation key.
  • pkg/controllers/runtime_controller.go
    • Imported the apierrors package for Kubernetes API error handling.
    • Modified the ReconcileInternal method to check for the fluid.io/dataset-policy annotation on the Runtime.
    • Implemented logic within ReconcileInternal to call a new ensureDatasetForRuntime function if the auto-create policy is set and the corresponding Dataset is not found.
    • Updated logging messages to provide more context when a Dataset is not found, especially when the auto-create policy is active.
    • Added a new private method ensureDatasetForRuntime responsible for creating a minimal Dataset object, copying relevant annotations, and setting its TypeMeta and ObjectMeta.
Activity
  • No new automated tests were added in this PR, as the change is confined to shared controller logic.
  • The author manually verified the basic flow as described in the PR body.
  • The author indicated that unit tests around RuntimeReconciler could be added in a follow-up PR if preferred.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Mar 1, 2026

Hi @jakharmonika364. Thanks for your PR.

I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a useful feature for auto-creating datasets when a runtime is deployed with a specific annotation. The overall implementation is sound, but I've identified a critical issue that could lead to resource leaks. The auto-created dataset lacks an owner reference to the runtime, which means it won't be garbage collected when the runtime is deleted. I've provided a high-severity comment with a code suggestion to fix this. I also found a minor opportunity to refactor a piece of code for better readability and have included a medium-severity suggestion for that. Given the nature of these changes, I strongly recommend adding unit tests, as you've also noted, to ensure the correctness of the auto-creation logic and prevent future regressions, especially around resource lifecycle management.

@jakharmonika364 jakharmonika364 force-pushed the feature-dataset-policy-auto-create branch from 8a59efa to 97fd836 Compare March 1, 2026 12:46
Signed-off-by: Monika Jakhar <jakharmonika364@gmail.com>
@jakharmonika364 jakharmonika364 force-pushed the feature-dataset-policy-auto-create branch from 97fd836 to bf571b3 Compare March 1, 2026 12:50
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 1, 2026

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.

[FEATURES] Support creating Runtime without Dataset dependency

1 participant