Skip to content

Commit

Permalink
githubrunner: fix invalid characters in job id
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamilcuk committed Jul 15, 2024
1 parent edfcfb0 commit 743cfd9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/nomad_tools/entry_githubrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
import requests
import yaml

from nomad_tools import nomadlib
from . import nomadlib
from .nomadlib.connection import urlquote

from .common import mynomad
from .nomadlib.datadict import DataDict
Expand Down Expand Up @@ -665,7 +666,7 @@ def get_github_runner_state(self) -> Optional[GithubRunnerState]:
allocs = [
nomadlib.Alloc(x)
for x in mynomad.get(
f"job/{self.ID}/allocations",
f"job/{urlquote(self.ID)}/allocations",
params=dict(
namespace=CONFIG.nomad.namespace,
filter='ClientStats == "running"',
Expand Down Expand Up @@ -1169,6 +1170,18 @@ def purgeall():
mynomad.stop_job(x.ID, purge=True)


@cli.command(
help="""Purge all nomad containers associated with this runner confguration that are dead.
Use with care."""
)
def purgealldead():
for x in get_nomad_state():
if x.is_dead():
log.error(f"Purging {x.ID}")
if not ARGS.dryrun:
mynomad.stop_job(x.ID, purge=True)


@cli.command(help="Dump the configuration")
def dumpconfig():
print(yaml.safe_dump(CONFIG.asdict()))
Expand Down

0 comments on commit 743cfd9

Please sign in to comment.