Skip to content

Commit

Permalink
pull shorter logs (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
xudifsd authored and hongzhili committed Nov 13, 2019
1 parent 799b2f8 commit 8225222
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ClusterManager/joblog_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def extract_job_log(jobId,logPath,userId):
try:
dataHandler = DataHandler()

logs = k8sUtils.GetLog(jobId)
logs = k8sUtils.GetLog(jobId, tail=3000)

# Do not overwrite existing logs with empty log
# DLTS bootstrap will generate logs for all containers.
Expand Down
7 changes: 5 additions & 2 deletions src/utils/k8sUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def GetPod(selector):
return podInfo


def GetLog(jobId):
def GetLog(jobId, tail=None):
# assume our job only one container per pod.

selector = "run=" + jobId
Expand All @@ -194,7 +194,10 @@ def GetLog(jobId):
if "status" in item and "containerStatuses" in item["status"] and "containerID" in item["status"]["containerStatuses"][0]:
containerID = item["status"]["containerStatuses"][0]["containerID"].replace("docker://", "")
log["containerID"] = containerID
log["containerLog"] = kubectl_exec(" logs " + log["podName"])
if tail is not None:
log["containerLog"] = kubectl_exec(" logs %s --tail=%s" % (log["podName"], str(tail)))
else:
log["containerLog"] = kubectl_exec(" logs " + log["podName"])
logs.append(log)
return logs

Expand Down

0 comments on commit 8225222

Please sign in to comment.