Skip to content

How to access kbatch pod logs?  #61

@FlorisCalkoen

Description

@FlorisCalkoen

I would like to access the logs of my (failed) jobs, but I think the docs are slightly outdated and/or I'm doing things wrong.

Attempt 1:

In the docs it's mentioned that you can get the logs by doing kbatch job logs CONTAINER_ID
"""
With kbatch job logs you can get the logs for a job. Make sure to pass the container id.
'''"

I don't think the current version has a logs argument for the job command. The command I see for job are delete, list, show and submit; see help message below:

kbatch job --help 
Usage: kbatch job [OPTIONS] COMMAND [ARGS]...

  Manage kbatch jobs.

Options:
  --help  Show this message and exit.

Commands:
  delete  Delete a job, cancelling running pods.
  list    List all the jobs.
  show    Show the details for a job.
  submit  Submit a job to run on Kubernetes.

Attempt 2

The pod command has a logs argumen; see help output below:

kbatch pod logs --help
Usage: kbatch pod logs [OPTIONS] POD_NAME

  Get the logs for a kbatch pod.

Options:
  --kbatch-url TEXT       URL to the kbatch server.
  --token TEXT            File to execute.
  --stream / --no-stream  Whether to stream the logs
  --read-timeout INTEGER  Timeout for reading data
  --pretty / --no-pretty
  --help                  Show this message and exit.

Now I can list my job names with kbatch job list -o table and then use the output to pick one of the job names "add-coastline-distances-job-q6pbj".

However, when I want to get the logs like this I get a http request error:

kbatch pod logs add-coastline-distances-job-q6pbj
[18:02:21] INFO     HTTP Request: GET https://pccompute.westeurope.cloudapp.azure.com/compute/services/kbatch/jobs/logs/add-coastline-distances-job-q6pbj/ "HTTP/1.1 500 Internal Server Error"      _client.py:1026
Traceback (most recent call last):
  File "/Users/calkoen/mambaforge/envs/jl-full/bin/kbatch", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/kbatch/cli.py", line 348, in logs
    result = _core.logs(pod_name, kbatch_url, token, read_timeout=read_timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/kbatch/_core.py", line 196, in logs
    result = next(gen)
             ^^^^^^^^^
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/kbatch/_core.py", line 233, in _logs
    r.raise_for_status()
  File "/Users/calkoen/mambaforge/envs/jl-full/lib/python3.11/site-packages/httpx/_models.py", line 761, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Server error '500 Internal Server Error' for url 'https://pccompute.westeurope.cloudapp.azure.com/compute/services/kbatch/jobs/logs/add-coastline-distances-job-q6pbj/'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions