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

bugfix: set device limit by the mountpoint #2154

Merged
merged 1 commit into from
Aug 28, 2018

Conversation

rudyfly
Copy link
Collaborator

@rudyfly rudyfly commented Aug 23, 2018

Ⅰ. Describe what this PR did

set device limit by the mountpoint.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

No need to add test case.

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Signed-off-by: Rudy Zhang [email protected]

@pouchrobot pouchrobot added kind/bug This is bug report for project size/M labels Aug 23, 2018
@codecov-io
Copy link

codecov-io commented Aug 23, 2018

Codecov Report

Merging #2154 into master will decrease coverage by 0.15%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2154      +/-   ##
=========================================
- Coverage   64.46%   64.3%   -0.16%     
=========================================
  Files         209     209              
  Lines       16680   16713      +33     
=========================================
- Hits        10752   10748       -4     
- Misses       4599    4637      +38     
+ Partials     1329    1328       -1
Flag Coverage Δ
#criv1alpha1test 32.92% <0%> (-0.09%) ⬇️
#criv1alpha2test 33.6% <0%> (-0.01%) ⬇️
#integrationtest 39.24% <0%> (-0.07%) ⬇️
#unittest 23.92% <0%> (-0.06%) ⬇️
Impacted Files Coverage Δ
storage/quota/quota.go 12.02% <0%> (-5.81%) ⬇️
storage/quota/prjquota.go 12.58% <0%> (+1.87%) ⬆️
storage/quota/grpquota.go 0% <0%> (ø) ⬆️
cri/stream/httpstream/spdy/upgrade.go 54.28% <0%> (-5.72%) ⬇️
ctrd/image.go 75% <0%> (-3.95%) ⬇️
cri/v1alpha1/cri.go 63.71% <0%> (+0.34%) ⬆️
daemon/logger/jsonfile/utils.go 73.17% <0%> (+1.62%) ⬆️
ctrd/watch.go 80.3% <0%> (+3.03%) ⬆️
apis/server/utils.go 66.66% <0%> (+4.76%) ⬆️

@@ -321,19 +321,30 @@ func (quota *PrjQuotaDriver) setDevLimit(dir string, devID uint64) (uint64, erro
return limit, nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to update the function in grpquota, it seems like a common interface function implement.


// setDevLimit sets device storage upper limit in quota driver according to inpur dir.
func setDevLimit(dir string, devID uint64) (uint64, error) {
if limit, exist := devLimits[devID]; exist {
Copy link
Collaborator

@allencloud allencloud Aug 28, 2018

Choose a reason for hiding this comment

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

Do we need to add lock here to avoid race section reading?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes,

@Ace-Tang
Copy link
Contributor

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Aug 28, 2018
continue
}

if strings.HasPrefix(dir, parts[1]) && len(parts[1]) > len(mountPoint) {
Copy link
Collaborator

@allencloud allencloud Aug 28, 2018

Choose a reason for hiding this comment

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

What will happen if there are two reacords in procMountFile and the input dir name is /home/pouch? @rudyfly

/dev/sdb1 /home/pouch ext4 rw,relatime,prjquota,data=ordered 0 0
/dev/sdb2 /home/pouch/a/b/c ext4 rw,relatime,prjquota,data=ordered 0 0

Or is there any possibility that two similar records exist there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have checked len(parts[1]) > len(mountPoint), It will choose the longest mount tab.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Roger, How about adding this details in the comment of this function or the code block? @rudyfly
Otherwise, I think there will be confusions there.

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

@@ -320,3 +329,90 @@ func loadQuotaIDs(repquotaOpt string) (map[uint32]struct{}, uint32, error) {
logrus.Infof("Load repquota ids: %d, list: %v", len(quotaIDs), quotaIDs)
return quotaIDs, minID, nil
}

func getMountpoint(dir string) (string, error) {
var (
Copy link
Contributor

Choose a reason for hiding this comment

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

codes duplicate with prjquota.CheckMountpoint

@allencloud
Copy link
Collaborator

Could you rebase to the latest master? @rudyfly


// setDevLimit sets device storage upper limit in quota driver according to inpur dir.
func setDevLimit(dir string, devID uint64) (uint64, error) {
if limit, exist := devLimits[devID]; exist {
Copy link
Contributor

Choose a reason for hiding this comment

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

devLimits represent the device block size limitation


// checkDevLimit checks if the device on which the input dir lies has already been recorded in driver.
func checkDevLimit(dir string, size uint64) error {
devID, err := system.GetDevID(dir)
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate code, we just call setDevLimit is enough, WDYT???

Copy link
Contributor

Choose a reason for hiding this comment

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

forget add lock???

@rudyfly rudyfly force-pushed the diskquota branch 2 times, most recently from b3efeaa to b36cc5b Compare August 28, 2018 03:55
@rudyfly
Copy link
Collaborator Author

rudyfly commented Aug 28, 2018

@allencloud I have done rebase master.

set device limit by the mountpoint.

Signed-off-by: Rudy Zhang <[email protected]>
@HusterWan
Copy link
Contributor

lgtm

@HusterWan HusterWan merged commit 01872d5 into AliyunContainerService:master Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants