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

support custom configuration to main context of nginx config #2895

Merged
merged 1 commit into from
Aug 3, 2018
Merged

support custom configuration to main context of nginx config #2895

merged 1 commit into from
Aug 3, 2018

Conversation

tomxor
Copy link
Contributor

@tomxor tomxor commented Aug 3, 2018

What this PR does / why we need it:
Adding custom configuration to the main context of the nginx config file is currently only possible by providing a custom template. IMO doing so should be considered a last resort since it could make the upgrade process more painful. This PR introduces the main-snippet ConfigMap option which enables addition of custom settings to the main context of the nginx config file.

Release note:

Adds `main-snippet` ConfigMap option which enables adding custom settings to the main section of the nginx config file.

Special notes for your reviewer:
Didn't see any tests for similar functions (e.g. http-snippet). I assume this can be verified in the e2e tests but I wasn't entirely sure if that's the proper place to test it.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 3, 2018
@codecov-io
Copy link

codecov-io commented Aug 3, 2018

Codecov Report

Merging #2895 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2895   +/-   ##
=======================================
  Coverage   47.56%   47.56%           
=======================================
  Files          76       76           
  Lines        5483     5483           
=======================================
  Hits         2608     2608           
  Misses       2540     2540           
  Partials      335      335
Impacted Files Coverage Δ
internal/ingress/controller/config/config.go 98.26% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 23ce9b5...1bacf16. Read the comment docs.

Copy link
Contributor

@antoineco antoineco left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me. Would you mind adding a simple e2e test to make sure custom directives make it to the config?

## main-snippet

Adds custom configuration to the main section of the nginx configuration.
_**default:**_ ""
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can remove that default: "" from all *-snippet descriptions (including the ones that are not part of this PR). It is mentioned in the table, and is kind of obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

33a284ac0c96899e018af79a39692897b236dec2

@tomxor
Copy link
Contributor Author

tomxor commented Aug 3, 2018

I'll add the e2e tests and ping when it's ready, thanks for the quick review.

@tomxor
Copy link
Contributor Author

tomxor commented Aug 3, 2018

@antoineco I've added a very naive e2e test: 60a4c3fb454e049515a5dc9550e7897b969963df

similar to other tests, it simply asserts the value is contained within the entire configuration file. obviously this is not ideal and preferably we should assert that it is included inside the main context. I can pollute the template with # main custom section start + end comments as done in the server snippet tests, but I'm not sure that's desirable. so if you want me to add that let me know.
on a related note, maybe it's time to consider adding a parser to the test infra, one that will return a type which allows making more accurate assertions.

once this is approved I will squash the commits.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 3, 2018
Copy link
Contributor

@antoineco antoineco left a comment

Choose a reason for hiding this comment

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

The test you added should do since each test runs in its own isolated namespace. Thanks for that!

err := f.UpdateNginxConfigMapData(mainSnippet, expectedComment)
Expect(err).NotTo(HaveOccurred())

ing, err := f.EnsureIngress(framework.NewSingleIngress(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not relevant for that particular test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

87455d7445255f68629b155baf26072113a5086b

@antoineco
Copy link
Contributor

Thanks @tomxor 🙌 I'll wait for you to squash these 4 commits and approve the PR.

@tomxor
Copy link
Contributor Author

tomxor commented Aug 3, 2018

@antoineco squashed, thanks for the review!

@antoineco
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 3, 2018
@antoineco
Copy link
Contributor

/lgtm cancel
(sorry, missed a tiny detail)

@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 3, 2018
Copy link
Contributor

@antoineco antoineco left a comment

Choose a reason for hiding this comment

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

Apologizes for the round-trips, I missed that one. Feel free to git commit --amend --no-edit.

mainSnippet := "main-snippet"

BeforeEach(func() {
err := f.NewEchoDeployment()
Copy link
Contributor

Choose a reason for hiding this comment

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

Also irrelevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no worries, pushed.

@antoineco
Copy link
Contributor

/lgtm
Thank you again @tomxor :)

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: antoineco, tomxor

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 3, 2018
@k8s-ci-robot k8s-ci-robot merged commit af7fe6b into kubernetes:master Aug 3, 2018
@tomxor tomxor deleted the main-ctx-snippet-cfg branch August 3, 2018 22:22
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants