-
Notifications
You must be signed in to change notification settings - Fork 950
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
refact: refact disk quota api #2704
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2704 +/- ##
========================================
Coverage ? 69.3%
========================================
Files ? 278
Lines ? 17424
Branches ? 0
========================================
Hits ? 12076
Misses ? 4023
Partials ? 1325
|
The code-check CI fails. Please update the code. Thanks |
Diskquota is a very essential feature for users. But I am afraid that this is not a general feature on any os distributions. So, FWIW, shall we make diskquota feature a plugin which could be enabled or disabled explicitly. @rudyfly |
66bebb9
to
37c682a
Compare
|
||
> valid `quota-id` which is larger than 0 is only used in `upgrade` interface. In this scenario of triggering `upgrade` interface, pouchd will remove the old container and use the new image to take place of old container's image, and create a new container which should inherit the original diskquota. Then user can pass an original `quota-id` of original container to take effect on newly created container. | ||
> 1. `rule1` can't use with `rule2/rule3/rule4` together; | ||
> 2. if it has set quota-id isn't null or `0`, `--disk-quota` only can been set with one rule, or means the length of disk quota slice is `1`. |
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.
sed "if it has set quota-id/quota-id"
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.
modified
> 2. if it has set quota-id isn't null or `0`, `--disk-quota` only can been set with one rule, or means the length of disk quota slice is `1`. | ||
> 3. `rule3` use `&` link with directory that must be absolute path, can't be regular expression with `rule4`; | ||
> 4. no special characters(`* & ;`) can exist in all mount points | ||
> 5. valid `quota-id` which is larger than `16777216` is only used in `upgrade` interface. In this scenario of triggering `upgrade` interface, pouchd will remove the old container and use the new image to take place of old container's image, and create a new container which should inherit the original diskquota. Then user can pass an original `quota-id` of original container to take effect on newly created container. |
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.
Using a given quota-id is a common scene, not only in 'upgrade' interface.
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.
modified
66deaaf
to
505019a
Compare
daemon/mgr/container_storage.go
Outdated
) | ||
|
||
if c.Config.QuotaID != "" { | ||
if c.Config.QuotaID != "" && c.Config.QuotaID != "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.
maybe we need lock here? This action will take long time. If we don't add lock, there maybe some confusing with concurrent update request
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.
update and create should be conflict, so I think no need to add lock here
There are four ways to identify the input format: | ||
|
||
* rule1: `--disk-quota=10GB` : maps container rootfs and all potential volumes binded inside; | ||
* rule2: `--disk-quota=/abc=10GB` : absolute path matching, maps only mount point `/abc` has been limited, container rootfs and any volume haven't been limited; |
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.
any 'other' volumes haven't been limited
test/cli_run_volume_test.go
Outdated
"--name", containerName, busyboxImage, "df") | ||
defer DelContainerForceMultyTime(c, containerName) | ||
ret.Assert(c, icmd.Success) | ||
|
||
out := ret.Stdout() | ||
fmt.Printf("%s\n", out) |
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.
remove this debug line?
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.
ok
for pouch cli command, support two api: ```bash --disk-quota []string --quota-id string ``` --disk-quota can be set: 1. --disk-quota=60G 2. --disk-quota=/abc=60G 3. --disk-quota=/&/abc=60G 4. --disk-quota=.*=60G --quota-id can be set: 1. --quota-id=0, or haven't set quota id(--quota-id="") 2. --quota-id=-1 3. --quota-id=16777216, or more than 16777216 detail rules you can see disk quota documents. validate disk quota config when create container, add test case for disk quota. Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
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
Ⅰ. Describe what this PR did
for pouch cli command, support two api:
--disk-quota can be set:
--quota-id can be set:
detail rules you can see disk quota documents.
validate disk quota config when create container,
add test case for disk quota.
Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
added
Ⅳ. Describe how to verify it
run disk quota test case
Ⅴ. Special notes for reviews
Signed-off-by: Rudy Zhang rudyflyzhang@gmail.com