Skip to content

prevent ThinRuntime pointing to a CacheRuntime-backed Dataset and add docs#5901

Merged
cheyang merged 5 commits into
fluid-cloudnative:masterfrom
xliuqq:thin-cache
May 28, 2026
Merged

prevent ThinRuntime pointing to a CacheRuntime-backed Dataset and add docs#5901
cheyang merged 5 commits into
fluid-cloudnative:masterfrom
xliuqq:thin-cache

Conversation

@xliuqq
Copy link
Copy Markdown
Collaborator

@xliuqq xliuqq commented May 20, 2026

Ⅰ. Describe what this PR does

prevent ThinRuntime pointing to a CacheRuntime-backed Dataset and add docs

Ⅱ. Does this pull request fix one issue?

fixes #5876

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

unit test

Ⅳ. Describe how to verify it

unit test

Ⅴ. Special notes for reviews

xliuqq added 2 commits May 20, 2026 20:49
Signed-off-by: xliuqq <xlzq1992@gmail.com>
Signed-off-by: xliuqq <xlzq1992@gmail.com>
Copy link
Copy Markdown
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 validation logic to ensure that CacheRuntime is not used as a physical runtime for reference datasets, alongside updated documentation and a new ThinRuntime example using Minio. The CheckIfReferenceDatasetIsSupported method was refactored to return errors, and unit tests were added to verify the new constraints. A review comment suggests making the configuration parsing script in the documentation more robust by reading the full file content instead of just the first line to avoid potential JSON parsing failures.

Comment on lines +99 to +102
with open("/etc/fluid/config/config.json", "r") as f:
lines = f.readlines()

rawStr = lines[0]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Reading the config file with f.readlines() and then taking the first line with lines[0] is not robust. If the JSON content is pretty-printed across multiple lines, this will fail to parse. It's safer to read the entire file content.

Suggested change
with open("/etc/fluid/config/config.json", "r") as f:
lines = f.readlines()
rawStr = lines[0]
with open("/etc/fluid/config/config.json", "r") as f:
rawStr = f.read()

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.35%. Comparing base (b0222b2) to head (c2f243c).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5901      +/-   ##
==========================================
+ Coverage   62.59%   63.35%   +0.76%     
==========================================
  Files         480      481       +1     
  Lines       32801    33070     +269     
==========================================
+ Hits        20533    20953     +420     
+ Misses      10633    10442     -191     
- Partials     1635     1675      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds controller-side validation to prevent ThinRuntime “reference dataset mode” (datasets mounting dataset://...) from referencing a physical Dataset backed by CacheRuntime, and updates sample documentation accordingly.

Changes:

  • Extend RuntimeReconciler.CheckIfReferenceDatasetIsSupported to reject ThinRuntime reference datasets when the physical dataset’s runtime type is CacheRuntime.
  • Add/extend unit tests covering ThinRuntime reference dataset acceptance/rejection cases.
  • Add/update ThinRuntime and cross-namespace dataset sharing docs (EN + ZH) with explicit constraints.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/controllers/runtime_controller.go Adds runtime-type validation for physical datasets referenced by ThinRuntime reference datasets.
pkg/controllers/runtime_controller_test.go Updates and expands unit tests for reference dataset support checks.
docs/zh/samples/thinruntime.md Adds a highlighted note describing ThinRuntime modes and the CacheRuntime restriction.
docs/zh/samples/dataset_across_namespace_with_sidecar.md Adds a warning note about CacheRuntime not being supported as the physical runtime.
docs/zh/samples/dataset_across_namespace_with_csi.md Adds a warning note about CacheRuntime not being supported as the physical runtime.
docs/en/samples/thinruntime.md Adds a new English ThinRuntime sample doc (Minio example) including the CacheRuntime restriction note.
docs/en/samples/dataset_across_namespace_with_sidecar.md Adds a warning note about CacheRuntime not being supported as the physical runtime.
docs/en/samples/dataset_across_namespace_with_csi.md Adds a warning note about CacheRuntime not being supported as the physical runtime.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/controllers/runtime_controller.go Outdated
Comment thread docs/zh/samples/dataset_across_namespace_with_sidecar.md Outdated
Comment thread docs/en/samples/thinruntime.md
Comment on lines +133 to +137
1. Read the JSON string from the `/etc/fluid/config.json` file. Fluid stores and mounts the parameters required for Fuse client mounting to the `/etc/fluid/config.json` file in the Fuse container.
2. Parse the JSON string and extract the parameters required for Fuse client mounting. For example, `url`, `bucket`, `minio-access-key`, `minio-access-secret`, and other parameters in the above example.
3. After extracting the required parameters, output the mount script to the file `mount-minio.sh`

| ⚠️ Note: Starting from Fluid v1.0.0, encryption parameters defined in `dataset.spec.mounts[*].encryptOptions` cannot be directly obtained from the `/etc/fluid/config.json` file. The `/etc/fluid/config.json` file only provides the storage paths for each encryption parameter value, so the parameter parsing script needs to perform additional file reading operations (e.g., "export AWS_ACCESS_KEY_ID=\`cat $akId\`" in the above example).
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

keep the same as chinese version.

Signed-off-by: xliuqq <xlzq1992@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Fail("Expected an error but got nil")
}
Expect(supported).To(BeFalse())
Expect(err.Error()).To(ContainSubstring("CacheRuntime is not supported"))
Comment thread docs/zh/samples/dataset_mount_dataset_subpath.md Outdated
Comment thread docs/zh/samples/dataset_across_namespace_with_sidecar.md Outdated
Copy link
Copy Markdown
Collaborator

@cheyang cheyang left a comment

Choose a reason for hiding this comment

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

The core logic looks good — catching unsupported CacheRuntime at the controller level is the right call since the physical dataset's runtime type may not be available at admission time. A few things need fixing before merge though.

Design question (non-blocking): The current check only rejects CacheRuntime (blacklist style). If new incompatible runtime types appear later, this code needs updating. Worth considering a whitelist approach (only allow known-compatible types) to be more future-proof — but that's a follow-up discussion.

Missing test coverage: There's no test for the case where the physical dataset hasn't been bound yet (Status.Runtimes is empty). GetRuntimeInfo would fall into the default case and error. A test for this path would prevent regressions.

Comment thread pkg/controllers/runtime_controller_test.go Outdated
Comment thread docs/zh/samples/dataset_across_namespace_with_sidecar.md Outdated
Signed-off-by: xliuqq <xlzq1992@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread pkg/controllers/runtime_controller.go Outdated
Comment thread docs/en/samples/dataset_across_namespace_with_sidecar.md Outdated
Comment thread docs/en/samples/dataset_across_namespace_with_csi.md Outdated
Signed-off-by: xliuqq <xlzq1992@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@cheyang cheyang left a comment

Choose a reason for hiding this comment

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

Previous review comments have been addressed. The CheckIfReferenceDatasetIsSupported logic now correctly validates physical runtime types, and the documentation typos are fixed. LGTM.

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 28, 2026

/lgtm
/approve

@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented May 28, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheyang

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@cheyang cheyang merged commit 823e07e into fluid-cloudnative:master May 28, 2026
27 of 28 checks passed
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.

[CacheRuntime] prevent ThinRuntime pointing to a CacheRuntime-backed Dataset

3 participants