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

feat: support COSI BucketInfo in replica config #537

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

shanduur
Copy link

  1. feature: added support for COSI BucketInfo
    • Introduced support for Container Object Storage Interface (COSI) BucketInfo.
    • Added a new method readBucketInfo in the Config struct to read COSI BucketInfo for each database replica.
    • Created a new function parseBucketInfo to handle the parsing of BucketInfo from a specified file.
    • Modified the ReadConfigFile function to call the new readBucketInfo method.
    • The new feature enhances litestream by supporting COSI BucketInfo, enabling more versatile storage configurations in Kubernetes.

Newly introduced code allows specifying new field called bucket-info. Configuration file as this:

dbs:
  - path: /path/to/db
    replicas:
      - bucket-info: /path/to/BucketInfo

Will be expanded based on the contents of the BucketInfo file to something like this:

dbs:
  - path: /path/to/db
    replicas:
      - bucket-info: /path/to/BucketInfo
        region: foo-bar
        bucket: foo-bar
        endpoint: https://foo-bar.example.com
        secret-access-key: EXAMPLE
        access-key-id: EXAMPLE
  1. fix: remove deprecated code

    • Removed deprecated code from the codebase.
    • Eliminated obsolete functionality to maintain a clean and up-to-date codebase.
    • This commit improves the maintainability of the code by eliminating deprecated or unnecessary components.
  2. fix: removed issues found by staticcheck.

    • Addressed and resolved issues identified by staticcheck.
    • Conducted a static analysis of the code and fixed potential issues, ensuring better code quality.
    • This commit focuses on improving the codebase by eliminating potential sources of bugs or inefficiencies.
  3. feature: report errors from stopping/starting replication

    • Enhanced error reporting during the stopping and starting of replication.
    • Improved the logging of errors during these processes to provide more informative messages.
    • This improvement aids in diagnosing issues related to replication, contributing to better system observability and troubleshooting.

COSI stands for Container Object Storage Interface. It is a standard developed by the Kubernetes community as part of the SIG-Storage project. COSI focuses specifically on defining an interface for object storage systems within the context of containerized applications and orchestrators like Kubernetes.

The primary goal of COSI is to provide a standardized way for containerized applications to interact with different object storage systems seamlessly. This interface allows developers and operators to use various object storage solutions without requiring changes to the application code. It abstracts the underlying details of the object storage provider, making it easier to switch between different storage backends.

Key components of COSI include:

  1. BucketInfo: In the context of litestream's changes, BucketInfo refers to the metadata or configuration information associated with a bucket in an object storage system. It specifies details such as the bucket name, authentication credentials, endpoint, and other relevant settings.

    The BucketInfo is a JSON object inside Secret, that can be mounted in the pod. In the mount path the new file will be created called BucketInfo. The contents should look like this:

    {
        "metadata": {
            "name": "foo-bar",
            "creationTimestamp": null
        },
        "spec": {
            "bucketName": "foo-bar",
            "authenticationType": "KEY", // Alternatively IAM, not feasible in our case
            "secretS3": {
                "endpoint": "s3://foo/bar",
                "region": "foo-bar",
                "accessKeyID": "EXAMPLE",
                "accessSecretKey": "EXAMPLE"
            },
            // Only one of the secrets can be present at the time
            "secretAzure": null,
            // "secretAzure": {
            //     "accessToken": "EXAMPLE",
            //     "expiryTimeStamp": null,
            // },
            // Only one of the protocols should be present at the time
            "protocols": [
                "S3",
                // "Azure",
                // "GCS"
            ]
        }
    }
  2. Protocols: COSI supports 3 different protocols for communication with object storage systems - S3 (Simple Storage Service), Azure Blob, GCS (Google Cloud Storage).

  3. Authentication Types: COSI supports different authentication mechanisms, such as access keys, secret keys, and various authentication types specific to different object storage providers.

In the context of your litestream changes, it seems that support for parsing COSI BucketInfo is being added, allowing litestream to work with Kubernetes-compliant object storage configurations. This enhances the flexibility of litestream by supporting a wider range of object storage solutions through the COSI standard.

Signed-off-by: Mateusz Urbanek <mateusz.urbanek.98@gmail.com>
Signed-off-by: Mateusz Urbanek <mateusz.urbanek.98@gmail.com>
Signed-off-by: Mateusz Urbanek <mateusz.urbanek.98@gmail.com>
Signed-off-by: Mateusz Urbanek <mateusz.urbanek.98@gmail.com>
@shanduur
Copy link
Author

@benbjohnson I am willing to keep the maintenance of that feature, update API and extend functionality if needed.

return fmt.Errorf("unable to decode BucketInfo: %w", err)
}

switch {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is a cool PR, but this switch is not configuring Azure or GCP.

Copy link
Author

Choose a reason for hiding this comment

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

Yep, it is not. I will do that soon for Azure, not sure about GCP, as there is no GCP secret defined in COSI alpha specification.

Copy link
Author

Choose a reason for hiding this comment

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

Ah, I don't know if the Azure Blob provides enough info for the litestream to configure replica client - it is only giving the BucketName and AccessToken - this probably is not enough data.

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.

None yet

2 participants