Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce373c2

Browse files
committed
fix: adding exec_entrypoint script
1 parent04919f5 commitce373c2

File tree

3 files changed

+38
-26
lines changed

3 files changed

+38
-26
lines changed

‎entrypoint_init_container.sh‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,27 @@ optimus job run-input "$JOB_NAME" --project-name \
2222
"$PROJECT" --output-dir"$JOB_DIR" \
2323
--type"$INSTANCE_TYPE" --name"$INSTANCE_NAME" \
2424
--scheduled-at"$SCHEDULED_AT" --host"$OPTIMUS_HOST"
25+
26+
touch$JOB_DIR/exec_entrypoint.sh
27+
chmod 755$JOB_DIR/exec_entrypoint.sh
28+
29+
cat>$JOB_DIR/exec_entrypoint.sh<<EOF
30+
#!/bin/bash
31+
echo "exec entrypoint -------"
32+
# TODO: this doesnt support using back quote sign in env vars, fix it
33+
echo "-- exporting env"
34+
set -o allexport
35+
source "$JOB_DIR/in/.env"
36+
set +o allexport
37+
38+
echo "-- current envs"
39+
cat "$JOB_DIR/in/.env"
40+
41+
echo "-- exporting env with secret"
42+
set -o allexport
43+
source "$JOB_DIR/in/.secret"
44+
set +o allexport
45+
46+
echo "-- running unit"
47+
exec$(evalecho"$@")
48+
EOF

‎ext/scheduler/airflow/dag/dag.py.tmpl‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,7 @@ JOB_DIR = "/data"
101101
IMAGE_PULL_POLICY = "IfNotPresent"
102102
INIT_CONTAINER_IMAGE = "odpf/optimus:{{.Version}}"
103103
INIT_CONTAINER_ENTRYPOINT = "/opt/entrypoint_init_container.sh"
104-
105-
def get_entrypoint_cmd(plugin_entrypoint):
106-
path_config = JOB_DIR + "/in/.env"
107-
path_secret = JOB_DIR + "/in/.secret"
108-
entrypoint = "set -o allexport; source {path_config}; set +o allexport; cat {path_config}; ".format(path_config=path_config)
109-
entrypoint += "set -o allexport; source {path_secret}; set +o allexport; ".format(path_secret=path_secret)
110-
return entrypoint + plugin_entrypoint
104+
EXEC_CONTAINER_ENTRYPOINT = JOB_DIR + "/exec_entrypoint.sh"
111105

