Skip to content

Conversation

@smolnar82
Copy link
Contributor

@rlevas @zeroflag @echekanskiy Please review

What changes were proposed in this pull request?

According to the requirement I needed to move LDAP related properties out from ambari.properties file into our DB table called ambari_configuration with 'ldap-configuration' category name when upgrading to 3.0.0.

How was this patch tested?

Unit test were added and adopted; local build result:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:37 h
[INFO] Finished at: 2018-01-12T13:40:34+01:00
[INFO] Final Memory: 207M/802M
[INFO] ------------------------------------------------------------------------

Besides unit testing the following integration test has been executed:

  1. installed Ambari 2.6.2
  2. executed ambari-server setup-ldap (LDAP related properties appeared in /etc/ambari-server/conf/ambari.properties; made a backup of this file)
  3. upgraded to Ambari 3.0.0 (using build 1426 and replaced ambari-server.jar to include my changes): Ambari Server 'upgrade' completed successfully.
  4. DB check: all properties I defined in step 2 have been added in ambari_configration table with 'ldap-configuration' category
  5. Property file check: LDAP related properties have been removed

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe anyMatch() would be shorter

Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation also removes properties with prefix and/or suffix, eg. security.server.crt_pass would match security.server.crt_pass_file, too, due to using indexOf(). It may not be a problem in this use case, but I think it should be addressed, since it is a generic method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation also removes properties with prefix and/or suffix, eg. security.server.crt_pass would match security.server.crt_pass_file, too, due to using indexOf(). It may not be a problem in this use case, but I think it should be addressed, since it is a generic method.

Copy link
Contributor

Choose a reason for hiding this comment

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

typo in ambari_congiuration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Deleting the file before writing the new one may lead to data loss.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@asfgit
Copy link

asfgit commented Jan 13, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/83/
Test FAILed.
Test FAILured.

Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks for the changes.

One more request: please do not force-push to the source branch of pull requests, since it makes it harder to see what previous comments were about (and how the comments were addressed). Instead, please push additional commits. They can be squashed during merge if a single commit on the target branch is desired.

Copy link
Contributor

Choose a reason for hiding this comment

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

Upgrade logic should be idempotent:

  1. Running upgrade on already upgraded setup should be no-op (no errors etc.). I guess this is the case, since properties removed at the end will not be processed on next try.
  2. Retrying partially completed upgrade should resume without errors. This might be a problem here, since all properties are left until the end, duplicate properties may be created. Can you please confirm if this handled correctly? (Test by throwing some exception in the middle of property processing.) If not, can you please make sure to "create or update" the properties instead of "create".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are good notices; thanks for bringing them up.
Point 1: like you indicated there won't be more properties to be upgraded = no-op
Point 2: I'll check it out and modify the code if needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

You should use org.apache.ambari.server.configuration.Configuration#readConfigFile to read the properties from the ambari.properties file into a java.util.Properties object. Then later write out the properties using org.apache.ambari.server.configuration.Configuration#writeConfigFile (which does not yet exist).

Copy link
Contributor

Choose a reason for hiding this comment

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

Can java.net.URL be used instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using HostAndPort from Guava instead

Copy link
Contributor

Choose a reason for hiding this comment

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

Can java.net.URL be used instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using HostAndPort from Guava instead

@asfgit
Copy link

asfgit commented Jan 15, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/116/
Test FAILed.
Test FAILured.

@asfgit
Copy link

asfgit commented Jan 15, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/120/
Test FAILed.
Test FAILured.

@asfgit
Copy link

asfgit commented Jan 15, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/124/
Test FAILed.
Test FAILured.

@smolnar82
Copy link
Contributor Author

Removed my commit which fixed the JUnit tests since @adoroszlai fixed it in #118

@asfgit
Copy link

asfgit commented Jan 15, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/132/
Test PASSed.

@smolnar82
Copy link
Contributor Author

Tests have been passed. Could someone with the proper privileges merge this PR?

@rlevas rlevas changed the title AMBARI-22668. Moving LDAP related properties to DB upon upgrade to 3.0.0 [AMBARI-22668] Moving LDAP related properties to DB upon upgrade to 3.0.0 Jan 15, 2018
@rlevas rlevas merged commit 23e51fa into apache:trunk Jan 15, 2018
@smolnar82 smolnar82 deleted the AMBARI-22668 branch January 15, 2018 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants