-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 debug binary to the docker image #3686
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
I've signed the CLA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. it would be very useful.
Still needs:
- unit tests
- documentation on usage
cmd/dbg/main.go
Outdated
|
||
func backends() { | ||
//Get the backend information from the nginx instance | ||
body, requestErr := makeRequest("http://127.0.0.1:18080/configuration/backends") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of http://127.0.0.1:18080/configuration/backends
being hardcoded here, it can be a global variable.
Also 18080
should be obtained be user configurable.
cmd/dbg/main.go
Outdated
} | ||
|
||
func backendsList() { | ||
body, requestErr := makeRequest("http://127.0.0.1:18080/configuration/backends") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of http://127.0.0.1:18080/configuration/backends
being hardcoded here, it can be a global variable.
Also 18080
should be obtained be user configurable.
cmd/dbg/main.go
Outdated
} | ||
|
||
func backendsGet(name string) { | ||
body, requestErr := makeRequest("http://127.0.0.1:18080/configuration/backends") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of http://127.0.0.1:18080/configuration/backends
being hardcoded here, it can be a global variable.
Also 18080
should be obtained be user configurable.
cmd/dbg/main.go
Outdated
|
||
func general() { | ||
//Get the other (general) information from the nginx instance | ||
body, requestErr := makeRequest("http://127.0.0.1:18080/configuration/general") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of http://127.0.0.1:18080/configuration/general
being hardcoded here, it can be a global variable.
Also 18080
should be obtained be user configurable.
cmd/dbg/main.go
Outdated
fmt.Println(err) | ||
return nil, err | ||
} | ||
defer resp.Body.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should begin with the defer. Defer is always be triggered when a function ends.
cmd/dbg/main.go
Outdated
fmt.Println(err) | ||
return | ||
} | ||
defer confFile.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should begin with the defer. Defer is always be triggered when a function ends.
@alexkursell just in case, I am removing the server listening on port 18080 in #3684 |
@alexkursell let's use a proper cli library instead: https://github.com/spf13/cobra seems to be the one in k8s realm.
As long as we have got the right abstraction here, the change should not be an issue. So this is not a blocker. |
test/e2e/framework/framework.go
Outdated
@@ -214,6 +214,19 @@ func (f *Framework) NginxLogs() (string, error) { | |||
return nginxLogs(f.KubeClientSet, f.IngressController.Namespace) | |||
} | |||
|
|||
// PodCommand executes any command inside the nginx pod | |||
func (f *Framework) PodCommand(cmd string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's already a function to do this: ExecIngressPod
5661b43
to
f1daec2
Compare
@alexkursell there is something wrong with this PR. If you need to add new dependencies, you need to run something like
to avoid adding the Also, usually we squash the commit, using one for the code changes and another for the changes in the vendor directory |
cmd/dbg/main.go
Outdated
fmt.Print(string(contents)) | ||
} | ||
|
||
func makeConfigRequest(path string) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use https://github.com/kubernetes/ingress-nginx/blob/master/internal/nginx/main.go#L51 just to avoid duplications
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/approve |
deferring lgtm to @ElvinEfendi |
cmd/dbg/main.go
Outdated
"os" | ||
) | ||
|
||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are const, not var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/lgtm |
[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 |
closes #3679 |
What this PR does / why we need it:
This PR adds a command-line tool to the image,
/dbg
, that can inspect various parts of the nginx configuration, including the dynamic parts used by lua. This should make it easier to debug problems to do with the generated configuration.Right now, it can query the
/configuration/backends
and/configuration/general
endpoints and display the result. In the case of the backend endpoint, it can also filter the output by backend name. It also includes a subcommand that essentially performscat /etc/nginx/nginx.conf
just to save on typing.In the future, I'd also like to add the ability to inspect the dynamically loaded SSL keys that are also managed by lua, as well as anything else that makes debugging easier.
Which issue this PR fixes : Addresses #3679
cc: @ElvinEfendi