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

ipa-client-install: Update how comments are added by ipachangeconf #2093

Closed
wants to merge 1 commit into from
Closed

ipa-client-install: Update how comments are added by ipachangeconf #2093

wants to merge 1 commit into from

Conversation

netoarmando
Copy link
Member

@netoarmando netoarmando commented Jul 3, 2018

Due to how 'openldap-client' parses its configuration files this patch changes how comments are added, moving them to the line above instead of appending to the same line.

Issue: https://pagure.io/freeipa/issue/5202

@netoarmando netoarmando added the re-run Trigger a new run of PR-CI label Jul 3, 2018
@freeipa-pr-ci freeipa-pr-ci removed the re-run Trigger a new run of PR-CI label Jul 3, 2018
@rcritten rcritten self-assigned this Jul 3, 2018
Copy link
Contributor

@rcritten rcritten left a comment

Choose a reason for hiding this comment

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

So if I understand this correctly, if a value that IPA wants to modify already exists, it adds a comment that IPA modifieed the variable plus a commented out version of that variable?

So if TLS_CACERTDIR is pre-set then post IPA install one would have

# TLS_CACERTDIR modified by IPA
# TLS_CACERTDIR /some/other/path
TLS_CACERTDIR /user/provided/value

This seems like a reasonable fix for the fact that openldap can't parse in-line comments. The idea was to highlight those things that IPA changed hopefully so end-users don't modify them.

I added a separate test after yours to add a new option, VAR_NAME2, and it was not preceded by a comment "modified by IPA". Maybe my test was bad but I think an additional test like this is needed in any case.

@netoarmando
Copy link
Member Author

@rcritten thanks for adding some explanation to this patch! Something I failed to do.

I added a separate test after yours to add a new option, VAR_NAME2, and it was not preceded by a comment "modified by IPA". Maybe my test was bad but I think an additional test like this is needed in any case.

The comment "modified by IPA" proceeds only variables that IPA would override. However, I can test the scenario you've mentioned to assert that the result wouldn't include the comment.



@pytest.fixture(scope='session')
def config_file(tmpdir_factory):
Copy link
Member

Choose a reason for hiding this comment

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

tmpdir_factory was introduced in pytest 2.8, but RHEL 7.5 has 2.7.0-2.el7. You need to use another way to create a temporary file, e.g. tmpdir fixture with a function scope fixture.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice observation, would pr-ci nightly catch this eventually?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so. QE will eventually run into this and complain.


@pytest.fixture(scope='session')
def config_file(tmpdir_factory):
file = tmpdir_factory.mktemp('data').join('config_file.conf')
Copy link
Member

Choose a reason for hiding this comment

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

file is the name of a Python 2 builtin. In other places, we use filename to refer to a file name.

Copy link
Member Author

Choose a reason for hiding this comment

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

My bad..

ipa_conf.changeConf(str(config_file), opts)

assert config_file.readlines() == [
'#SOME_CONF modified by IPA\n',
Copy link
Member

Choose a reason for hiding this comment

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

#text is hard to read. Could you change the code to emit # text instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed.

Due to how 'openldap-client' parses its configuration files this patch
changes how comments are added, moving them to the line above instead
of appending to the same line.

IPA doesn't want to break existing configuration, if a value already
exists it adds a comment to the modified setting and a note about that
on the line above.

New settings will be added without any note.

Issue: https://pagure.io/freeipa/issue/5202

Signed-off-by: Armando Neto <abiagion@redhat.com>
@netoarmando
Copy link
Member Author

@tiran I've changed to # text format only in # SOME_VAR modified by IPA line.
I would update every comment to that format, I haven't done it because I was afraid it could break some script executed by administrators out there.

Copy link
Member

@tiran tiran left a comment

Choose a reason for hiding this comment

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

LGTM

@rcritten rcritten dismissed their stale review July 5, 2018 15:27

changes applied

@rcritten rcritten added the ack Pull Request approved, can be merged label Jul 5, 2018
@tiran tiran added the pushed Pull Request has already been pushed label Jul 5, 2018
@tiran
Copy link
Member

tiran commented Jul 5, 2018

master:

  • 53c5496 ipa-client-install: Update how comments are added by ipachangeconf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
4 participants