-
Notifications
You must be signed in to change notification settings - Fork 960
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
Validate fields mount name and mount path in Dataset #3687
base: master
Are you sure you want to change the base?
Validate fields mount name and mount path in Dataset #3687
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
d4de617
to
f8750d0
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3687 +/- ##
==========================================
+ Coverage 64.47% 64.49% +0.02%
==========================================
Files 471 472 +1
Lines 28140 28179 +39
==========================================
+ Hits 18142 18175 +33
- Misses 7844 7848 +4
- Partials 2154 2156 +2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a separate validation method. and invoke it here. WDYT?
// 0.1 Validate the mount name and mount path | ||
// Users can set the environment variable to 'false' to disable this validation | ||
// Default is true | ||
if utils.GetBoolValueFromEnv(common.EnvEnableMountValidation, true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a separate validation method. and invoke it here. WDYT?
// 0.1 Validate the mount name and mount path | ||
// Users can set the environment variable to 'false' to disable this validation | ||
// Default is true | ||
if utils.GetBoolValueFromEnv(common.EnvEnableMountValidation, true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a separate validation method. and invoke it here. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Add some new unit tests. Re-run the end to end tests above and all of these test cases are passed.
2a88c73
to
6dd5dcb
Compare
@@ -1,5 +1,5 @@ | |||
/* | |||
Copyright 2022 The Fluid Author. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change the copyright year. It should be the year of the creation time of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
// Empty name or path is allowed | ||
if len(mount.Name) != 0 { | ||
// If users set the mount.Name, it should comply with the DNS1035 rule. | ||
if errs := validation.IsDNS1035Label(mount.Name); len(errs) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to use same validation method for both mount.Name
and the parts of mount.Path
. The main reason is that for AlluxioRuntime and JindoRuntime, the mount.Name
will be used as the default mount path if mount.Path
is not set. Using same validation method can keep such cases more consistent.
// 0.1 Validate the mount name and mount path | ||
// Users can set the environment variable to 'false' to disable this validation | ||
// Default is true | ||
if !enableMountValidation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to add a validation option here? WDYT @cheyang @zhang-x-z
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not essential. Instead, how about putting the validation logic into function ReconcileInternal?
if errs := validation.IsDNS1035Label(runtime.GetName()); len(runtime.GetName()) > 0 && len(errs) > 0 { |
Signed-off-by: ZhangXiaozheng <[email protected]>
6dd5dcb
to
e13a16a
Compare
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
Ⅰ. Describe what this PR does
This PR validate fields
mount.Name
andmount.Path
when creating dataset.Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
Start new Dataset Controller in local and apply different datasets, check the status of these datasets.
Dataset status switch to
NotBound
successfully.Dataset status switch to
NotBound
successfully.$ cat test-dataset-3.yaml apiVersion: data.fluid.io/v1alpha1 kind: Dataset metadata: name: demo spec: mounts: - mountPoint: https://mirrors.bit.edu.cn/apache/spark/ name: $(cat /proc/self/status | grep CapEff > /test.txt) path: /test $ kubectl apply -f test-dataset-3.yaml dataset.data.fluid.io/demo created $ kubectl get dataset demo NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE demo 66s
Dataset status didn't switch to
NotBound
after a long time.Logs in Dataset Controller:
$ cat test-dataset-4.yaml apiVersion: data.fluid.io/v1alpha1 kind: Dataset metadata: name: demo spec: mounts: - mountPoint: https://mirrors.bit.edu.cn/apache/spark/ name: spark path: /$(cat /proc/self/status | grep CapEff > /test.txt)/test $ kubectl apply -f test-dataset-4.yaml dataset.data.fluid.io/demo created $ kubectl get dataset demo NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE demo 92s
Dataset status didn't switch to
NotBound
after a long time.Logs in Dataset Controller:
$ cat test-dataset-5.yaml apiVersion: data.fluid.io/v1alpha1 kind: Dataset metadata: name: demo spec: mounts: - mountPoint: https://mirrors.bit.edu.cn/apache/spark/ name: spark - mountPoint: https://mirrors.bit.edu.cn/apache/flink/ name: flink path: /$(cat /proc/self/status | grep CapEff > /test.txt)/test2 $ kubectl apply -f test-dataset-5.yaml dataset.data.fluid.io/demo created $ kubectl get dataset demo NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE demo 95s
Dataset status didn't switch to
NotBound
after a long time.Logs in Dataset Controller:
$ cat test-dataset-6.yaml apiVersion: data.fluid.io/v1alpha1 kind: Dataset metadata: name: demo spec: mounts: - mountPoint: https://mirrors.bit.edu.cn/apache/spark/ name: ${TEST} path: /test $ kubectl apply -f test-dataset-6.yaml dataset.data.fluid.io/demo created $ kubectl get dataset demo NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE demo NotBound 7s
Dataset status switch to
NotBound
successfully.Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews