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

Add /dbg certs command #3799

Merged
merged 1 commit into from
Feb 25, 2019
Merged

Add /dbg certs command #3799

merged 1 commit into from
Feb 25, 2019

Conversation

alexkursell
Copy link
Contributor

What this PR does / why we need it: While #3779 isn't going to be part of the 0.23 release, it would be nice however, to have all of the /dbg commands that the plugin relies on existing to be present in the 0.23 release so that the plugin is completely usable with 0.23 ingress-nginx controllers.

This PR separates out just the additions to the /dbg command so that they can be merged before #3779

cc: @ElvinEfendi

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 22, 2019
@aledbf
Copy link
Member

aledbf commented Feb 25, 2019

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 25, 2019
@aledbf
Copy link
Member

aledbf commented Feb 25, 2019

While #3779 isn't going to be part of the 0.23 release,

Why not? I think we should publish the plugin in 0.23 as an alpha feature providing the krew command to install the plugin from github without opening a PR in the krew repository.

@@ -127,6 +157,11 @@ function _M.call()
return
end

if starts_with(ngx.var.request_uri, "/configuration/certs") then
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use ngx.var.uri instead of using starts_with?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

end

local key = _M.get_pem_cert_key(query["hostname"])
if key and key ~= "" then
Copy link
Member

Choose a reason for hiding this comment

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

key ~= ""

I don't think this should be "not found" - it's found, just empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So if the queried host isn't configured at all, this is nil. If the host exists in the ingress definition at all but doesn't have a certificate, this is the empty string. I feel like we should return 404 for both of these cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on some in-person discussion, I've made this change.

Copy link
Member

Choose a reason for hiding this comment

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

tldr; returning an empty content in that case reveals more information than returning 404.

@alexkursell
Copy link
Contributor Author

While #3779 isn't going to be part of the 0.23 release,

Why not? I think we should publish the plugin in 0.23 as an alpha feature providing the krew command to install the plugin from github without opening a PR in the krew repository.

Sure, that seems like a good idea!

@ElvinEfendi
Copy link
Member

ElvinEfendi commented Feb 25, 2019

@aledbf since we are going to be serving certs dynamically only (#3808), what do you think to have this command support dynamic mode only to avoid unnecessary complexity?

@aledbf
Copy link
Member

aledbf commented Feb 25, 2019

@ElvinEfendi good idea

@ElvinEfendi
Copy link
Member

@alexkursell let's simplify the RP then by removing support for static certs.

@alexkursell
Copy link
Contributor Author

@alexkursell let's simplify the RP then by removing support for static certs.

Done.

@@ -88,15 +89,39 @@ func NewPostStatusRequest(path, contentType string, data interface{}) (int, []by
return res.StatusCode, body, nil
}

// GetServerBlock takes an nginx.conf file and a host and tries to find the server block for that host
func GetServerBlock(conf string, host string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Did you leave this here because it'll be needed later on when we add more commands to dbg?

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. I'm also making use of it in the actual plugin, and I feel that it's good to keep it next to the other common nginx.conf reading stuff.

@ElvinEfendi
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 25, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, alexkursell, ElvinEfendi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 7b737df into kubernetes:master Feb 25, 2019
@alexkursell alexkursell deleted the dbg-certs branch February 25, 2019 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants