Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable multi-container pod runner #304

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions acto/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
break
else:
raise Exception("No operator yaml found in deploy config")

# Extract the operator_container_name from config
self._operator_container_name = None
for step in self._deploy_config.steps:
if step.apply and step.apply.operator:
self._operator_container_name = step.apply.operator_container_name
break

Check warning on line 62 in acto/deploy.py

View workflow job for this annotation

GitHub Actions / coverage-report

Missing coverage

Missing coverage on lines 58-62

@property
def operator_yaml(self) -> str:
Expand Down Expand Up @@ -136,3 +143,7 @@
if yaml_["kind"] == "Deployment":
return yaml_["metadata"]["name"]
return None

@property
def operator_container_name(self) -> str:
return self._operator_container_name

Check warning on line 149 in acto/deploy.py

View workflow job for this annotation

GitHub Actions / coverage-report

Missing coverage

Missing coverage on line 149
5 changes: 3 additions & 2 deletions acto/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def run_trial(
self.kubeconfig,
self.context_name,
wait_time=self.wait_time,
operator_container_name=self.deploy.operator_container_name
)
checker: CheckerSet = self.checker_t(
self.context,
Expand Down Expand Up @@ -1070,7 +1071,7 @@ def __learn(self, context_file, helper_crd, analysis_only=False):
break
apiclient = kubernetes_client(learn_kubeconfig, learn_context_name)
runner = Runner(
self.context, "learn", learn_kubeconfig, learn_context_name
self.context, "learn", learn_kubeconfig, learn_context_name, self.deploy.operator_container_name
)
runner.run_without_collect(
self.operator_config.seed_custom_resource
Expand Down Expand Up @@ -1183,7 +1184,7 @@ def run(
self.is_reproduce,
self.apply_testcase_f,
self.acto_namespace,
self.operator_config.diff_ignore_fields,
self.operator_config.diff_ignore_fields
)
runners.append(runner)

Expand Down
3 changes: 3 additions & 0 deletions acto/lib/operator_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class ApplyStep(BaseModel, extra="forbid"):
operator: bool = Field(
description="If the file contains the operator deployment",
default=False)
operator_container_name: Optional[str] = Field(
description="The container name of the operator in the operator pod",
default=None)
namespace: Optional[str] = Field(
description="Namespace for applying the file. If not specified, " +
"use the namespace in the file or Acto namespace. " +
Expand Down
6 changes: 3 additions & 3 deletions acto/post_process/post_diff_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
add_acto_label(apiclient, self._context['namespace'])
trial_dir = os.path.join(self._workdir, 'trial-%02d' % self._worker_id)
os.makedirs(trial_dir, exist_ok=True)
runner = Runner(self._context, trial_dir, self._kubeconfig, self._context_name)
runner = Runner(self._context, trial_dir, self._kubeconfig, self._context_name, operator_container_name=self._deploy.operator_container_name)

Check warning on line 328 in acto/post_process/post_diff_test.py

View workflow job for this annotation

GitHub Actions / coverage-report

Missing coverage

Missing coverage on line 328
snapshot, err = runner.run(cr, generation=self._generation)
difftest_result = {
'input_digest': hashlib.md5(json.dumps(cr, sort_keys=True).encode("utf-8")).hexdigest(),
Expand Down Expand Up @@ -378,7 +378,7 @@

trial_dir = os.path.join(self._workdir, 'trial-%02d' % self._worker_id)
os.makedirs(trial_dir, exist_ok=True)
runner = Runner(self._context, trial_dir, self._kubeconfig, self._context_name)
runner = Runner(self._context, trial_dir, self._kubeconfig, self._context_name, operator_container_name=self._deploy.operator_container_name)

Check warning on line 381 in acto/post_process/post_diff_test.py

View workflow job for this annotation

GitHub Actions / coverage-report

Missing coverage

Missing coverage on line 381
while True:
after_k8s_bootstrap_time = time.time()
try:
Expand Down Expand Up @@ -418,7 +418,7 @@
kubectl_client=kubectl_client,
namespace=self._context['namespace'])
after_operator_deploy_time = time.time()
runner = Runner(self._context, trial_dir, self._kubeconfig, self._context_name)
runner = Runner(self._context, trial_dir, self._kubeconfig, self._context_name, operator_container_name=self._deploy.operator_container_name)

Check warning on line 421 in acto/post_process/post_diff_test.py

View workflow job for this annotation

GitHub Actions / coverage-report

Missing coverage

Missing coverage on line 421

generation += 1

Expand Down
17 changes: 13 additions & 4 deletions acto/runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
context_name: str,
custom_system_state_f: Optional[Callable[..., dict]] = None,
wait_time: int = 45,
operator_container_name: str = None
):
self.namespace = context["namespace"]
self.crd_metainfo: dict = context["crd"]
self.trial_dir = trial_dir
self.kubeconfig = kubeconfig
self.context_name = context_name
self.operator_container_name = operator_container_name

Check warning on line 46 in acto/runner/runner.py

View workflow job for this annotation

GitHub Actions / coverage-report

Missing coverage

Missing coverage on line 46
self.wait_time = wait_time
self.log_length = 0

Expand Down Expand Up @@ -311,10 +313,17 @@
)
else:
logger.error("Failed to find operator pod")

log = self.core_v1_api.read_namespaced_pod_log(
name=operator_pod_list[0].metadata.name, namespace=self.namespace
)
if self.operator_container_name != None:
log = self.core_v1_api.read_namespaced_pod_log(
name=operator_pod_list[0].metadata.name,
namespace=self.namespace,
container=self.operator_container_name
)
else:
log = self.core_v1_api.read_namespaced_pod_log(

Check warning on line 323 in acto/runner/runner.py

View workflow job for this annotation

GitHub Actions / coverage-report

Missing coverage

Missing coverage on lines 316-323
name=operator_pod_list[0].metadata.name,
namespace=self.namespace,
)

# only get the new log since previous result
new_log = log.split("\n")
Expand Down
21 changes: 21 additions & 0 deletions data/clickhouse-operator/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"deploy": {
"steps": [
{
"apply": {
"file": "data/clickhouse-operator/zookeeper.yaml",
"namespace": "zoo3ns"
}
},
{
"apply": {
"file": "data/clickhouse-operator/operator.yaml",
"operator_container_name": "clickhouse-operator",
"operator": true
}
}
]
},
"crd_name": "clickhouseinstallations.clickhouse.altinity.com",
"seed_custom_resource": "data/clickhouse-operator/cr.yaml"
}
Loading
Loading