Skip to content

Commit

Permalink
k8s: upgrade to pykube 0.14.0
Browse files Browse the repository at this point in the history
* Removes monkey patched `logs()` method.

Signed-off-by: Diego Rodriguez <[email protected]>
  • Loading branch information
Diego Rodriguez committed Jan 25, 2017
1 parent ca240c3 commit db37145
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
46 changes: 1 addition & 45 deletions reana_job_controller/k8s.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import time
import pykube
from six.moves.urllib.parse import urlencode
import volume_templates

api = pykube.HTTPClient(pykube.KubeConfig.from_service_account())
Expand Down Expand Up @@ -187,9 +186,7 @@ def watch_pods(job_db):
logging.info(
'Getting {} logs'.format(pod.name)
)
# Remove when Pykube 0.14.0 is released
pod.logs = logs
job_db[job_name]['log'] = pod.logs(pod)
job_db[job_name]['log'] = pod.logs()
logging.info(
'Cleaning Job {}'.format(job_name)
)
Expand All @@ -201,44 +198,3 @@ def watch_pods(job_db):
logging.debug(
'Event: {}\nObject:\n{}'.format(event.type, pod.obj)
)


# Remove this function when Pykube 0.14.0 is released
def logs(self, container=None, pretty=None, previous=False,
since_seconds=None, since_time=None, timestamps=False,
tail_lines=None, limit_bytes=None):
"""
Produces the same result as calling kubectl logs pod/<pod-name>.
Check parameters meaning at
http://kubernetes.io/docs/api-reference/v1/operations/,
part 'read log of the specified Pod'. The result is plain text.
"""
log_call = "log"
params = {}
if container is not None:
params["container"] = container
if pretty is not None:
params["pretty"] = pretty
if previous:
params["previous"] = "true"
if since_seconds is not None and since_time is None:
params["sinceSeconds"] = int(since_seconds)
elif since_time is not None and since_seconds is None:
params["sinceTime"] = since_time
if timestamps:
params["timestamps"] = "true"
if tail_lines is not None:
params["tailLines"] = int(tail_lines)
if limit_bytes is not None:
params["limitBytes"] = int(limit_bytes)

query_string = urlencode(params)
log_call += "?{}".format(query_string) if query_string else ""
kwargs = {
"version": self.version,
"namespace": self.namespace,
"operation": log_call,
}
r = self.api.get(**self.api_kwargs(**kwargs))
r.raise_for_status()
return r.text
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Flask==0.10.1
pykube==0.13.0
pykube==0.14.0

0 comments on commit db37145

Please sign in to comment.