How to get data using Stargate on DataStax Enterprise

343 views Asked by At

I have datastax cassandra 6.8 installed in dev server and i also installed Stargate newest version in another dev server. The connection is established between Stargate and Cassandra. I dont see anything error in log file. I am able to use postman to run a rest call to Stargate to get auth_token. After that, i set that token to header and make a GET call to retrieve data

 http://{{dev server and port}}/v2/keyspaces/dco/test1?where={"id":{"$eq":"c8e67364-1547-4833-9208-9ea9c0f0acf6"}}

I get this error

{
    "description": "Server error: org.apache.cassandra.stargate.transport.ServerError: Unexpected persistence error: Name authentication_schemes/INTERNAL is not valid for any resource type",
    "code": 500
}

The error looks like my user/pass that i used to get auth_token doesn't have right to retrieve data. But I have tried to use that user/pass to login cassandra and i am able to do select and insert queries.

Could you please help me to figure out how i bypass this problem.

Below are my screenshot of postman and Cassandra db

enter image description here

Cassandra table test1 (id is uuid and primary key)

id                                   | create_date
--------------------------------------+---------------------------------
 f47dee1b-1b51-4e25-933f-6f3f8817a6f5 | 1970-01-01 00:00:00.000000+0000
 c8e67364-1547-4833-9208-9ea9c0f0acf6 | 2021-09-16 18:59:16.352000+0000
 faae6180-0464-11ec-9a03-0242ac130003 | 2009-07-13 08:30:12.000000+0000
2

There are 2 answers

0
Erick Ramirez On

There isn't enough information in your post to determine what the underlying problem is so I'm going to post my test environment so you could compare it to yours.

DSE configuration

This is my single-node DSE 6.8.15 cluster:

$ nodetool status
Datacenter: Cassandra
=====================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving/Stopped
--  Address        Load       Tokens       Owns (effective)  Host ID                               Rack
UN  10.101.36.175  203.4 KiB  8            100.0%            722c2393-92c8-4eb5-999c-c39063a9aee5  rack1

These are the entries I've configured in cassandra.yaml:

cluster_name: 'stargate'
seed_provider:
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          - seeds: "10.101.36.175"
listen_address: 10.101.36.175
native_transport_address: 10.101.36.175

And in dse.yaml:

authentication_options:
    enabled: true
    default_scheme: internal

Stargate configuration

The IP of my Stargate node is 10.101.36.44 and I've started it with:

$ starctl \
  --cluster-name stargate \
  --cluster-seed 10.101.36.175 \
  --cluster-version 6.8 \
  --listen 10.101.36.44 \
  --dc Cassandra \
  --rack rack1 \
  --dse \
  --enable-auth

For reference, I used the example in the Stargate.io Installation Guide.

Once Stargate is up, I can confirm that all the necessary ports for the API endpoints are up:

$ sudo lsof -nPi -sTCP:LISTEN
COMMAND    PID            USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
systemd-r  817 systemd-resolve   13u  IPv4  22041      0t0  TCP 127.0.0.53:53 (LISTEN)
sshd      1136            root    3u  IPv4  25117      0t0  TCP *:22 (LISTEN)
sshd      1136            root    4u  IPv6  25128      0t0  TCP *:22 (LISTEN)
java      8724          ubuntu  467u  IPv6  59646      0t0  TCP *:7199 (LISTEN)
java      8724          ubuntu  468u  IPv6  59647      0t0  TCP *:37421 (LISTEN)
java      8724          ubuntu  473u  IPv6  59240      0t0  TCP 10.101.36.44:7000 (LISTEN)
java      8724          ubuntu  851u  IPv6  61496      0t0  TCP *:8081 (LISTEN)
java      8724          ubuntu  866u  IPv6  62632      0t0  TCP *:8090 (LISTEN)
java      8724          ubuntu  867u  IPv6  63503      0t0  TCP *:8084 (LISTEN)
java      8724          ubuntu  872u  IPv6  65299      0t0  TCP *:8080 (LISTEN)
java      8724          ubuntu  889u  IPv6  63517      0t0  TCP *:9042 (LISTEN)
java      8724          ubuntu 1013u  IPv6  65561      0t0  TCP *:8082 (LISTEN)

Testing

In my cluster, I have created this table:

CREATE KEYSPACE sgoneks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;

CREATE TABLE sgoneks.vaccinations_by_name (
    name text PRIMARY KEY,
    firstdose date,
    seconddose date,
    vaccine text
)

And the table contains the following data:

sguser@cqlsh> SELECT * FROM sgoneks.vaccinations_by_name ;

 name   | firstdose  | seconddose | vaccine
--------+------------+------------+-------------
    bob | 2021-02-28 | 2021-05-23 | astrazeneca
 carlos | 2021-03-12 | 2021-04-02 | astrazeneca
  alice | 2021-06-20 | 2021-07-19 |      pfizer

Here is how I generated the authentication token and saved it as an environment variable:

$ curl -L -X POST 'http://10.101.36.44:8081/v1/auth' \
    -H 'Content-Type: application/json' \
    --data-raw '{"username":"sguser", "password":"sguser"}'
{"authToken":"41867001-216d-4525-b612-6b883a64984d"}
$ export AUTH_TOKEN="41867001-216d-4525-b612-6b883a64984d"

Here's a quick connectivity test by checking that the sgoneks keyspace exists:

$ curl -L -X GET 'http://10.101.36.44:8082/v2/schemas/keyspaces/sgoneks' \
    -H 'Content-Type: application/json' \
    -H "X-Cassandra-Token: $AUTH_TOKEN" \
    -H "Accept: application/json" \
    | jq
{
  "data": {
    "name": "sgoneks"
  }
}

Finally, I retrieved the vaccination details for name='alice' here:

$ curl -L -X GET 'http://10.101.36.44:8082/v2/keyspaces/sgoneks/vaccinations_by_name/alice' \
    -H 'Content-Type: application/json' \
    -H "X-Cassandra-Token: $AUTH_TOKEN" \
    | jq
{
  "count": 1,
  "data": [
    {
      "name": "alice",
      "firstdose": {
        "year": 2021,
        "month": "JUNE",
        "monthValue": 6,
        "chronology": {
          "calendarType": "iso8601",
          "id": "ISO"
        },
        "dayOfMonth": 20,
        "dayOfWeek": "SUNDAY",
        "era": "CE",
        "dayOfYear": 171,
        "leapYear": false
      },
      "seconddose": {
        "year": 2021,
        "month": "JULY",
        "monthValue": 7,
        "chronology": {
          "calendarType": "iso8601",
          "id": "ISO"
        },
        "dayOfMonth": 19,
        "dayOfWeek": "MONDAY",
        "era": "CE",
        "dayOfYear": 200,
        "leapYear": false
      },
      "vaccine": "pfizer"
    }
  ]
}

As a side note, you might find it easier to just use Astra DB because it comes with Stargate.io pre-configured and ready to use.

If you're still having issues with your DSE installation, I'd recommend logging a ticket with DataStax Support so one of our engineers can assist you directly. Cheers!

0
dwettlaufer On

Are you by chance using LDAP auth in your DSE cluster? At this time it's not supported in Stargate which could be causing the error you're seeing.

If possible I'd try revoking the INTERNAL related permissions for the role you're using. You can also try creating a new role with only basic permissions and no authentication schemes.