mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-01-25 22:18:24 +00:00
Fix tls certificate generation in cron jobs
tls renewal and generation was failing in cron jobs because of "The input device is not a TTY" errors. This is because the "-it" docker option does not work when a tty is not available.
This commit is contained in:
parent
2d98356629
commit
e521333b75
@ -2,6 +2,10 @@
|
||||
|
||||
Note: Breaking changes between versions are indicated by "💥".
|
||||
|
||||
## Unreleased
|
||||
|
||||
- [Bugfix] Fix tls certificate generation in cron jobs
|
||||
|
||||
## v3.11.6 (2020-03-13)
|
||||
|
||||
- [Bugfix] Fix "Unable to resolve dependency" error during forum initialisation
|
||||
|
@ -3,6 +3,7 @@ import click
|
||||
from .. import config as tutor_config
|
||||
from .. import fmt
|
||||
from .. import scripts
|
||||
from .. import utils
|
||||
|
||||
|
||||
class ScriptRunner(scripts.BaseRunner):
|
||||
@ -90,7 +91,10 @@ def restart(context, services):
|
||||
@click.pass_obj
|
||||
def run(context, args):
|
||||
config = tutor_config.load(context.root)
|
||||
context.docker_compose(context.root, config, "run", "--rm", *args)
|
||||
command = ["run", "--rm"]
|
||||
if not utils.is_a_tty():
|
||||
command.append("-T")
|
||||
context.docker_compose(context.root, config, *command, *args)
|
||||
|
||||
|
||||
@click.command(
|
||||
|
@ -4,6 +4,7 @@ import random
|
||||
import shutil
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import click
|
||||
|
||||
@ -66,7 +67,10 @@ def walk_files(path):
|
||||
|
||||
|
||||
def docker_run(*command):
|
||||
return docker("run", "--rm", "-it", *command)
|
||||
args = ["run", "--rm"]
|
||||
if is_a_tty():
|
||||
args.append("-it")
|
||||
return docker(*args, *command)
|
||||
|
||||
|
||||
def docker(*command):
|
||||
@ -92,6 +96,12 @@ def kubectl(*command):
|
||||
)
|
||||
return execute("kubectl", *command)
|
||||
|
||||
def is_a_tty():
|
||||
"""
|
||||
Return True if stdin is able to allocate a tty. Tty allocation sometimes cannot be
|
||||
enabled, for instance in cron jobs
|
||||
"""
|
||||
return os.isatty(sys.stdin.fileno())
|
||||
|
||||
def execute(*command):
|
||||
click.echo(fmt.command(" ".join(command)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user