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

refact: refact disk quota api #2704

Merged
merged 1 commit into from
Feb 28, 2019

Conversation

rudyfly
Copy link
Collaborator

@rudyfly rudyfly commented Feb 3, 2019

Ⅰ. Describe what this PR did

for pouch cli command, support two api:

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

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

@codecov
Copy link

codecov bot commented Feb 3, 2019

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #2704   +/-   ##
========================================
  Coverage          ?   69.3%           
========================================
  Files             ?     278           
  Lines             ?   17424           
  Branches          ?       0           
========================================
  Hits              ?   12076           
  Misses            ?    4023           
  Partials          ?    1325
Flag Coverage Δ
#criv1alpha2_test 39.43% <39.68%> (?)
#integration_test_0 36.61% <26.98%> (?)
#integration_test_1 35.54% <24.6%> (?)
#integration_test_2 36.6% <24.6%> (?)
#integration_test_3 35.48% <24.6%> (?)
#node_e2e_test 35.33% <24.6%> (?)
#unittest 27.55% <16.66%> (?)
Impacted Files Coverage Δ
apis/opts/diskquota.go 93.93% <100%> (ø)
storage/quota/quota.go 13.45% <100%> (ø)
daemon/mgr/container_validation.go 42.92% <40.9%> (ø)
daemon/mgr/container.go 60.58% <45.45%> (ø)
daemon/mgr/container_storage.go 60.34% <47.14%> (ø)

@fuweid
Copy link
Contributor

fuweid commented Feb 11, 2019

daemon/mgr/container_storage.go:476:26:warning: should drop = 0 from declaration of var globalQuotaID; it is the zero value (golint)

The code-check CI fails. Please update the code. Thanks

@allencloud
Copy link
Collaborator

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

@rudyfly rudyfly force-pushed the diskquota branch 3 times, most recently from 66bebb9 to 37c682a Compare February 15, 2019 09:15

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

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"

Copy link
Collaborator Author

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

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

modified

daemon/mgr/container_validation.go Outdated Show resolved Hide resolved
daemon/mgr/container_storage.go Show resolved Hide resolved
)

if c.Config.QuotaID != "" {
if c.Config.QuotaID != "" && c.Config.QuotaID != "0" {
Copy link
Contributor

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

Copy link
Collaborator Author

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

daemon/mgr/container_validation.go Outdated Show resolved Hide resolved
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;
Copy link
Contributor

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

"--name", containerName, busyboxImage, "df")
defer DelContainerForceMultyTime(c, containerName)
ret.Assert(c, icmd.Success)

out := ret.Stdout()
fmt.Printf("%s\n", out)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this debug line?

Copy link
Collaborator Author

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

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

@fuweid fuweid merged commit a373ba9 into AliyunContainerService:master Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants