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

implement first version (basic HTTP actions support, basic auth) #25

Merged
merged 8 commits into from
Sep 13, 2024

Conversation

rursprung
Copy link
Collaborator

please see the individual commit messages for further details. this should give you a working first version of liquibase-opensearch which can be used against OpenSearch as long as it is using basic authentication.

please carefully review any open TODOs (none of which is a blocker, but some might suggest low-hanging fruits in liquibase-core for better no-SQL support) as well as the ported liquibase.nosql package (taken from liquibase-mongodb; which isn't really generic!).

closes #17

Copy link
Collaborator Author

@rursprung rursprung left a comment

Choose a reason for hiding this comment

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

@filipelautert & @reta (and anyone else reviewing this! i added filipe as the stand-in mention for "liquibase team"): sorry for the spam, but i've added some comments to highlight specific things to you. please nevertheless review everything - i mainly highlighted the areas where i'm unsure (+ i found some things which i hadn't found before when i implemented this 😄)

pom.xml Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
liquibase.ext.opensearch.database.OpenSearchLiquibaseDatabase
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

missing newline at EOF

src/test/resources/liquibase/ext/changelog.empty.yaml Outdated Show resolved Hide resolved
Copy link
Contributor

@filipelautert filipelautert left a comment

Choose a reason for hiding this comment

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

Questions/comments answered.

pom.xml Outdated
<dependency>
<groupId>org.opensearch.client</groupId>
<artifactId>opensearch-java</artifactId>
<version>2.10.2</version>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Couple of bugfixes included:

Suggested change
<version>2.10.2</version>
<version>2.10.3</version>

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also exclude opensearch-rest-client since we use AHC 5 here (https://github.com/liquibase/liquibase-opensearch/pull/25/files#diff-9c5fb3d1b7e3b0f54bc5c4182965c4fe1f9023d449017cece3005d3f90e8e4d8R91)

            <exclusions>
            	<exclusion>
            		<groupId>org.opensearch.client</groupId>
            		<artifactId>opensearch-rest-client</artifactId>
            	</exclusion>
            </exclusions>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the exclusion is blocked by opensearch-project/opensearch-java#1002 (though a workaround would be possible it's better to wait for the proper fix)

@rursprung
Copy link
Collaborator Author

for the tests to pass this needs a new liquibase-core which contains liquibase/liquibase#5950 & liquibase/liquibase#5953

@filipelautert filipelautert self-requested a review June 5, 2024 04:57
@rursprung rursprung requested review from filipelautert and reta June 5, 2024 12:33
pom.xml Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Jun 26, 2024

}

if (!hasDatabaseChangeLogTable()) {
getLogger().info("Create Database Change Log Collection");
Copy link
Contributor

Choose a reason for hiding this comment

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

Sure!

note that the pom so far claimed that the license was the Liquibase
EULA, but this repository - and the extension - is licensed as
Apache 2.0.
this folder is generated by maven when running builds.
this already allows connecting to OpenSearch using basic authentication.

note: the `liquibase.nosql` package has been copied from
[`liquibase-mongodb`] and adapted where needed (it is not 100% generic).
no authorship is claimed for this content!

[`liquibase-mongodb`]: https://github.com/liquibase/liquibase-mongodb
this also comes with various supporting infrastructure, e.g. the
executor.

this does not yet allow executing any changesets, but it allows
liquibase to run with an empty changeset which will create the
`changelog` and also manage the lock (which ensures that only one
liquibase operation is running at a time).

note: the `liquibase.nosql` package has been copied from
[`liquibase-mongodb`] and adapted where needed (it is not 100% generic).
no authorship is claimed for this content!

it's important that all document operations being performed on the
changelog & lock indices are done with `refresh=wait_for` to ensure that
a subsequent read will see the correct data (otherwise a changeset might
be marked as run but a subsequent run will not see this and try to run
it again).

[`liquibase-mongodb`]: https://github.com/liquibase/liquibase-mongodb
this adds a new change type which allows generic HTTP requests. while
this isn't great to support working over multiple OpenSearch major
releases (in case the REST API had breaking changes) it already offers
an easy way to trigger any possible action on OpenSearch.
latter versions might add additional change types for specific
operations on OpenSearch which can then also abstract away from the
exact API version (if possible).
this allows executing the [`clear-checksums`] liquibase action.

[`clear-checksums`]: https://docs.liquibase.com/commands/utility/clear-checksums.html
this provides the necessary XSD. note that the XSD has to be published
at
http://www.liquibase.org/xml/ns/opensearch/liquibase-opensearch-1.0.xsd
for the reference to be valid for consumers. this seems to have been
done for other plugins (e.g. mongodb) but is - presumably? - a manual
process.
Copy link

sonarcloud bot commented Sep 13, 2024

@filipelautert filipelautert merged commit aa59f36 into liquibase:master Sep 13, 2024
10 of 11 checks passed
@rursprung rursprung deleted the initial-featureset branch September 13, 2024 16:41
@reta
Copy link
Collaborator

reta commented Sep 13, 2024

🥳

rursprung added a commit that referenced this pull request Sep 19, 2024
this was a last-minute change before merging PR #25 and we didn't spot
this: all tests are failing due to this as this is being called by the
constructor of `ChangeLogParameters`.

instead of returning something artifical (like `//`) which doesn't apply
here we'll just return an empty string. this is needed until liquibase
adds first-class support for NoSQL DBs and removes any SQL-specific
features (requires liquibase/liquibase#4236).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement first version (basic HTTP actions support, basic auth)
4 participants