-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix default value #4144
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
fix default value #4144
Conversation
Signed-off-by: frankleaf <frank.wt@alibaba-inc.com>
|
@frankleaf Please fix the ut. Thanks. |
|
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 refactoring this piece of code. Thanks.
pkg/ddc/jindocache/transform.go
Outdated
|
|
||
| if mount.Options["metaPolicy"] == "ONCE" { | ||
| metaPolicy = mount.Options["metaPolicy"] | ||
| if mount.Options["cacheStrategy"] == "DHT" && metaPolicy == "ONCE" { |
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.
There are two checks for mount.Options["cacheStrategy"] == "DHT" in the code. How about using the following way:
if cacheStrategy := mount.Options["cacheStrategy"]; cacheStrategy == "DHT" {
if metaPolicy == "ONCE" {
cacheStrategy = cacheStrategy
} else {
err = fmt.Errorf("CacheStrategy DHT must be used with metaPolicy ONCE and current metaPolicy is %s", metaPolicy)
e.Log.Error(err, "Incorrect metaPolicy", metaPolicy)
return err
}
}
pkg/ddc/jindocache/transform.go
Outdated
|
|
||
| if mount.Options["cacheStrategy"] == "DHT" && mount.Options["metaPolicy"] == "ONCE" { | ||
| cacheStrategy = mount.Options["cacheStrategy"] | ||
| if mount.Options["metaPolicy"] == "ALWAYS" { |
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.
For metaPolicy, it only checks for the "ALWAYS" case but not the "ONCE" case. You might want to add a more thorough check.
if userMetaPolicy, ok := mount.Options["metaPolicy"]; ok {
if userMetaPolicy == "ONCE" || userMetaPolicy == "ALWAYS" {
metaPolicy = userMetaPolicy
} else {
err = fmt.Errorf("Invalid metaPolicy: %s", userMetaPolicy)
e.Log.Error(err, "Invalid metaPolicy")
return err
}
}
|
cheyang
left a comment
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.
/lgtm
/approve
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* fix default value Signed-off-by: frankleaf <frank.wt@alibaba-inc.com> * fix ut Signed-off-by: frankleaf <frank.wt@alibaba-inc.com> * fix ut Signed-off-by: frankleaf <frank.wt@alibaba-inc.com> * fix ut Signed-off-by: frankleaf <frank.wt@alibaba-inc.com> --------- Signed-off-by: frankleaf <frank.wt@alibaba-inc.com> Signed-off-by: cheyang <cheyang@163.com>




Ⅰ. Describe what this PR does
Ⅱ. Does this pull request fix one issue?
fixes #XXXX
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews