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

How to access kbatch pod logs? #61

Closed
FlorisCalkoen opened this issue Mar 13, 2024 · 1 comment · Fixed by #81
Closed

How to access kbatch pod logs? #61

FlorisCalkoen opened this issue Mar 13, 2024 · 1 comment · Fixed by #81

Comments

@FlorisCalkoen
Copy link

FlorisCalkoen commented Mar 13, 2024

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

@minrk
Copy link
Contributor

minrk commented Sep 27, 2024

Trying to bring this project back up. I think #79 would have helped you find your problem by showing you the actual error, but kbatch pod logs must take a pod name (i.e. found with kbatch pod list) and add-coastline-distances-job-q6pbj is the name of the job (job pods will have two random bits on the end, e.g. job-q6pbj-abc123, while job names have just one). #81 adds kbatch job logs JOB_NAME so you can get the logs by job name without having to look up the pod for the job yourself.

@minrk minrk closed this as completed in #81 Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants