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

Add scylladb module #8002

Merged
merged 17 commits into from
Jan 31, 2025
Merged

Add scylladb module #8002

merged 17 commits into from
Jan 31, 2025

Conversation

mkorolyov
Copy link
Contributor

ScyllaDB is an open-source distributed NoSQL wide-column data store. It gains wide popularity as a drop-in replacement for Cassandra but a significantly faster one.

This PR adds the ScyllaDB module.

@mkorolyov mkorolyov requested a review from a team as a code owner December 26, 2023 10:32
@guy9
Copy link

guy9 commented Jan 7, 2024

Thanks @mkorolyov , interested in this as well

@mykaul
Copy link

mykaul commented Jan 14, 2024

I wish there was a way NOT to provide your own scylla.yaml, but merge your defaults with the default scylla.yaml - the end result is that you might be missing some new defaults if you bring your own scylla.yaml.

mkorolyov and others added 2 commits January 16, 2024 09:25
@mkorolyov
Copy link
Contributor Author

I wish there was a way NOT to provide your own scylla.yaml, but merge your defaults with the default scylla.yaml - the end result is that you might be missing some new defaults if you bring your own scylla.yaml.

This looks like a separate feature for merging config files. Usually what I used to see in a majority of the applications is that you are using the default config file and overriding it with ENVs or flags or providing your own config file. Providing own config file which will still be merged with some default looks like implicit behavior which in my opinion will confuse users. WDYT?

@guy9
Copy link

guy9 commented Jan 21, 2024

Any updates on merging this?

@mykaul
Copy link

mykaul commented Jan 23, 2024

I wish there was a way NOT to provide your own scylla.yaml, but merge your defaults with the default scylla.yaml - the end result is that you might be missing some new defaults if you bring your own scylla.yaml.

This looks like a separate feature for merging config files. Usually what I used to see in a majority of the applications is that you are using the default config file and overriding it with ENVs or flags or providing your own config file. Providing own config file which will still be merged with some default looks like implicit behavior which in my opinion will confuse users. WDYT?

Yes, my ask is exactly this - let's use the default Scylla YAML that comes with Scylla, and allow overriding values in it.

this.enableJmxReporting = false;

withEnv("CASSANDRA_SNITCH", "GossipingPropertyFileSnitch");
withEnv("JVM_OPTS", "-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.initial_token=0");
Copy link

Choose a reason for hiding this comment

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

those are not relevant to scylla, you need commandline option for skip_wait_for_gossip_to_settle

addExposedPort(CQL_PORT);
this.enableJmxReporting = false;

withEnv("CASSANDRA_SNITCH", "GossipingPropertyFileSnitch");
Copy link

Choose a reason for hiding this comment

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

I think this needs to be checked, scylla docker doesn't use this variable

@vbazhmin
Copy link

vbazhmin commented Jun 7, 2024

Hello folks. Any updates on this one ? ;)

@eddumelendez
Copy link
Member

Hi, I'll review the PR once the other comments have been addressed. It is great seeing Scylla team reviewing the PR.

@fruch
Copy link

fruch commented Aug 1, 2024

Hi, I'll review the PR once the other comments have been addressed. It is great seeing Scylla team reviewing the PR.

hopefully it won't be dragged like it's counterpart:
testcontainers/testcontainers-python#167

@eddumelendez
Copy link
Member

@fruch LMK once this is ready to review and will do it as soon as possible. I still see some comments that hasn't been resolved. So, that's the reason why I haven't reviewed yet.

@eddumelendez
Copy link
Member

Hi, I know this is still in progress because I see some comments unresolved. But, JFTR it would be nice to add an integration test enabling ssl and add it to the docs.

@eddumelendez
Copy link
Member

I'm updating the PR based on testcontainers/testcontainers-go#2919

@mkorolyov
Copy link
Contributor Author

Hi @mykaul,

I've looked into implementing your suggestion, and it seems there are a few challenges with achieving this functionality:

  1. ScyllaDB Configuration Dependency:
    The ScyllaDB service requires a single configuration file, typically located at /etc/scylla/scylla.yaml in the official Docker image. It's straightforward to replace this file in the container using a volume mount, e.g., -v ~/master_scylla.yaml:/etc/scylla/scylla.yaml.

  2. Merging Custom Configuration:
    To merge a custom partial configuration with the default one, we would need to process and generate the final configuration file before the container starts and then mount it to the container.

  3. Extracting Default Configuration:
    One potential approach is to extract the default configuration file directly from the Docker image without starting the container. This can be done using Docker commands, such as:

    docker create --name temp-container scylladb/scylla  
    docker cp temp-container:/etc/scylla/scylla.yaml ./scylla.yaml  
    docker rm temp-container  

