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

Ignore missing servers or snippets when removing from map #275

Merged
merged 2 commits into from
Jun 14, 2021

Conversation

anderbubble
Copy link
Contributor

@anderbubble anderbubble commented Jan 23, 2021

nginx.servers_config wants a lightened copy of the nginx map
to render as json; but, when it was trying to remove the
servers and snippets keys from the map it assumed their presence,
causing a KeyError if they were not present by its use of .pop().

While wrapping these in an "if" clause would likely be more
correct, along with replacing .pop() with del (if jinja even
supports that) the simplest change here is to just specify a
default value for .pop(), which obviates the KeyError.

Fixes #274

PR progress checklist (to be filled in by reviewers)

  • Changes to documentation are appropriate (or tick if not required)
  • Changes to tests are appropriate (or tick if not required)
  • Reviews completed

What type of PR is this?

Primary type

  • [build] Changes related to the build system
  • [chore] Changes to the build process or auxiliary tools and libraries such as documentation generation
  • [ci] Changes to the continuous integration configuration
  • [feat] A new feature
  • [fix] A bug fix
  • [perf] A code change that improves performance
  • [refactor] A code change that neither fixes a bug nor adds a feature
  • [revert] A change used to revert a previous commit
  • [style] Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)

Secondary type

  • [docs] Documentation changes
  • [test] Adding missing or correcting existing tests

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

Describe the changes you're proposing

Pillar / config required to test the proposed changes

Debug log showing how the proposed changes work

Documentation checklist

  • Updated the README (e.g. Available states).
  • Updated pillar.example.

Testing checklist

  • Included in Kitchen (i.e. under state_top).
  • Covered by new/existing tests (e.g. InSpec, Serverspec, etc.).
  • Updated the relevant test pillar.

Additional context

Copy link
Member

@javierbertoli javierbertoli left a comment

Choose a reason for hiding this comment

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

@anderbubble good catch.

If possible, mind you do a few more changes that are relevant?

  1. Add a similar fix in the snippets.sls file
  2. Delete this line, this block and these lines so we have a test for this fix.
  3. Amend the commit message to something like fix(config): ignore missing servers or snippets so our automated versioning does not complain (check here for more details)

With these other minor changes, we'll have testing in place for the issue and it will be OK to be merged

nginx/servers_config.sls Outdated Show resolved Hide resolved
javierbertoli added a commit to netmanagers/nginx-formula that referenced this pull request Apr 13, 2021
@javierbertoli
Copy link
Member

@anderbubble ping?

@anderbubble
Copy link
Contributor Author

anderbubble commented Apr 20, 2021

I'm here; just busy. I expect I can perform the additional changes you suggested; it just might take me a bit to get to it.

edit: I've put it on my agenda for Friday.

@javierbertoli
Copy link
Member

@anderbubble wonderful! I'll wait for your changes to merge this.

javierbertoli added a commit to netmanagers/nginx-formula that referenced this pull request Apr 28, 2021
javierbertoli added a commit to netmanagers/nginx-formula that referenced this pull request Apr 28, 2021
javierbertoli added a commit to netmanagers/nginx-formula that referenced this pull request May 12, 2021
javierbertoli added a commit to netmanagers/nginx-formula that referenced this pull request Jun 14, 2021
@myii
Copy link
Member

myii commented Jun 14, 2021

1. Add a similar fix in the [snippets.sls](https://github.com/saltstack-formulas/nginx-formula/blob/master/nginx/snippets.sls#L11-L12) file

3. Amend the commit message to something like `fix(config): ignore missing servers or snippets` so our automated versioning does not complain (check [here](https://github.com/saltstack-formulas/.github/blob/master/CONTRIBUTING.rst#relationship-between-commit-type-and-version-bump) for more details)

Updated this PR to complete the above steps requested by @javierbertoli. Includes resolving this review comment:

nginx.servers_config wants a lightened copy of the nginx map
to render as json; but, when it was trying to remove the
servers and snippets keys from the map it assumed their presence,
causing a KeyError if they were not present by its use of .pop().

While wrapping these in an "if" clause would likely be more
correct, along with replacing .pop() with del (if jinja even
supports that) the simplest change here is to just specify a
default value for .pop(), which obviates the KeyError.

Fixes saltstack-formulas#274
Fix failure highlighted on OpenSUSE Tumbleweed, where the `cmd.run` runs
before the `pkg.installed`:

* https://gitlab.com/saltstack-formulas/nginx-formula/-/jobs/1345325819#L2830
@javierbertoli javierbertoli merged commit c55120a into saltstack-formulas:master Jun 14, 2021
@javierbertoli
Copy link
Member

Thanks you @anderbubble & @myii for this!

@saltstack-formulas-travis

🎉 This PR is included in version 2.7.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

javierbertoli added a commit to netmanagers/nginx-formula that referenced this pull request Jun 14, 2021
saltstack-formulas-travis pushed a commit that referenced this pull request Jun 14, 2021
## [2.7.3](v2.7.2...v2.7.3) (2021-06-14)

### Tests

* **snippets:** add tests for snippets includes ([1c83b6d](1c83b6d)), closes [#275](#275) [#274](#274)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Run fails if nginx.server.snippets is not defined in pillar
4 participants