-
Notifications
You must be signed in to change notification settings - Fork 331
Description
A couple issues I had running through the quickstart, which just may documentation issues.
- I deployed using Docker Compose
Looking at the stdout output I did not find what the docs asked me to look for:
**Bootstrapped with credentials: {"client-id": "XXXX", "client-secret": "YYYY"}**
But I did find this which I assumed was what I was looking for:
realm: default-realm root principal credentials: fa44645a04410a0e:f1b82a42de2295da466682d3cfdbb0f1
I assume the format in this case was id:secret
So then ran the CLI command
./polaris \
--client-id fa44645a04410a0e \
--client-secret f1b82a42de2295da466682d3cfdbb0f1 \
catalogs \
create \
--storage-type s3 \
--default-base-location s3://some-example-bucket/folder/ \
--role-arn arn:aws:iam::###########:role/polaris-storage \
first-polaris-catalog
I ran into a few issues:
-
The Polaris CLI startup script did still needed Pydantic and dateutil to be installed, so I had to install those manually, assuming probably poetry. I do see them in the pyproject.toml, so I'm assuming that's more a "my system" problem, so Installed them in the virtual environment that was created and all seems to work fine now.
-
I ran the command above and got a JSON parsing error
Traceback (most recent call last):
File "/home/alexmerced/development/developmentwork/dremio/repos/polaris/regtests/client/python/cli/polaris_cli.py", line 73, in <module>
PolarisCli.execute()
File "/home/alexmerced/development/developmentwork/dremio/repos/polaris/regtests/client/python/cli/polaris_cli.py", line 45, in execute
error = json.loads(e.body)['error']
^^^^^^^^^^^^^^^^^^
File "/home/alexmerced/.pyenv/versions/3.11.2/lib/python3.11/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alexmerced/.pyenv/versions/3.11.2/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alexmerced/.pyenv/versions/3.11.2/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- This wasn't super helpful so I modified polaris_cli.py to get me more detail
from cli.options.parser import Parser
from polaris.management import ApiClient, Configuration, ApiException
from polaris.management import PolarisDefaultApi
class PolarisCli:
"""
Implements a basic Command-Line Interface (CLI) for interacting with a Polaris service. The CLI can be used to
manage entities like catalogs, principals, and grants within Polaris and can perform most operations that are
available in the Python client API.
Example usage:
* ./polaris --client-id ${id} --client-secret ${secret} --host ${hostname} principals create example_user
* ./polaris --client-id ${id} --client-secret ${secret} --host ${hostname} principal-roles create example_role
* ./polaris --client-id ${id} --client-secret ${secret} --host ${hostname} catalog-roles list
"""
@staticmethod
def execute():
options = Parser.parse()
client_builder = PolarisCli._get_client_builder(options)
with client_builder() as api_client:
try:
from cli.command import Command
admin_api = PolarisDefaultApi(api_client)
command = Command.from_options(options)
command.execute(admin_api)
except ApiException as e:
import json
print(f'Exception when communicating with the Polaris server. Status code: {e.status}')
print(f'Response headers: {e.headers}')
print(f'Response body: {e.body}')
try:
error = json.loads(e.body)['error']
print(f'{error["type"]}: {error["message"]}')
except (json.JSONDecodeError, KeyError):
print('Error parsing response as JSON. Raw response body:')
print(e.body)
@staticmethod
def _get_client_builder(options):
# Validate
has_access_token = options.access_token is not None
has_client_secret = options.client_id is not None and options.client_secret is not None
if has_access_token and has_client_secret:
raise Exception("Please provide credentials via either --client-id / --client-secret or "
"--access-token, but not both")
# Authenticate accordingly
polaris_catalog_url = f'http://{options.host}:{options.port}/api/management/v1'
if has_access_token:
return lambda: ApiClient(
Configuration(host=polaris_catalog_url, access_token=options.access_token),
)
elif has_client_secret:
return lambda: ApiClient(
Configuration(host=polaris_catalog_url, username=options.client_id, password=options.client_secret),
)
else:
raise Exception("Please provide credentials via --client-id & --client-secret or via --access-token")
if __name__ == '__main__':
PolarisCli.execute()- So running this version of python_cli.py I got the following output:
Exception when communicating with the Polaris server. Status code: 401
Response headers: HTTPHeaderDict({'Date': 'Wed, 31 Jul 2024 15:16:14 GMT', 'Vary': 'Origin', 'WWW-Authenticate': 'Bearer realm="realm"', 'Content-Type': 'text/plain', 'Content-Length': '49'})
Response body: Credentials are required to access this resource.
Error parsing response as JSON. Raw response body:
Credentials are required to access this resource.
So I'm assuming the client-id and client-secret aren't what I thought they were or I passed them incorrectly, any guidance on this would be helpful.