While this method works, it feels like a bit of a hack to me, and I’m not entirely comfortable with introducing such a workaround into the workflow.

  1. Maintaining Up-to-Date Configurations:
    Alternatively, the latest default ScyllaDB configuration file can be found in their repository here. However, storing a snapshot of this file in the testcontainers-java repository introduces a maintenance issue: it would become outdated as soon as updates are made upstream.

  2. Dynamic Fetching Concerns:
    Dynamically fetching the latest configuration file from the ScyllaDB repository during container setup (e.g., via HTTP calls) is also problematic and may not align with project standards or be acceptable to the maintainers.

Given these constraints, do you have other suggestions for achieving this functionality? Specifically, how can we ensure the availability of an up-to-date configuration file while maintaining simplicity and compatibility with the existing workflow?

Looking forward to your thoughts!

@mkorolyov
Copy link
Contributor Author

@eddumelendez Hey, thanks for stepping in and polishing PR. Just asking, why you removed custom config file related changes?

@mykaul
Copy link

mykaul commented Jan 5, 2025

@mkorolyov - thanks for looking into this. I think your point no. 1 makes a convincing argument - it's trivial to just pass a yaml file, it's quite standard, so anyone using the Scylla testcontainer can do it. Let's just document it.

@mkorolyov
Copy link
Contributor Author

@mykaul Hey, added possibility to easily replace config file for test container and documented it.

@eddumelendez Hey, added ssl integration test and documented it.

Could you pls take a look so we could proceed with it?

Appreciate your help and time!

}

@Test
public void testSslConfiguration() {
Copy link
Member

Choose a reason for hiding this comment

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

@mkorolyov this test fails. Lacking ssl configuration? default image doesn't provide those env vars

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was committed by mistake. cleaned that up, thanks!

}

@Test
public void testSimpleSsl()
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding this! I think cql cli command would not work unless is configured properly. We should configure it properly when ssl is enabled https://opensource.docs.scylladb.com/stable/operating-scylla/security/gen-cqlsh-file.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eddumelendez yes, if ssl enabled on the server for client connections in order to cqlsh to work we need to configure ssl for it too, but it is not used here, in test containers, right? I didn't get your point, could you pls clarify what else you would like to see in this PR? thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Users can execute commands using via execInContainer method provided by Testcontainers API. Testcontainers should provide a proper configuration for the container to run properly. In this case, external clients will connect properly because the sdk client is configured but not inside the container. I think we should fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a test example how to make cqlsh work with same ssl setup.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! WDYT about adding withSsl(MountableFile certificate, MountableFile keyfile, MountableFile truststore) and copy those files as part of ScyllaDBContainer. If so, then create the cqlshrc.

ScyllaDBContainer scylladb = new ScyllaDBContainer(SCYLLADB_IMAGE)
    .withConfigurationOverride("scylla-test-ssl")
    .withSsl(certificate, keyfile, truststore)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eddumelendez Sure, added withSsl. Also used SSL_CERTFILE env variable instead of rewriting cqlshrc file as there could be issues with the connection hostname specified in the file and also it simplifies setup.

@mkorolyov
Copy link
Contributor Author

@eddumelendez Hey, could you please take a look? I've updated PR according to your suggestions.

Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

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

@mkorolyov we are close. I left one more comment related to the truststore given it is optional.

return this;
}

public ScyllaDBContainer withSsl(MountableFile certificate, MountableFile keyfile, MountableFile truststore) {
Copy link
Member

Choose a reason for hiding this comment

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

truststore is optional. See https://opensource.docs.scylladb.com/stable/operating-scylla/security/client-node-encryption.html#validate-the-clients. So, we should provide another method
withSsl(MountableFile certificate, MountableFile keyfile)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch! thanks, fixed this one

Copy link
Member

Choose a reason for hiding this comment

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

I have reverted this because truststore must be at the system truststore and in order to do that we need to copy the file too. Sorry about that.

@eddumelendez eddumelendez changed the title Add scylladb Add scylladb module Jan 31, 2025
@eddumelendez eddumelendez added this to the next milestone Jan 31, 2025
@eddumelendez eddumelendez merged commit 46fe670 into testcontainers:main Jan 31, 2025
108 checks passed
@eddumelendez
Copy link
Member

Thanks for your contribution, @mkorolyov !

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.

6 participants