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: add envs for pouch exec #2250

Merged
merged 2 commits into from
Sep 19, 2018

Conversation

knightXun
Copy link
Contributor

@knightXun knightXun commented Sep 18, 2018

Ⅰ. Describe what this PR did

Provide new Environments for pouch exec

Ⅱ. Does this pull request fix one issue?

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Sep 18, 2018

Codecov Report

❗ No coverage uploaded for pull request head (envs@8cb32d2). Click here to learn what that means.
The diff coverage is n/a.

@CLAassistant
Copy link

CLAassistant commented Sep 18, 2018

CLA assistant check
All committers have signed the CLA.

}

mgr.ExecProcesses.Put(execid, execConfig)

return execid, nil
}

// MergeEnvs merge oldEnvs with new Env
func MergeEnvs(oldEnv, newEnv []string) []string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am wondering if that we have already supported this function, in https://github.com/alibaba/pouch/blob/master/daemon/mgr/container_utils.go#L262
I think this is a common function.

apis/swagger.yml Outdated
@@ -3193,6 +3193,11 @@ definitions:
minItems: 1
items:
type: "string"
Env:
type: "array"
description: "Env for commands"
Copy link
Collaborator

Choose a reason for hiding this comment

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

envs for exec command in container
I think this is more specific.

@@ -41,7 +41,7 @@ type RegistryServiceConfig struct {
// > are in compliance with any terms that cover redistributing
// > nondistributable artifacts.
//
AllowNondistributableArtifactsCIDRs []string `json:"AllowNondistributableArtifactsCIDRs,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert this file when you git commit. We do not need this change. And the change done by swagger-0.12.0 is because swagger has a bug in itself.

cli/exec.go Outdated
@@ -51,6 +52,7 @@ func (e *ExecCommand) addFlags() {
flagSet.BoolVarP(&e.Terminal, "tty", "t", false, "Allocate a tty device")
flagSet.BoolVarP(&e.Interactive, "interactive", "i", false, "Open container's STDIN")
flagSet.StringVarP(&e.User, "user", "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
flagSet.StringArrayVarP(&e.Envs,"env","e", []string{}, "Set environment variables")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Set environment variables for exec command in container

"github.com/pkg/errors"
"strings"
Copy link
Collaborator

Choose a reason for hiding this comment

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

please package strings would be in the first part, not in the third-part one.

@@ -27,18 +29,48 @@ func (mgr *ContainerManager) CreateExec(ctx context.Context, name string, config
return "", fmt.Errorf("container %s is not running", c.ID)
}

Envs := MergeEnvs(c.Config.Env, config.Env)
logrus.Info("Envs", Envs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line of log is Info, and I think it is too casual. It will add more info log in production. How about changing this into Debugf?

@allencloud
Copy link
Collaborator

Please also the corresponding cli integration test for this pull request. Thanks a lot. @knightXun

@allencloud allencloud changed the title add envs for pouch exec featureadd envs for pouch exec Sep 18, 2018
@allencloud allencloud changed the title featureadd envs for pouch exec feature: add envs for pouch exec Sep 18, 2018
@knightXun
Copy link
Contributor Author

@allencloud I will add tests for this.

@pouchrobot pouchrobot added size/M and removed size/S labels Sep 18, 2018
@pouchrobot
Copy link
Collaborator

@knightXun Thanks for your contribution. 🍻
Please sign off in each of your commits.

@knightXun
Copy link
Contributor Author

knightXun commented Sep 19, 2018

@pouchrobot /test

@allencloud
Copy link
Collaborator

LGTM, and would you like to sign the cla again? Since Alibaba org has updated something, then everyone of us needs to sign it again. @knightXun

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Sep 19, 2018
@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #2250 into master will increase coverage by 0.04%.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2250      +/-   ##
==========================================
+ Coverage    66.7%   66.74%   +0.04%     
==========================================
  Files         208      208              
  Lines       16919    16923       +4     
==========================================
+ Hits        11286    11296      +10     
- Misses       4268     4272       +4     
+ Partials     1365     1355      -10
Flag Coverage Δ
#criv1alpha1test 32.53% <60%> (+0.12%) ⬆️
#criv1alpha2test 36.15% <60%> (+0.18%) ⬆️
#integrationtest 39.33% <60%> (-0.18%) ⬇️
#nodee2etest 33.51% <60%> (+0.12%) ⬆️
#unittest 23.76% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
daemon/mgr/container_types.go 83.63% <ø> (ø) ⬆️
daemon/mgr/container_exec.go 67.28% <60%> (-0.68%) ⬇️
daemon/mgr/system.go 70.49% <0%> (-7.38%) ⬇️
daemon/mgr/container_utils.go 81.92% <0%> (-2.41%) ⬇️
daemon/containerio/container_io.go 74.58% <0%> (-1.11%) ⬇️
pkg/meta/store.go 63.28% <0%> (-0.79%) ⬇️
ctrd/container.go 59.76% <0%> (-0.48%) ⬇️
daemon/mgr/container.go 57.59% <0%> (+0.4%) ⬆️
cri/v1alpha2/cri.go 67.61% <0%> (+1.19%) ⬆️
ctrd/image.go 78.94% <0%> (+2.19%) ⬆️
... and 2 more

1 similar comment
@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #2250 into master will increase coverage by 0.04%.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2250      +/-   ##
==========================================
+ Coverage    66.7%   66.74%   +0.04%     
==========================================
  Files         208      208              
  Lines       16919    16923       +4     
==========================================
+ Hits        11286    11296      +10     
- Misses       4268     4272       +4     
+ Partials     1365     1355      -10
Flag Coverage Δ
#criv1alpha1test 32.53% <60%> (+0.12%) ⬆️
#criv1alpha2test 36.15% <60%> (+0.18%) ⬆️
#integrationtest 39.33% <60%> (-0.18%) ⬇️
#nodee2etest 33.51% <60%> (+0.12%) ⬆️
#unittest 23.76% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
daemon/mgr/container_types.go 83.63% <ø> (ø) ⬆️
daemon/mgr/container_exec.go 67.28% <60%> (-0.68%) ⬇️
daemon/mgr/system.go 70.49% <0%> (-7.38%) ⬇️
daemon/mgr/container_utils.go 81.92% <0%> (-2.41%) ⬇️
daemon/containerio/container_io.go 74.58% <0%> (-1.11%) ⬇️
pkg/meta/store.go 63.28% <0%> (-0.79%) ⬇️
ctrd/container.go 59.76% <0%> (-0.48%) ⬇️
daemon/mgr/container.go 57.59% <0%> (+0.4%) ⬆️
cri/v1alpha2/cri.go 67.61% <0%> (+1.19%) ⬆️
ctrd/image.go 78.94% <0%> (+2.19%) ⬆️
... and 2 more

@allencloud allencloud merged commit c2553d6 into AliyunContainerService:master Sep 19, 2018
@@ -27,11 +27,18 @@ func (mgr *ContainerManager) CreateExec(ctx context.Context, name string, config
return "", fmt.Errorf("container %s is not running", c.ID)
}

envs, err := mergeEnvSlice(c.Config.Env, config.Env)
Copy link
Contributor

Choose a reason for hiding this comment

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

first argu of mergeEnvSlice should config.Env

ping @knightXun cc @HusterWan

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will correct it tonight

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/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants