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

Support more storages #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Support more storages #77

wants to merge 2 commits into from

Conversation

jnmt
Copy link
Contributor

@jnmt jnmt commented Dec 17, 2024

Description

This PR adds more storage configurations so that users can choose any supported storage. I will update the getting started guide once this PR is merged. The instructions are as follows. If you want to use another storage, just change the storage name (except for Cosmos DB since there is only an emulator for the docker container, and it's stable).

  1. Start storage
docker compose -f docker-compose-ledger-mysql.yml up -d mysql
  1. Load schema
docker compose -f docker-compose-ledger-mysql.yml up -d scalardl-ledger-schema-loader
  1. Start Ledger (and envoy and CA server)
docker compose -f docker-compose-ledger-mysql.yml up -d

You can start all services at once by executing only the last one, but I think it's better to let users follow these steps (in the quick start guide) to understand what's necessary to use ScalarDL and what they are doing.

Related issues and/or PRs

N/A

Changes made

  • Add storage-specific docker-compose configurations and storage configurations

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes. Will be updated later
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes. Tested locally
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

  • Old configurations only for Cassandra will be removed after the document is updated.
  • We can add similar configurations for the Auditor mode, but I think preparing all of them might be too much for samples. Let's discuss it if you have opinions.

@jnmt jnmt self-assigned this Dec 17, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kota2and3kan In the previous discussion, we planned to remove these template files after including license settings in the templates on the docker container side. But I'm now changing my mind and would like to keep them for a while since these are sometimes useful for handling some special cases (at this time, for DynamoDB).

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. I understood!

@jnmt
Copy link
Contributor Author

jnmt commented Dec 18, 2024

@feeblefakie include works fine instead of using -f in the command line. Thanks for the suggestion. I also looked into extends to further reduce lines of configuration since it seems to have an override feature. However, I think we should not use it here because it would make users confused when they want to customize the compose file.

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

Copy link
Contributor

@kota2and3kan kota2and3kan left a comment

Choose a reason for hiding this comment

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

Thank you for the updates!
I was able to run all database patterns in my local environment. So, basically, looks good to me.
However, I left several comments and suggestions.
Please take a look when you have time! 🙇‍♂️


FYI:

Test result
  • MySQL

    $ docker compose -f docker-compose-ledger-mysql.yml ps
    NAME                                 IMAGE                                             COMMAND                  SERVICE           CREATED         STATUS                   PORTS
    mysql-1                              mysql:8.1                                         "docker-entrypoint.s…"   mysql             9 minutes ago   Up 9 minutes (healthy)   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp
    scalardl-samples-cfssl-ocspserve-1   ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-ocspserve   2 minutes ago   Up 2 minutes             8888/tcp, 0.0.0.0:8889->8889/tcp, :::8889->8889/tcp
    scalardl-samples-cfssl-serve-1       ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-serve       2 minutes ago   Up 2 minutes             0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 8889/tcp
    scalardl-samples-ledger-envoy-1      ghcr.io/scalar-labs/scalar-envoy:1.5.0            "/entrypoint.sh"         ledger-envoy      2 minutes ago   Up 2 minutes             9001/tcp, 0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 10000/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, :::50051-50052->50051-50052/tcp
    scalardl-samples-scalar-ledger-1     ghcr.io/scalar-labs/scalardl-ledger-byol:3.10.0   "./docker-entrypoint…"   scalar-ledger     2 minutes ago   Up 2 minutes (healthy)   50051/tcp
    $ scalardl register-secret --config ~/tmp/client.properties
    {
      "status_code" : "OK",
      "output" : null
    }
  • PostgreSQL

    $ docker compose -f docker-compose-ledger-postgres.yml ps
    NAME                                 IMAGE                                             COMMAND                  SERVICE           CREATED          STATUS                    PORTS
    postgres-1                           postgres:15                                       "docker-entrypoint.s…"   postgres          4 minutes ago    Up 3 minutes (healthy)    0.0.0.0:5432->5432/tcp, :::5432->5432/tcp
    scalardl-samples-cfssl-ocspserve-1   ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-ocspserve   49 seconds ago   Up 47 seconds             8888/tcp, 0.0.0.0:8889->8889/tcp, :::8889->8889/tcp
    scalardl-samples-cfssl-serve-1       ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-serve       49 seconds ago   Up 47 seconds             0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 8889/tcp
    scalardl-samples-ledger-envoy-1      ghcr.io/scalar-labs/scalar-envoy:1.5.0            "/entrypoint.sh"         ledger-envoy      49 seconds ago   Up 44 seconds             9001/tcp, 0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 10000/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, :::50051-50052->50051-50052/tcp
    scalardl-samples-scalar-ledger-1     ghcr.io/scalar-labs/scalardl-ledger-byol:3.10.0   "./docker-entrypoint…"   scalar-ledger     49 seconds ago   Up 46 seconds (healthy)   50051/tcp
    $ scalardl register-secret --config ~/tmp/client.properties
    {
      "status_code" : "OK",
      "output" : null
    }
  • Cassandra

    $ docker compose -f docker-compose-ledger-cassandra.yml ps
    NAME                                 IMAGE                                             COMMAND                  SERVICE           CREATED              STATUS                        PORTS
    scalardl-samples-cassandra-1         cassandra:3.11                                    "docker-entrypoint.s…"   cassandra         2 minutes ago        Up 2 minutes (healthy)        7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp
    scalardl-samples-cfssl-ocspserve-1   ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-ocspserve   About a minute ago   Up About a minute             8888/tcp, 0.0.0.0:8889->8889/tcp, :::8889->8889/tcp
    scalardl-samples-cfssl-serve-1       ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-serve       About a minute ago   Up About a minute             0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 8889/tcp
    scalardl-samples-ledger-envoy-1      ghcr.io/scalar-labs/scalar-envoy:1.5.0            "/entrypoint.sh"         ledger-envoy      About a minute ago   Up About a minute             9001/tcp, 0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 10000/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, :::50051-50052->50051-50052/tcp
    scalardl-samples-scalar-ledger-1     ghcr.io/scalar-labs/scalardl-ledger-byol:3.10.0   "./docker-entrypoint…"   scalar-ledger     About a minute ago   Up About a minute (healthy)   50051/tcp
    $ scalardl register-secret --config ~/tmp/client.properties
    {
      "status_code" : "OK",
      "output" : null
    }
  • DynamoDB

    $ docker compose -f docker-compose-ledger-dynamodb.yml ps
    NAME                                 IMAGE                                             COMMAND                  SERVICE           CREATED          STATUS                    PORTS
    dynamodb-1                           amazon/dynamodb-local:2.5.2                       "java -jar DynamoDBL…"   dynamodb          11 minutes ago   Up 10 minutes (healthy)   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp
    scalardl-samples-cfssl-ocspserve-1   ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-ocspserve   40 seconds ago   Up 38 seconds             8888/tcp, 0.0.0.0:8889->8889/tcp, :::8889->8889/tcp
    scalardl-samples-cfssl-serve-1       ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-serve       40 seconds ago   Up 38 seconds             0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 8889/tcp
    scalardl-samples-ledger-envoy-1      ghcr.io/scalar-labs/scalar-envoy:1.5.0            "/entrypoint.sh"         ledger-envoy      40 seconds ago   Up 23 seconds             9001/tcp, 0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 10000/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, :::50051-50052->50051-50052/tcp
    scalardl-samples-scalar-ledger-1     ghcr.io/scalar-labs/scalardl-ledger-byol:3.10.0   "./docker-entrypoint…"   scalar-ledger     40 seconds ago   Up 24 seconds (healthy)   50051/tcp
    $ scalardl register-secret --config ~/tmp/client.properties
    {
      "status_code" : "OK",
      "output" : null
    }
  • Oracle DB

    $ docker compose -f docker-compose-ledger-oracle.yml ps
    NAME                                 IMAGE                                                  COMMAND                  SERVICE           CREATED              STATUS                        PORTS
    oracle-1                             container-registry.oracle.com/database/free:23.4.0.0   "/bin/bash -c $ORACL…"   oracle            4 minutes ago        Up 4 minutes (healthy)        0.0.0.0:1521->1521/tcp, :::1521->1521/tcp
    scalardl-samples-cfssl-ocspserve-1   ghcr.io/scalar-labs/scalar-cfssl:1.0.0                 "docker-entrypoint.s…"   cfssl-ocspserve   About a minute ago   Up About a minute             8888/tcp, 0.0.0.0:8889->8889/tcp, :::8889->8889/tcp
    scalardl-samples-cfssl-serve-1       ghcr.io/scalar-labs/scalar-cfssl:1.0.0                 "docker-entrypoint.s…"   cfssl-serve       About a minute ago   Up About a minute             0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 8889/tcp
    scalardl-samples-ledger-envoy-1      ghcr.io/scalar-labs/scalar-envoy:1.5.0                 "/entrypoint.sh"         ledger-envoy      About a minute ago   Up 58 seconds                 9001/tcp, 0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 10000/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, :::50051-50052->50051-50052/tcp
    scalardl-samples-scalar-ledger-1     ghcr.io/scalar-labs/scalardl-ledger-byol:3.10.0        "./docker-entrypoint…"   scalar-ledger     About a minute ago   Up About a minute (healthy)   50051/tcp
    $ scalardl register-secret --config ~/tmp/client.properties
    {
      "status_code" : "OK",
      "output" : null
    }
  • SQL Server

    $ docker compose -f docker-compose-ledger-sqlserver.yml ps
    NAME                                 IMAGE                                             COMMAND                  SERVICE           CREATED         STATUS                   PORTS
    scalardl-samples-cfssl-ocspserve-1   ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-ocspserve   2 minutes ago   Up 2 minutes             8888/tcp, 0.0.0.0:8889->8889/tcp, :::8889->8889/tcp
    scalardl-samples-cfssl-serve-1       ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-serve       2 minutes ago   Up 2 minutes             0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 8889/tcp
    scalardl-samples-ledger-envoy-1      ghcr.io/scalar-labs/scalar-envoy:1.5.0            "/entrypoint.sh"         ledger-envoy      2 minutes ago   Up About a minute        9001/tcp, 0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 10000/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, :::50051-50052->50051-50052/tcp
    scalardl-samples-scalar-ledger-1     ghcr.io/scalar-labs/scalardl-ledger-byol:3.10.0   "./docker-entrypoint…"   scalar-ledger     2 minutes ago   Up 2 minutes (healthy)   50051/tcp
    sqlserver-1                          mcr.microsoft.com/mssql/server:2022-latest        "/opt/mssql/bin/perm…"   sqlserver         5 minutes ago   Up 4 minutes (healthy)   0.0.0.0:1433->1433/tcp, :::1433->1433/tcp
    $ scalardl register-secret --config ~/tmp/client.properties
    {
      "status_code" : "OK",
      "output" : null
    }
  • Cosmos DB

    $ docker compose -f docker-compose-ledger-cosmosdb.yml ps
    NAME                                 IMAGE                                             COMMAND                  SERVICE           CREATED         STATUS                        PORTS
    scalardl-samples-cfssl-ocspserve-1   ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-ocspserve   2 minutes ago   Up 2 minutes                  8888/tcp, 0.0.0.0:8889->8889/tcp, :::8889->8889/tcp
    scalardl-samples-cfssl-serve-1       ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-serve       2 minutes ago   Up 2 minutes                  0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 8889/tcp
    scalardl-samples-ledger-envoy-1      ghcr.io/scalar-labs/scalar-envoy:1.5.0            "/entrypoint.sh"         ledger-envoy      2 minutes ago   Up About a minute             9001/tcp, 0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 10000/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, :::50051-50052->50051-50052/tcp
    scalardl-samples-scalar-ledger-1     ghcr.io/scalar-labs/scalardl-ledger-byol:3.10.0   "./docker-entrypoint…"   scalar-ledger     2 minutes ago   Up About a minute (healthy)   50051/tcp
    $ scalardl register-secret --config ~/tmp/client.properties
    {
      "status_code" : "OK",
      "output" : null
    }

@@ -0,0 +1,62 @@
services:
ledger-envoy:
image: ghcr.io/scalar-labs/scalar-envoy:1.5.0
Copy link
Contributor

@kota2and3kan kota2and3kan Dec 26, 2024

Choose a reason for hiding this comment

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

Suggested change
image: ghcr.io/scalar-labs/scalar-envoy:1.5.0
image: ghcr.io/scalar-labs/scalar-envoy:1.6.1

I think it would be better to use the latest version of Scalar Envoy. For example, the latest helm chart of ScalarDL 3.10 uses Scalar Envoy 1.6.1 in its internal.
https://github.com/scalar-labs/helm-charts/blob/scalardl-4.9.1/charts/scalardl/values.yaml#L40

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. I understood!

networks:
- scalar-network

cfssl-init:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not directly related to this PR, but I have one question.

Is CFSSL necessary for running scalardl-samples? I think if users want to generate a private key and certificate by using this CFSSL server, I think we need to deploy it. However, now, we are using the private key and certificate under the fixture/ directory. So, I want to confirm whether this CFSSL server is necessary or not.

If it's not mandatory, I think we can make it an optional component. For example, we can set the profiles configuration as follows:

$ git diff docker-compose-ledger-common.yml
diff --git a/docker-compose-ledger-common.yml b/docker-compose-ledger-common.yml
index 6a4481c..982dc41 100644
--- a/docker-compose-ledger-common.yml
+++ b/docker-compose-ledger-common.yml
@@ -23,6 +23,8 @@ services:
     # they start up at the same time (by commands like `docker-compose up`),
     # they both attempt to generate the same missing certificate files, which
     # results in a race condition.
+    profiles:
+      - cfssl
     image: ghcr.io/scalar-labs/scalar-cfssl:1.0.0
     container_name: "scalardl-samples-cfssl-init-1"
     volumes:
@@ -32,6 +34,8 @@ services:
       - scalar-network

   cfssl-serve:
+    profiles:
+      - cfssl
     image: ghcr.io/scalar-labs/scalar-cfssl:1.0.0
     container_name: "scalardl-samples-cfssl-serve-1"
     volumes:
@@ -45,6 +49,8 @@ services:
       - scalar-network

   cfssl-ocspserve:
+    profiles:
+      - cfssl
     image: ghcr.io/scalar-labs/scalar-cfssl:1.0.0
     container_name: "scalardl-samples-cfssl-ocspserve-1"
     volumes:

In this case, the CFSSL server is not deployed by default as follows:

  • Default behavior
    $ docker compose -f docker-compose-ledger-postgres.yml up -d
    
    $ docker compose -f docker-compose-ledger-postgres.yml ps
    NAME                               IMAGE                                             COMMAND                  SERVICE         CREATED         STATUS                        PORTS
    postgres-1                         postgres:15                                       "docker-entrypoint.s…"   postgres        2 minutes ago   Up About a minute (healthy)   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp
    scalardl-samples-ledger-envoy-1    ghcr.io/scalar-labs/scalar-envoy:1.5.0            "/entrypoint.sh"         ledger-envoy    8 seconds ago   Up 4 seconds                  9001/tcp, 0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 10000/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, :::50051-50052->50051-50052/tcp
    scalardl-samples-scalar-ledger-1   ghcr.io/scalar-labs/scalardl-ledger-byol:3.10.0   "./docker-entrypoint…"   scalar-ledger   8 seconds ago   Up 6 seconds (healthy)        50051/tcp
    

Also, if you want to deploy the CFSSL server, you can specify it by using the --profile option as follows:

  • Specify the profile explicitly
    $ docker compose -f docker-compose-ledger-postgres.yml --profile cfssl up -d
    
    $ docker compose -f docker-compose-ledger-postgres.yml ps
    NAME                                 IMAGE                                             COMMAND                  SERVICE           CREATED              STATUS                        PORTS
    postgres-1                           postgres:15                                       "docker-entrypoint.s…"   postgres          3 minutes ago        Up 3 minutes (healthy)        0.0.0.0:5432->5432/tcp, :::5432->5432/tcp
    scalardl-samples-cfssl-ocspserve-1   ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-ocspserve   10 seconds ago       Up 8 seconds                  8888/tcp, 0.0.0.0:8889->8889/tcp, :::8889->8889/tcp
    scalardl-samples-cfssl-serve-1       ghcr.io/scalar-labs/scalar-cfssl:1.0.0            "docker-entrypoint.s…"   cfssl-serve       10 seconds ago       Up 8 seconds                  0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 8889/tcp
    scalardl-samples-ledger-envoy-1      ghcr.io/scalar-labs/scalar-envoy:1.5.0            "/entrypoint.sh"         ledger-envoy      About a minute ago   Up About a minute             9001/tcp, 0.0.0.0:9901->9901/tcp, :::9901->9901/tcp, 10000/tcp, 0.0.0.0:50051-50052->50051-50052/tcp, :::50051-50052->50051-50052/tcp
    scalardl-samples-scalar-ledger-1     ghcr.io/scalar-labs/scalardl-ledger-byol:3.10.0   "./docker-entrypoint…"   scalar-ledger     About a minute ago   Up About a minute (healthy)   50051/tcp
    

If it's not a mandatory component, I think we can make it an optional thing as I mentioned above. This is because:

  • We can reduce deployed components.
    • It can make a system simple. Especially, for the local testing purpose of application developers, I think fewer components and resources are a better choice.
  • We can reduce unnecessary confusion and questions from actual users.
    • If there are some components that users cannot understand easily, they might confused and ask the support team What are these components? or Do we need CFSSL in the production environment? etc... To avoid such things, I think it would be better to keep the system (test environment) simple and minimal by default.

What do you think?
This comment does not prevent merging this PR, but I want to discuss it with you later!

@@ -76,7 +75,7 @@ services:
- SCALAR_DL_LEDGER_AUDITOR_ENABLED=true

scalar-auditor:
Copy link
Contributor

Choose a reason for hiding this comment

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

We can add similar configurations for the Auditor mode, but I think preparing all of them might be too much for samples. Let's discuss it if you have opinions.

I considered some efficient ways and tried to implement some of them in my local environment. However, I was not able to good way... (I faced a bit difficult problem with the include configuration...) We might need to implement all docker-compose-auditor-xxxx.yml files one by one...

And, I agree with you. Preparing all files might be too much for testing purposes. So, at the moment, I think we don't need to provide Auditor things for all databases. At least, users can deploy Auditor with Cassandra by using the previous way.

However, sometimes, users (especially, application developers) want to test ScalarDL Auditor on their local environment for testing and developing their applications. So, We might need to continue to consider this challenge.

Anyway, I don't think we need Auditor configurations for all storage at the moment. Let's discuss this later when we have a chance!

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.

3 participants