diff --git a/CHANGELOG.md b/CHANGELOG.md index 8745b4a..4329664 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased +- [Bugfix] Fix "Unexpected args" error during service initialization on Kubernetes (#611). + ## v13.1.6 (2022-03-15) - [Bugfix] Fix `local/k8s quickstart` commands when upgrading from an older release (#595). diff --git a/tutor/commands/k8s.py b/tutor/commands/k8s.py index 7adcad1..64c0146 100644 --- a/tutor/commands/k8s.py +++ b/tutor/commands/k8s.py @@ -113,6 +113,7 @@ class K8sJobRunner(jobs.BaseJobRunner): # We cannot use the k8s API to create the job: configMap and volume names need # to be found with the right suffixes. kubectl_apply( + self.root, "--selector", f"app.kubernetes.io/name={job_name}", ) @@ -232,27 +233,21 @@ def start(context: Context, names: List[str]) -> None: for name in names: if name == "all": # Create volumes - utils.kubectl( - "apply", - "--kustomize", - tutor_env.pathjoin(context.root), + kubectl_apply( + context.root, "--wait", "--selector", "app.kubernetes.io/component=volume", ) # Create everything else except jobs - utils.kubectl( - "apply", - "--kustomize", - tutor_env.pathjoin(context.root), + kubectl_apply( + context.root, "--selector", "app.kubernetes.io/component notin (job,volume,namespace)", ) else: - utils.kubectl( - "apply", - "--kustomize", - tutor_env.pathjoin(context.root), + kubectl_apply( + context.root, "--selector", f"app.kubernetes.io/name={name}", ) diff --git a/tutor/jobs.py b/tutor/jobs.py index c3bc3da..56624c8 100644 --- a/tutor/jobs.py +++ b/tutor/jobs.py @@ -56,24 +56,20 @@ def initialise(runner: BaseJobRunner, limit_to: Optional[str] = None) -> None: if limit_to is None or limit_to == plugin_name: for service in hook: fmt.echo_info( - "Plugin {}: running pre-init for service {}...".format( - plugin_name, service - ) + f"Plugin {plugin_name}: running pre-init for service {service}..." ) runner.run_job_from_template( service, plugin_name, "hooks", service, "pre-init" ) for service in ["lms", "cms"]: if limit_to is None or limit_to == service: - fmt.echo_info("Initialising {}...".format(service)) + fmt.echo_info(f"Initialising {service}...") runner.run_job_from_template(service, "hooks", service, "init") for plugin_name, hook in runner.iter_plugin_hooks("init"): if limit_to is None or limit_to == plugin_name: for service in hook: fmt.echo_info( - "Plugin {}: running init for service {}...".format( - plugin_name, service - ) + f"Plugin {plugin_name}: running init for service {service}..." ) runner.run_job_from_template( service, plugin_name, "hooks", service, "init" @@ -136,9 +132,7 @@ site.themes.create(theme_dir_name='{theme_name}') """.format( theme_name=theme_name, domain_name=domain_name ) - command = BASE_OPENEDX_COMMAND + './manage.py lms shell -c "{python_code}"'.format( - python_code=python_code - ) + command = BASE_OPENEDX_COMMAND + f'./manage.py lms shell -c "{python_code}"' runner.run_job("lms", command)