Skip to content

Conversation

@Ace-Tang
Copy link
Contributor

check cgroup resource valid in container create,
discard un-support cgroup set related flag.

Signed-off-by: Ace-Tang [email protected]

Ⅰ. Describe what this PR did

Pouch run get lots of flags that whether these flags can be set depend on the
corresponding cgroup file is exist. Add check for the cgroup file is needed.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@HusterWan
Copy link
Contributor

@Ace-Tang please create PR base on branch 0.5.x, thanks a lot !!! 💯

@Ace-Tang
Copy link
Contributor Author

Hi, @HusterWan , the pr won't include in 0.5.0

@codecov-io
Copy link

codecov-io commented May 25, 2018

Codecov Report

Merging #1375 into master will increase coverage by 18.69%.
The diff coverage is 45.78%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1375       +/-   ##
===========================================
+ Coverage   16.23%   34.92%   +18.69%     
===========================================
  Files         200      255       +55     
  Lines       13583    18329     +4746     
===========================================
+ Hits         2205     6402     +4197     
+ Misses      11224    11084      -140     
- Partials      154      843      +689
Impacted Files Coverage Δ
daemon/mgr/container_utils.go 51.31% <13.4%> (+1.69%) ⬆️
daemon/mgr/container.go 49.31% <66.66%> (+49.31%) ⬆️
pkg/system/cgroup.go 93.65% <93.65%> (ø)
cri/v1alpha1/cri_utils.go 0% <0%> (-29.32%) ⬇️
cri/v1alpha2/cri_utils.go 0% <0%> (-28.42%) ⬇️
pkg/utils/utils.go 71.21% <0%> (-1.84%) ⬇️
cli/pause.go 0% <0%> (ø) ⬆️
cli/main.go 0% <0%> (ø) ⬆️
cli/tag.go
client/image_tag.go
... and 128 more

}

func getMemoryCgroupInfo(root string) *MemoryCgroupInfo {
path := root + "/" + "memory"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change to path.Join is more better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or root + "/memory" more single?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I do not think root + "/memory" is a good way. String append via + is not very readable and brings some difficulty to code review. While I think for path, we can use path.Join like @rudyfly suggested. For others, I suggested that we should use format to make it like: fmt.Sprintf("you told me %s", msg).

So I think we had better update this.

}

func getCPUCgroupInfo(root string) *CPUCgroupInfo {
cpuPath := root + "/" + "cpu"
Copy link
Collaborator

Choose a reason for hiding this comment

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

As before

"github.com/alibaba/pouch/pkg/errtypes"
"github.com/alibaba/pouch/pkg/meta"
"github.com/alibaba/pouch/pkg/randomid"
"github.com/alibaba/pouch/pkg/system"
Copy link
Contributor

Choose a reason for hiding this comment

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

please put the github.com/sirupsen/logrus into next import group

}

// validate container Config
warnings, err := validateConfig(config)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this part validation could be located in the API bridge layer. WDYT? @Ace-Tang @fuweid

Copy link
Contributor

Choose a reason for hiding this comment

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

@allencloud the config has changed by ContainerManager).Create, like

if config.HostConfig.EnableLxcfs && lxcfs.IsLxcfsEnabled {
 		config.HostConfig.Binds = append(config.HostConfig.Binds, lxcfs.LxcfsParentDir+":/var/lib/lxc:shared")
 		sourceDir := lxcfs.LxcfsHomeDir + "/proc/"
 		destDir := "/proc/"
 		for _, procFile := range lxcfs.LxcfsProcFiles {
 			bind := fmt.Sprintf("%s%s:%s%s", sourceDir, procFile, destDir, procFile)
 			config.HostConfig.Binds = append(config.HostConfig.Binds, bind)
 		}
 	}

I don't think we can do validation in the API bridge level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fuweid ,do you mean config is merged with something after ContainerManager).Create?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes @Ace-Tang . If we can move the merge function into bridge, the validation can be done in bridge, too.

check cgroup resource valid in container create,
discard un-support cgroup set related flag.

Signed-off-by: Ace-Tang <[email protected]>
@Ace-Tang
Copy link
Contributor Author

@allencloud @rudyfly @fuweid , updated as comment, but except validate location, as @fuweid said, config will changed in Create funtion.

@Ace-Tang
Copy link
Contributor Author

Ace-Tang commented Jun 1, 2018

CRI ci test fail

@allencloud
Copy link
Collaborator

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Jun 4, 2018
@allencloud allencloud merged commit f2adcde into AliyunContainerService:master Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature 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.

7 participants