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

ctrd/daemon: support PlainHttp pull/push image #2810

Merged
merged 1 commit into from
Apr 26, 2019
Merged

ctrd/daemon: support PlainHttp pull/push image #2810

merged 1 commit into from
Apr 26, 2019

Conversation

fuweid
Copy link
Contributor

@fuweid fuweid commented Apr 24, 2019

Signed-off-by: Wei Fu fuweid89@gmail.com

Ⅰ. Describe what this PR did

If the user sets the insecure registries, pouch will use PlainHTTP or
HTTPs with unknown CA to pull or push image. For example, there are
two registries

  1. 172.17.0.7:5000
  2. 172.17.0.2:5000 my.testingregistry.com

We can use pouchd --insecure-registries my.testingregistry.com:5000 --insecure-registries 172.17.0.7:5000 to start pouch daemon. Then we
can pull or push any images from my.testingregistry.com:5000 or
172.17.0.7:5000 with PlainHTTP. But we cannot do it with
172.17.0.2:5000.

Ⅱ. Does this pull request fix one issue?

Fix: #2663

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

added

Ⅳ. Describe how to verify it

CI

Ⅴ. Special notes for reviews

If the user sets the insecure registries, pouch will use PlainHTTP or
HTTPs with unknown CA to pull or push image. For example, there are
two registries

  1. 172.17.0.7:5000
  2. 172.17.0.2:5000 my.testingregistry.com

We can use `pouchd --insecure-registries my.testingregistry.com:5000
--insecure-registries 172.17.0.7:5000` to start pouch daemon. Then we
can pull or push any images from my.testingregistry.com:5000 or
172.17.0.7:5000 with PlainHTTP. But we cannot do it with
172.17.0.2:5000.

Fix: #2663

Signed-off-by: Wei Fu <fuweid89@gmail.com>
@codecov
Copy link

codecov bot commented Apr 24, 2019

Codecov Report

Merging #2810 into master will increase coverage by 0.13%.
The diff coverage is 84.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2810      +/-   ##
==========================================
+ Coverage   69.34%   69.48%   +0.13%     
==========================================
  Files         278      278              
  Lines       17397    17428      +31     
==========================================
+ Hits        12064    12109      +45     
+ Misses       3983     3976       -7     
+ Partials     1350     1343       -7
Flag Coverage Δ
#criv1alpha2_test 39.28% <45.45%> (-0.02%) ⬇️
#integration_test_0 36.56% <45.45%> (+0.02%) ⬆️
#integration_test_1 35.35% <45.45%> (+0.01%) ⬆️
#integration_test_2 36.58% <45.45%> (+0.03%) ⬆️
#integration_test_3 35.42% <45.45%> (-0.05%) ⬇️
#node_e2e_test 35.12% <45.45%> (+0.1%) ⬆️
#unittest 28.78% <50%> (+0.08%) ⬆️
Impacted Files Coverage Δ
daemon/config/config.go 67.85% <ø> (ø) ⬆️
daemon/daemon.go 70.05% <100%> (+0.15%) ⬆️
ctrd/client.go 69.72% <100%> (+0.33%) ⬆️
ctrd/client_opts.go 68.18% <100%> (+31.81%) ⬆️
ctrd/image.go 69.96% <50%> (ø) ⬆️
ctrd/utils.go 78.94% <64.7%> (-4.39%) ⬇️
cri/v1alpha2/cri.go 71.48% <0%> (+0.51%) ⬆️
daemon/mgr/container.go 60.25% <0%> (+0.84%) ⬆️
ctrd/container.go 54.64% <0%> (+1.13%) ⬆️
apis/server/utils.go 75% <0%> (+3.84%) ⬆️

func validateHostPort(s string) error {
_, port, err := net.SplitHostPort(s)
if err != nil {
port = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not return err?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe it is domain name without any port, such as 80


// InsecureRegistries sets insecure registries to allow to pull
// insecure registries.
InsecureRegistries []string `json:"insecure-registries,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

add daemon test for this config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is hard to add this case right now because we need to download the registry and push the image in there. I am not sure how to make it easier to add it into repo.

@rudyfly
Copy link
Collaborator

rudyfly commented Apr 26, 2019

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Apr 26, 2019
@rudyfly rudyfly merged commit 33a9d82 into AliyunContainerService:master Apr 26, 2019
@fuweid fuweid deleted the me-http-pull branch April 26, 2019 04:33
// isInsecureDomain will return true if the domain of reference is in the
// insecure registry. The insecure registry will accept HTTP or HTTPS with
// certificates from unknown CAs.
func (c *Client) isInsecureDomain(ref string) bool {
Copy link
Collaborator

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 unit test cases for this function?

}
}

func validateHostPort(s string) error {
Copy link
Collaborator

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 unit test cases for this function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Can pouchd support http protocol when pull image?
4 participants