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

fix default value #4144

Merged
merged 4 commits into from
Jun 4, 2024
Merged

Conversation

frankleaf
Copy link
Member

Ⅰ. 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

Signed-off-by: frankleaf <[email protected]>
@cheyang
Copy link
Collaborator

cheyang commented May 30, 2024

@frankleaf Please fix the ut. Thanks.

Signed-off-by: frankleaf <[email protected]>
@frankleaf
Copy link
Member Author

@frankleaf Please fix the ut. Thanks.
done

Copy link
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.

I suggest refactoring this piece of code. Thanks.

metaPolicy = mount.Options["metaPolicy"]
}

if mount.Options["metaPolicy"] == "ONCE" {
metaPolicy = mount.Options["metaPolicy"]
if mount.Options["cacheStrategy"] == "DHT" && metaPolicy == "ONCE" {
Copy link
Collaborator

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
    }
}

readCacheReplica := 1
writeCacheReplica := 1

if mount.Options["cacheStrategy"] == "DHT" && mount.Options["metaPolicy"] == "ONCE" {
cacheStrategy = mount.Options["cacheStrategy"]
if mount.Options["metaPolicy"] == "ALWAYS" {
Copy link
Collaborator

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
    }
}

frankleaf added 2 commits June 4, 2024 13:29
Signed-off-by: frankleaf <[email protected]>
Signed-off-by: frankleaf <[email protected]>
Copy link

sonarqubecloud bot commented Jun 4, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
24.3% Duplication on New Code

See analysis details on SonarCloud

Copy link
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.

/lgtm
/approve

Copy link

fluid-e2e-bot bot commented Jun 4, 2024

[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

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

@fluid-e2e-bot fluid-e2e-bot bot merged commit cb6c5c6 into fluid-cloudnative:master Jun 4, 2024
7 checks passed
cheyang pushed a commit to Ametsuji-akiya/fluid that referenced this pull request Jul 16, 2024
* fix default value

Signed-off-by: frankleaf <[email protected]>

* fix ut

Signed-off-by: frankleaf <[email protected]>

* fix ut

Signed-off-by: frankleaf <[email protected]>

* fix ut

Signed-off-by: frankleaf <[email protected]>

---------

Signed-off-by: frankleaf <[email protected]>
Signed-off-by: cheyang <[email protected]>
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.

2 participants