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

[Feature]: Supports write disable option #2537

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

NaturalSelect
Copy link
Collaborator

@NaturalSelect NaturalSelect commented Aug 23, 2023

What this PR does / why we need it:

  • Supports write disable option("Forbidden")
┌──(root💀LAPTOP-9TS0FG11)-[/home/nature/cubefs]
└─# ./build/bin/cfs-cli vol set-forbidden ltptest true
Volume forbidden property has been set successfully.

┌──(root💀LAPTOP-9TS0FG11)-[/home/nature/cubefs]
└─# ./build/bin/cfs-cli vol set-forbidden ltptest false
Volume forbidden property has been set successfully.

NOTE: master will put partition status to node, only when their status inconsistent with master, this check process will be completed by heartbeat.

Forbid a volume:

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ rm a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt
-bash: echo: write error: Input/output error

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt
-bash: echo: write error: Input/output error

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> a.txt
-bash: echo: write error: Input/output error

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ cat a.txt
1
1
1
1
1
1
1

Unforbid a volume:

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "1" >> b.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ cat b.txt
1

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ echo "2" >> a.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ ls
a.txt  b.txt

┌──(nature㉿LAPTOP-9TS0FG11)-[~/disk/client/mnt]
└─$ cat a.txt
1
1
1
1
1
1
1
2

NOTE: When I unforbid the partition, execute echo "2" >> a.txt still get a I/O error, but it will success when I execute echo "1" >> b.txt, I don't know what cause the problem, please let me know if you have any idea about it.

Which issue this PR fixes:

fixes #2477

Special notes for your reviewer:

  • Please contract me, if the pull request passed the review.

  • Maybe update client to check "forbidden partition error" is necessarily.

Release note:

@NaturalSelect
Copy link
Collaborator Author

@leonrayang Please take a look.

@codecov
Copy link

codecov bot commented Aug 23, 2023

Codecov Report

❗ No coverage uploaded for pull request base (master@bf04fd0). Click here to learn what that means.
The diff coverage is 35.55%.

❗ Current head e5915fb differs from pull request most recent head 0b086b6. Consider uploading reports for the commit 0b086b6 to get more accurate results

@@            Coverage Diff            @@
##             master    #2537   +/-   ##
=========================================
  Coverage          ?   41.36%           
=========================================
  Files             ?      553           
  Lines             ?   113608           
  Branches          ?        0           
=========================================
  Hits              ?    46998           
  Misses            ?    62615           
  Partials          ?     3995           
Files Changed Coverage Δ
datanode/partition.go 0.00% <0.00%> (ø)
datanode/partition_raft.go 0.00% <ø> (ø)
datanode/space_manager.go 0.00% <0.00%> (ø)
datanode/wrap_operator.go 0.00% <0.00%> (ø)
metanode/manager_op.go 0.00% <0.00%> (ø)
metanode/manager_proxy.go 0.00% <0.00%> (ø)
metanode/partition.go 24.03% <0.00%> (ø)
metanode/partition_op_dentry.go 0.00% <ø> (ø)
metanode/partition_op_extent.go 16.46% <ø> (ø)
metanode/partition_op_inode.go 0.00% <ø> (ø)
... and 11 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Victor1319
Copy link
Member

@NaturalSelect you can take a referenc for mp's follower read isFollowerRead implementation.
checkFollowerRead(volNames []string, partition MetaPartition)

  1. set volume to rdonly
  2. master send volume status to every datanode & metanode, with heartbeat
  3. datanode&matanode update local mp&dp rdonly status according to volume status in heartbeat.

@Victor1319 Victor1319 added the discuss Need to discuss label Aug 25, 2023
@NaturalSelect
Copy link
Collaborator Author

@NaturalSelect you can take a referenc for mp's follower read isFollowerRead implementation. checkFollowerRead(volNames []string, partition MetaPartition)

  1. set volume to rdonly
  2. master send volume status to every datanode & metanode, with heartbeat
  3. datanode&matanode update local mp&dp rdonly status according to volume status in heartbeat.

Yes, that's what I'm doing now.

Victor1319
Victor1319 previously approved these changes Aug 25, 2023
Copy link
Member

@Victor1319 Victor1319 left a comment

Choose a reason for hiding this comment

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

once volume is forbidden, all data partition & meta partition in this volume should also set to be status rdonly in master

metanode/manager_proxy.go Outdated Show resolved Hide resolved
metanode/partition.go Show resolved Hide resolved
metanode/partition_op_extent.go Outdated Show resolved Hide resolved
sdk/master/api_admin.go Outdated Show resolved Hide resolved
datanode/wrap_operator.go Show resolved Hide resolved
master/admin_task_manager.go Outdated Show resolved Hide resolved
master/cluster.go Show resolved Hide resolved
@NaturalSelect NaturalSelect force-pushed the master-dev branch 2 times, most recently from 0dbf4b5 to 324d1e6 Compare August 30, 2023 06:43
@NaturalSelect NaturalSelect force-pushed the master-dev branch 11 times, most recently from 0ec0e07 to a590fdc Compare August 31, 2023 09:19
@NaturalSelect NaturalSelect changed the base branch from develop-3.4.0 to master August 31, 2023 13:10
@netlify
Copy link

netlify bot commented Aug 31, 2023

Deploy Preview for cubefs-check ready!

Name Link
🔨 Latest commit 0b086b6
🔍 Latest deploy log https://app.netlify.com/sites/cubefs-check/deploys/64f19a045525bf000706dfc4
😎 Deploy Preview https://deploy-preview-2537--cubefs-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@Victor1319 Victor1319 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@leonrayang leonrayang left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: NaturalSelect <2145973003@qq.com>
@leonrayang leonrayang merged commit c3ed9ba into cubefs:master Sep 1, 2023
11 checks passed
@Victor1319 Victor1319 added this to the release-3.3.2 milestone Apr 17, 2024
sejust pushed a commit to sejust/cubefs that referenced this pull request Apr 22, 2024
Signed-off-by: NaturalSelect <2145973003@qq.com>
sejust pushed a commit to sejust/cubefs that referenced this pull request Apr 22, 2024
Signed-off-by: NaturalSelect <2145973003@qq.com>
leonrayang pushed a commit that referenced this pull request Apr 22, 2024
Signed-off-by: NaturalSelect <2145973003@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Need to discuss
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: support set volume read only.
3 participants