Skip to content

Commit e0df07b

Browse files
authored
docs(getting-started): update stackablectl op install output (#589)
* docs(getting-started): update stackablectl op install output * chore(getting-started): add warning to generated script * chore(ruff): formatting * chore(clippy): resolve warning * chore(nix): update Cargo.nix * chore(shellcheck): ignore warnings that are not relevant in this context --------- Co-authored-by: Nick <[email protected]>
1 parent 7c12f6b commit e0df07b

File tree

13 files changed

+189
-107
lines changed

13 files changed

+189
-107
lines changed

docs/modules/druid/examples/getting_started/getting_started.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
# DO NOT EDIT THE SCRIPT
5+
# Instead, update the j2 template, and regenerate it for dev:
6+
# cat <<EOF | jinja2 --format yaml getting_started.sh.j2 -o getting_started.sh
7+
# helm:
8+
# repo_name: stackable-dev
9+
# repo_url: https://repo.stackable.tech/repository/helm-dev/
10+
# versions:
11+
# commons: 0.0.0-dev
12+
# druid: 0.0.0-dev
13+
# hdfs: 0.0.0-dev
14+
# listener: 0.0.0-dev
15+
# secret: 0.0.0-dev
16+
# zk: 0.0.0-dev
17+
# EOF
18+
419
# The getting started guide script
520
# It uses tagged regions which are included in the documentation
621
# https://docs.asciidoctor.org/asciidoc/latest/directives/include-tagged-regions/
@@ -122,10 +137,12 @@ kubectl rollout status --watch statefulset/simple-druid-router-default --timeout
122137
# end::watch-druid-rollout[]
123138

124139
echo "Starting port-forwarding of port 8888"
140+
# shellcheck disable=2069 # we want all output to be blackholed
125141
# tag::port-forwarding[]
126142
kubectl port-forward svc/simple-druid-router 8888 > /dev/null 2>&1 &
127143
# end::port-forwarding[]
128144
PORT_FORWARD_PID=$!
145+
# shellcheck disable=2064 # we want the PID evaluated now, not at the time the trap is
129146
trap "kill $PORT_FORWARD_PID" EXIT
130147
sleep 5
131148

docs/modules/druid/examples/getting_started/getting_started.sh.j2

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
# DO NOT EDIT THE SCRIPT
5+
# Instead, update the j2 template, and regenerate it for dev:
6+
# cat <<EOF | jinja2 --format yaml getting_started.sh.j2 -o getting_started.sh
7+
# helm:
8+
# repo_name: stackable-dev
9+
# repo_url: https://repo.stackable.tech/repository/helm-dev/
10+
# versions:
11+
# commons: 0.0.0-dev
12+
# druid: 0.0.0-dev
13+
# hdfs: 0.0.0-dev
14+
# listener: 0.0.0-dev
15+
# secret: 0.0.0-dev
16+
# zk: 0.0.0-dev
17+
# EOF
18+
419
# The getting started guide script
520
# It uses tagged regions which are included in the documentation
621
# https://docs.asciidoctor.org/asciidoc/latest/directives/include-tagged-regions/
@@ -122,10 +137,12 @@ kubectl rollout status --watch statefulset/simple-druid-router-default --timeout
122137
# end::watch-druid-rollout[]
123138

124139
echo "Starting port-forwarding of port 8888"
140+
# shellcheck disable=2069 # we want all output to be blackholed
125141
# tag::port-forwarding[]
126142
kubectl port-forward svc/simple-druid-router 8888 > /dev/null 2>&1 &
127143
# end::port-forwarding[]
128144
PORT_FORWARD_PID=$!
145+
# shellcheck disable=2064 # we want the PID evaluated now, not at the time the trap is
129146
trap "kill $PORT_FORWARD_PID" EXIT
130147
sleep 5
131148

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Installed commons=0.0.0-dev operator
2+
Installed secret=0.0.0-dev operator
3+
Installed listener=0.0.0-dev operator
4+
Installed zookeeper=0.0.0-dev operator
5+
Installed hdfs=0.0.0-dev operator
6+
Installed druid=0.0.0-dev operator
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Installed commons={{ versions.commons }} operator
2+
Installed secret={{ versions.secret }} operator
3+
Installed listener={{ versions.listener }} operator
4+
Installed zookeeper={{ versions.zookeeper }} operator
5+
Installed hdfs={{ versions.hdfs }} operator
6+
Installed druid={{ versions.druid }} operator

docs/modules/druid/pages/getting_started/installation.adoc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,8 @@ include::example$getting_started/getting_started.sh[tag=stackablectl-install-ope
2525

2626
The tool will show
2727

28-
----
29-
Installed commons operator
30-
Installed secret operator
31-
Installed listener operator
32-
Installed zookeeper operator
33-
Installed hdfs operator
34-
Installed druid operator
35-
----
28+
[source]
29+
include::example$getting_started/install_output.txt[]
3630

3731
TIP: Consult the xref:management:stackablectl:quickstart.adoc[] to learn more about how to use `stackablectl`.
3832

rust/operator-binary/src/druid_controller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ mod test {
14201420
druid_segment_cache_property = rg_configmap
14211421
.data
14221422
.unwrap()
1423-
.get(&RUNTIME_PROPS.to_string())
1423+
.get(RUNTIME_PROPS)
14241424
.unwrap()
14251425
.to_string();
14261426

tests/templates/kuttl/authorizer/authcheck.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,28 @@ def create_user(user_name):
1313
auth=("admin", "password1"),
1414
verify=False,
1515
)
16-
data = f"{{\"password\": \"{user_name}\"}}"
16+
data = f'{{"password": "{user_name}"}}'
1717
headers = {
18-
'Content-Type': 'application/json',
18+
"Content-Type": "application/json",
1919
}
2020
requests.post(
2121
f"https://{coordinator_host}:{coordinator_port}/druid-ext/basic-security/authentication/db/{authenticator_name}/users/{user_name}/credentials",
2222
headers=headers,
2323
data=data,
24-
auth=('admin', 'password1'),
24+
auth=("admin", "password1"),
2525
verify=False,
2626
)
2727

2828

2929
if __name__ == "__main__":
3030
result = 0
3131

32-
log_level = 'DEBUG'
33-
logging.basicConfig(level=log_level, format='%(asctime)s %(levelname)s: %(message)s', stream=sys.stdout)
32+
log_level = "DEBUG"
33+
logging.basicConfig(
34+
level=log_level,
35+
format="%(asctime)s %(levelname)s: %(message)s",
36+
stream=sys.stdout,
37+
)
3438

3539
print("CREATING USERS")
3640
create_user("alice")

tests/templates/kuttl/commons/healthcheck.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
if __name__ == "__main__":
77
result = 0
88

9-
log_level = 'DEBUG' # if args.debug else 'INFO'
10-
logging.basicConfig(level=log_level, format='%(asctime)s %(levelname)s: %(message)s', stream=sys.stdout)
9+
log_level = "DEBUG" # if args.debug else 'INFO'
10+
logging.basicConfig(
11+
level=log_level,
12+
format="%(asctime)s %(levelname)s: %(message)s",
13+
stream=sys.stdout,
14+
)
1115

1216
druid_cluster_name = sys.argv[1]
1317

@@ -42,7 +46,9 @@
4246
if res.status_code == 200 and res.text.lower() == "true":
4347
break
4448
else:
45-
print(f"Got non 200 status code [{res.status_code}] or non-true response [{res.text.lower()}], retrying attempt no [{count}] ....")
49+
print(
50+
f"Got non 200 status code [{res.status_code}] or non-true response [{res.text.lower()}], retrying attempt no [{count}] ...."
51+
)
4652
except requests.exceptions.Timeout:
4753
print(f"Connection timed out, retrying attempt no [{count}] ....")
4854
except requests.ConnectionError as e:

tests/templates/kuttl/commons/ingestioncheck-tls.py

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
class DruidClient:
1313
def __init__(self, cert, verify):
1414
self.session = requests.Session()
15-
self.session.headers.update({'Accept': 'application/json', 'Content-Type': 'application/json'})
16-
if os.environ['DRUID_OIDC'] == 'true':
17-
if os.environ['DRUID_USER'] == '' or os.environ['DRUID_PASSWORD'] == '':
18-
sys.exit("Need to provide basic auth user and password when OIDC is enabled.")
19-
self.session.auth = HTTPBasicAuth(os.environ['DRUID_USER'], os.environ['DRUID_PASSWORD'])
15+
self.session.headers.update(
16+
{"Accept": "application/json", "Content-Type": "application/json"}
17+
)
18+
if os.environ["DRUID_OIDC"] == "true":
19+
if os.environ["DRUID_USER"] == "" or os.environ["DRUID_PASSWORD"] == "":
20+
sys.exit(
21+
"Need to provide basic auth user and password when OIDC is enabled."
22+
)
23+
self.session.auth = HTTPBasicAuth(
24+
os.environ["DRUID_USER"], os.environ["DRUID_PASSWORD"]
25+
)
2026
self.session.cert = cert
2127
self.session.verify = verify
2228

@@ -33,7 +39,7 @@ def get_tasks(self, url):
3339
return response.text
3440

3541
def post_task(self, url, input):
36-
response = self.session.post(url, data=open(input, 'rb'))
42+
response = self.session.post(url, data=open(input, "rb"))
3743
assert response.status_code == 200
3844
return response.text
3945

@@ -77,44 +83,46 @@ def query_datasource(self, url, sql, expected, iterations):
7783
cert = ("/tmp/druid-tls/tls.crt", "/tmp/druid-tls/tls.key")
7884
verify = "/tmp/druid-tls/ca.crt"
7985
else:
80-
sys.exit("Usage: python ./ingestioncheck.py <namespace> <cluster_name> <no-tls|internal-and-server-tls|internal-and-server-tls-and-tls-client-auth>")
86+
sys.exit(
87+
"Usage: python ./ingestioncheck.py <namespace> <cluster_name> <no-tls|internal-and-server-tls|internal-and-server-tls-and-tls-client-auth>"
88+
)
8189

8290

8391
druid = DruidClient(cert, verify)
8492

85-
print('''
93+
print("""
8694
Query tasks
87-
===========''')
95+
===========""")
8896
tasks = druid.get_tasks(
8997
url=f"{protocol}://{druid_cluster_name}-coordinator-default-0.{druid_cluster_name}-coordinator-default.{namespace}.svc.cluster.local:{coordinator_port}/druid/indexer/v1/tasks",
9098
)
9199
task_count = len(json.loads(tasks))
92-
print(f'existing tasks: {task_count}')
100+
print(f"existing tasks: {task_count}")
93101

94-
print('''
102+
print("""
95103
Start ingestion task
96-
====================''')
104+
====================""")
97105
ingestion = druid.post_task(
98106
url=f"{protocol}://{druid_cluster_name}-coordinator-default-0.{druid_cluster_name}-coordinator-default.{namespace}.svc.cluster.local:{coordinator_port}/druid/indexer/v1/task",
99-
input='/tmp/druid-quickstartimport.json'
107+
input="/tmp/druid-quickstartimport.json",
100108
)
101109
task_id = json.loads(ingestion)["task"]
102-
url_encoded_taskid = urllib.parse.quote(task_id, safe='')
110+
url_encoded_taskid = urllib.parse.quote(task_id, safe="")
103111
print(f"TASKID: [{task_id}]")
104-
print('''
112+
print("""
105113
Re-query tasks
106-
==============''')
114+
==============""")
107115
tasks = druid.get_tasks(
108116
url=f"{protocol}://{druid_cluster_name}-coordinator-default-0.{druid_cluster_name}-coordinator-default.{namespace}.svc.cluster.local:{coordinator_port}/druid/indexer/v1/tasks",
109117
)
110118
new_task_count = len(json.loads(tasks))
111-
print(f'new tasks: {new_task_count}')
112-
print(f'assert {new_task_count} == {task_count+1}')
119+
print(f"new tasks: {new_task_count}")
120+
print(f"assert {new_task_count} == {task_count+1}")
113121
assert new_task_count == task_count + 1
114122

115-
print('''
123+
print("""
116124
Wait for ingestion task to succeed
117-
======================================''')
125+
======================================""")
118126
job_finished = False
119127
while not job_finished:
120128
time.sleep(5)
@@ -123,29 +131,33 @@ def query_datasource(self, url, sql, expected, iterations):
123131
)
124132
task_status = json.loads(task)["status"]["statusCode"]
125133
print(f"Current task status: [{task_status}]")
126-
assert task_status == "RUNNING" or task_status == "SUCCESS", f"Taskstatus not running or succeeeded: {task_status}"
134+
assert (
135+
task_status == "RUNNING" or task_status == "SUCCESS"
136+
), f"Taskstatus not running or succeeeded: {task_status}"
127137
job_finished = task_status == "SUCCESS"
128138

129-
print('''
139+
print("""
130140
Wait for broker to indicate all segments are fully online
131-
======================================''')
141+
======================================""")
132142
broker_ready = False
133143
while not broker_ready:
134144
time.sleep(2)
135-
broker_ready_rc = druid.check_rc(f"{protocol}://{druid_cluster_name}-broker-default-0.{druid_cluster_name}-broker-default.{namespace}.svc.cluster.local:{broker_port}/druid/broker/v1/readiness")
145+
broker_ready_rc = druid.check_rc(
146+
f"{protocol}://{druid_cluster_name}-broker-default-0.{druid_cluster_name}-broker-default.{namespace}.svc.cluster.local:{broker_port}/druid/broker/v1/readiness"
147+
)
136148
broker_ready = broker_ready_rc == 200
137149
print(f"Broker respondend with [{broker_ready_rc}] to readiness check")
138150

139-
print('''
151+
print("""
140152
Datasource SQL
141-
==============''')
153+
==============""")
142154
sample_data_size = 39244
143155
result = druid.query_datasource(
144156
url=f"{protocol}://{druid_cluster_name}-broker-default-0.{druid_cluster_name}-broker-default.{namespace}.svc.cluster.local:{broker_port}/druid/v2/sql",
145-
sql={"query": "select count(*) as c from \"wikipedia-2015-09-12\""},
157+
sql={"query": 'select count(*) as c from "wikipedia-2015-09-12"'},
146158
expected=sample_data_size,
147-
iterations=12
159+
iterations=12,
148160
)
149-
print(f'results: {result}')
150-
print(f'assert {sample_data_size} == {result}')
161+
print(f"results: {result}")
162+
print(f"assert {sample_data_size} == {result}")
151163
assert sample_data_size == result

0 commit comments

Comments
 (0)