112106
volume = k8s.V1Volume(
113107
name='asset-volume',
@@ -150,8 +144,8 @@ init_container = k8s.V1Container(
150144
image_pull_policy=IMAGE_PULL_POLICY,
151145
namespace=conf.get('kubernetes', 'namespace', fallback="default"),
152146
image={{ .Task.Image | quote}},
153-
cmds=["/bin/sh"],
154-
arguments=["-c", get_entrypoint_cmd("""{{.Task.Entrypoint}} """)],
147+
cmds=[EXEC_CONTAINER_ENTRYPOINT],
148+
arguments=["""{{.Task.Entrypoint}} """], # space inside the quote is required
155149
name="{{ .Task.Name | replace "_" "-" }}",
156150
task_id={{ .Task.Name | quote}},
157151
get_logs=True,
@@ -193,8 +187,8 @@ hook_{{$hookName}} = SuperKubernetesPodOperator(
193187
image_pull_policy=IMAGE_PULL_POLICY,
194188
namespace=conf.get('kubernetes', 'namespace', fallback="default"),
195189
image="{{ $t.Image }}",
196-
cmds=["/bin/sh"],
197-
arguments=["-c", get_entrypoint_cmd("""{{ $t.Entrypoint }} """)],
190+
cmds=[EXEC_CONTAINER_ENTRYPOINT],
191+
arguments=["""{{ $t.Entrypoint }} """], # space inside the quote is required
198192
name="hook_{{ $t.Name | replace "_" "-" }}",
199193
task_id="hook_{{ $t.Name }}",
200194
get_logs=True,

‎ext/scheduler/airflow/dag/expected_dag.py‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@
7171
IMAGE_PULL_POLICY="IfNotPresent"
7272
INIT_CONTAINER_IMAGE="odpf/optimus:dev"
7373
INIT_CONTAINER_ENTRYPOINT="/opt/entrypoint_init_container.sh"
74-
75-
defget_entrypoint_cmd(plugin_entrypoint):
76-
path_config=JOB_DIR+"/in/.env"
77-
path_secret=JOB_DIR+"/in/.secret"
78-
entrypoint="set -o allexport; source {path_config}; set +o allexport; cat {path_config}; ".format(path_config=path_config)
79-
entrypoint+="set -o allexport; source {path_secret}; set +o allexport; ".format(path_secret=path_secret)
80-
returnentrypoint+plugin_entrypoint
74+
EXEC_CONTAINER_ENTRYPOINT=JOB_DIR+"/exec_entrypoint.sh"
8175

8276
volume=k8s.V1Volume(
8377
name='asset-volume',
@@ -119,8 +113,8 @@ def get_entrypoint_cmd(plugin_entrypoint):
119113
image_pull_policy=IMAGE_PULL_POLICY,
120114
namespace=conf.get('kubernetes','namespace',fallback="default"),
121115
image="example.io/namespace/bq2bq-executor:latest",
122-
cmds=["/bin/sh"],
123-
arguments=["-c",get_entrypoint_cmd("""python3 /opt/bumblebee/main.py """)],
116+
cmds=[EXEC_CONTAINER_ENTRYPOINT],
117+
arguments=["""python3 /opt/bumblebee/main.py """],# space inside the quote is required
124118
name="bq-bq",
125119
task_id="bq-bq",
126120
get_logs=True,
@@ -156,8 +150,8 @@ def get_entrypoint_cmd(plugin_entrypoint):
156150
image_pull_policy=IMAGE_PULL_POLICY,
157151
namespace=conf.get('kubernetes','namespace',fallback="default"),
158152
image="example.io/namespace/transporter-executor:latest",
159-
cmds=["/bin/sh"],
160-
arguments=["-c",get_entrypoint_cmd("""java -cp /opt/transporter/transporter.jar:/opt/transporter/jolokia-jvm-agent.jar -javaagent:jolokia-jvm-agent.jar=port=7777,host=0.0.0.0 com.gojek.transporter.Main """)],
153+
cmds=[EXEC_CONTAINER_ENTRYPOINT],
154+
arguments=["""java -cp /opt/transporter/transporter.jar:/opt/transporter/jolokia-jvm-agent.jar -javaagent:jolokia-jvm-agent.jar=port=7777,host=0.0.0.0 com.gojek.transporter.Main """],# space inside the quote is required
161155
name="hook_transporter",
162156
task_id="hook_transporter",
163157
get_logs=True,
@@ -189,8 +183,8 @@ def get_entrypoint_cmd(plugin_entrypoint):
189183
image_pull_policy=IMAGE_PULL_POLICY,
190184
namespace=conf.get('kubernetes','namespace',fallback="default"),
191185
image="example.io/namespace/predator-image:latest",
192-
cmds=["/bin/sh"],
193-
arguments=["-c",get_entrypoint_cmd("""predator ${SUB_COMMAND} -s ${PREDATOR_URL} -u "${BQ_PROJECT}.${BQ_DATASET}.${BQ_TABLE}" """)],
186+
cmds=[EXEC_CONTAINER_ENTRYPOINT],
187+
arguments=["""predator ${SUB_COMMAND} -s ${PREDATOR_URL} -u "${BQ_PROJECT}.${BQ_DATASET}.${BQ_TABLE}" """],# space inside the quote is required
194188
name="hook_predator",
195189
task_id="hook_predator",
196190
get_logs=True,
@@ -222,8 +216,8 @@ def get_entrypoint_cmd(plugin_entrypoint):
222216
image_pull_policy=IMAGE_PULL_POLICY,
223217
namespace=conf.get('kubernetes','namespace',fallback="default"),
224218
image="example.io/namespace/failure-hook-image:latest",
225-
cmds=["/bin/sh"],
226-
arguments=["-c",get_entrypoint_cmd("""sleep 5 """)],
219+
cmds=[EXEC_CONTAINER_ENTRYPOINT],
220+
arguments=["""sleep 5 """],# space inside the quote is required
227221
name="hook_failureHook",
228222
task_id="hook_failureHook",
229223
get_logs=True,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp