Skip to content

Commit

Permalink
fix: clickhouse client permission error
Browse files Browse the repository at this point in the history
Clickhouse client command was triggering a permission denied error:

$ tutor local run cairn-clickhouse cairn-client
Code: 586. DB::ErrnoException: Cannot create file:
//.clickhouse-client-history, errno: 13, strerror: Permission denied.
(CANNOT_CREATE_FILE)

Traceback (most recent call last):
  File "/scripts/cairn", line 161, in <module>
    main()
  File "/scripts/cairn", line 62, in main
    args.func(args)
  File "/scripts/cairn", line 68, in command_client
    subprocess.check_call(get_client_command())
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['clickhouse', 'client',
'--host', 'cairn-clickhouse', '--port', '9000', '--user', 'openedx',
'--password', 'xrIDmynTAiDuJeVZc5ar', '--multiline', '--multiquery',
'--database', 'openedx']' returned non-zero exit status 74.

This was because the home of the cairn client was set to "/".
  • Loading branch information
regisb committed Mar 16, 2023
1 parent c3f74e7 commit 237432a
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def command_migrate(args):
migrations = sorted(glob(os.path.join(args.path, "*")))
for path in migrations:
migration_name = os.path.basename(path)
print(
f"Applying migration {migration_name}... ", end=" "
)
print(f"Applying migration {migration_name}... ", end=" ")
query = f"SELECT 'applied' FROM _migrations WHERE name='{migration_name}'"
is_applied = run_query(query)
if is_applied == "applied":
Expand Down Expand Up @@ -150,6 +148,7 @@ def get_client_command_no_db(*args):
CLICKHOUSE_AUTH["password"],
"--multiline",
"--multiquery",
"--history_file=/tmp/.clickhouse-client-history",
]
if CLICKHOUSE_AUTH["http_scheme"] == "https":
command.append("--secure")
Expand Down

0 comments on commit 237432a

Please sign in to comment.