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 convenience method for authenticating with astra via db_id and token #1228

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

Conversation

jbellis
Copy link

@jbellis jbellis commented Sep 14, 2024

example usage:

from cassandra.cluster import Cluster

cloud_config = {
    'db_id': '04ab96df-...',
    'token': 'AstraCS:...'
    }
cluster = Cluster(cloud=cloud_config)

if 'db_id' in cloud and 'token' in cloud:
# download SCB if necessary
if 'secure_connect_bundle' not in cloud:
bundle_path = f'astra-secure-connect-{cloud["db_id"]}.zip'
Copy link
Contributor

Choose a reason for hiding this comment

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

Since each region within a given Astra DB cluster has its own SCB, how do we handle a multi-region scenario here?

@jbellis
Copy link
Author

jbellis commented Sep 19, 2024 via email

@msmygit
Copy link
Contributor

msmygit commented Sep 19, 2024

If you have a good solution, I can give it a try. Otherwise I'm happy for this to be a single region option.

Hi @jbellis please review the patch that I've submitted here to your fork, jbellis#1

The signature when specifying the region identifier will now be:

from cassandra.cluster import Cluster

cloud_config = {
    'db_id': '04ab96df-...',
    'token': 'AstraCS:...',
    'db_region': 'us-east4'
    }
cluster = Cluster(cloud=cloud_config)

and if the region identifier is not provided, the signature will be as follows and we will just return the SCB URL for the primary region (will work for single-region scenario too),

from cassandra.cluster import Cluster

cloud_config = {
    'db_id': '04ab96df-...',
    'token': 'AstraCS:...'
    }
cluster = Cluster(cloud=cloud_config)

and this work both for single- as well as multi-region Astra DB clusters. Let me know WDYT? Thank you in advance!

@absurdfarce
Copy link
Collaborator

We've had discussions about adding automatic download of the SCB into the drivers as an option in the past and in the end the decision has always been not to do so. That API has changed underneath us in the past IIRC but far more importantly it makes the DevOps API outages production-level issues for lots of clients... and DBPE has expressed some reservation about elevating that API to that status.

@joao-r-reis I know you and I have had these discussions in the past. Did I misrepresent/get anything wrong in the description above?

@jbellis
Copy link
Author

jbellis commented Sep 23, 2024 via email

@jbellis
Copy link
Author

jbellis commented Sep 24, 2024

That API has changed underneath us in the past IIRC

It's a public, documented API. I think this is a non issue now. https://docs.datastax.com/en/astra-api-docs/_attachments/devops-api/index.html#tag/Database-Operations/operation/listDatacenters

@phact
Copy link
Contributor

phact commented Sep 24, 2024

but far more importantly it makes the DevOps API outages production-level issues for lots of clients...

would caching it on disk alleviate your concern @absurdfarce

@absurdfarce
Copy link
Collaborator

It doesn't @phact. The API stability concerns are definitely a second-tier issue. The much larger issue for me is that we have spoken with ProdEng about this specific change and been told that we don't know that the relevant APIs/downloads were something that should be exposed for broad public use at the rates we'd expect from wide deployment of the drivers.

Even if that were no longer the case I wouldn't want to address this as a one-off for a single driver. I'd prefer to see a proposal to fix this handled as part of our product planning process so that we can deploy it uniformly to all drivers in a way that keeps the interface reasonably consistent. I'll raise this with our product folks so that they're aware of it.

@msmygit
Copy link
Contributor

msmygit commented Sep 28, 2024

I also just realized we have this https://github.com/mieslep/cassandra-connector/blob/main/cassandra_connector/cassandra_connector.py#L38 which could be improvized outside of the python driver itself to just accept the DB ID (as opposed to the endpoint as is being currently available here).

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.

4 participants