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

Fixes #33687 - Add warning not to directly edit settings.py #223

Merged
merged 1 commit into from
Oct 21, 2021

Conversation

wbclark
Copy link
Collaborator

@wbclark wbclark commented Jul 26, 2021

Short term static alternative to #210

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I think this is a very long header and I generally dislike those. In puppet-foreman we have https://github.com/theforeman/puppet-foreman/blob/master/templates/_header.erb and IMHO that's plenty long.

# !!! WARNING: DO NOT EDIT THIS FILE !!! #
################################################################################
# File managed by Puppet. #
# Module: pulpcore #
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Module: pulpcore #
# Module: <%= scope['module_name'] %> #

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would $module_name ever take on another value? If not, then why not simply hard code it?

Note in the generic version I intend to build, it would be dynamic so that it could be used by other modules. That would also have an overrideable $installer_name so that it can say, e.g. File managed by foreman-installer one line above.

Copy link
Member

Choose a reason for hiding this comment

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

Nah, I think it will always be the module name based on the metadata and thus no worry that it might change for right now.

Copy link
Member

Choose a reason for hiding this comment

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

However, if you do want to go to a generic header it makes sense to think about it. For example, the closing # that you add now becomes a lot harder. That's why I'd advise to leave that part out. I should have mentioned that in my initial review.

My reasoning is that a change now will lead to a service restart. Restarting all services just for a new comment in a config file is a bit of a waste. So I'd prefer to get it right the first time.

Copy link
Member

Choose a reason for hiding this comment

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

I think I see what you are saying... the trailing # is harder to calculate than if there was none. So if that part was dropped, when the generic solution is implemented it matches this closer and is easier to implement. We do not necessarily need the aesthetic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Understood. With that said, I already solved that issue in my proof of concept for the more general case:

https://github.com/theforeman/puppet-pulpcore/pull/210/files#diff-893d976ae6fa01e560858f0185fdcfad47f8550e71e8a510fc7a8135ca8e03e6R16

Comment on lines 7 to 9
# Not only are your edits likely to be overwritten, there is also a strong #
# possibility of breaking your system if you change configuration here without #
# making required changes elsewhere. Refer to the documentation you used to #
# install Pulpcore to determine the safe and persistent way to modify the #
# configuration. #
################################################################################
Copy link
Member

Choose a reason for hiding this comment

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

Is this part really needed? The user may not have explicitly thought about it so how are they going to link it back?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's important to provide some explanation to the user so that they understand why they are asked to not make edits.

If there is a warning not to make edits, but no explanation, a confident user might say "oh, I already understand it won't be persistent, so this warning doesn't apply to me. I just want to try out that other tasking system..."

I agree it's difficult to phrase it in such a way that is equally applicable to users of puppet, foreman-installer, satellite-installer, orcharhino, etc. Necessarily, the explanation will be vague, and this is the problem that I intend to solve by allowing custom strings in hiera.

But in the meantime, with the upcoming release introducing several new config file entries that can easily be broken in unexpected ways, I argue that a vague explanation is still better than no explanation at all.

templates/settings.py.erb Outdated Show resolved Hide resolved
@wbclark wbclark force-pushed the static_settings_py_warning branch from 9e4156e to f36e59f Compare July 26, 2021 15:53
Copy link
Member

@ehelms ehelms left a comment

Choose a reason for hiding this comment

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

I think this is a fair start, and the systematic change being worked on will be a better long term solution. For now this achieves the primary objective of helping users understand they should not be editing. I suppose we will learn over time if it actually works.

@ehelms
Copy link
Member

ehelms commented Oct 12, 2021

@wbclark I think there is at least one suggestion to address here with the dynamic module name

@ekohl what are your current thoughts on this change going in?

@wbclark
Copy link
Collaborator Author

wbclark commented Oct 12, 2021

@wbclark I think there is at least one suggestion to address here with the dynamic module name

Thanks.

I think that static module name should be fine for this PR since it will never change.

As I understood the suggestion from @ekohl it was a recommendation to think about the future where this type of logic could be used by any module. I have done that, and it is solved in #210

So I would propose that we:

  1. merge this as is, as it provides some warning to users now
  2. re-implement Add customizable warning not to directly edit settings.py #210 as a PR to an existing library or as a new module, to allow downstream customization and standardize across modules in the future

OR

  1. merge Add customizable warning not to directly edit settings.py #210 now, as it does everything this does, with the additional feature that the strings can be overwritten in hiera for messages that are more targeted by use case
  2. later re-implement that one as a PR to an existing library or as a new module, to standardize across modules in the future

The upside of the 2nd approach would be the additional customization it allows, which solves the problem of documenting/commenting for pure puppet deployments vs. foreman installer vs. downstream; the downside would be that a future breaking change becomes more likely if the customizable form is merged now, then goes through additional reviews and changes during externalization

@wbclark wbclark force-pushed the static_settings_py_warning branch from f36e59f to 2912cf1 Compare October 12, 2021 19:57
@wbclark wbclark changed the title Add warning not to directly edit settings.py Fixes #33687 - Add warning not to directly edit settings.py Oct 12, 2021
@wbclark
Copy link
Collaborator Author

wbclark commented Oct 12, 2021

After further thought and discussion, I pushed an update with the following changes:

  1. Created Redmine #33687 and linked it for tracking purposes
  2. Changed to <%= scope['module_name'] %> for consistency with other module headers
  3. Removed closing # characters. I added these in Add customizable warning not to directly edit settings.py #210 because I intend to build that out to support any comment syntax, including one that might have opening and closing tags for comments. While I also like the visual style these provide, it's not important to the core functionality of this feature in this module.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I still feel this is quite a heavy text. Some inline comments to make it a bit smaller.

I do like the reference to the documentation.

templates/settings.py.erb Show resolved Hide resolved
templates/settings.py.erb Outdated Show resolved Hide resolved
templates/settings.py.erb Outdated Show resolved Hide resolved
@wbclark wbclark force-pushed the static_settings_py_warning branch from 2912cf1 to a247929 Compare October 21, 2021 22:18
@wbclark
Copy link
Collaborator Author

wbclark commented Oct 21, 2021

@ekohl This is updated with your requested changes.

Longer term, I still prefer a solution using custom strings that can be overwritten in hiera, so that foreman-installer, satellite-installer, orcharhino, or any other tool using this module can provide warnings that are tailored to their use case.

For example, satellite-installer could link directly to an article on access.redhat.com describing how to (re-)configure Pulpcore using satellite-installer.

@wbclark
Copy link
Collaborator Author

wbclark commented Oct 21, 2021

If that's your goal, why not copy what we have in dhcp?

Thanks, that is neat.

Quite a bit simpler, if not as robust, as what I had in #210

@wbclark wbclark merged commit 9617d79 into theforeman:master Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Needs testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants