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

feat(provider/kubernetes): runJob logs #2164

Merged
merged 1 commit into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class KubernetesJobStatus implements JobStatus, Serializable {
Set<String> securityGroups
@JsonIgnore
Pod pod
String logs

KubernetesJobStatus(Pod pod, String account) {
this.name = pod.metadata.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,27 @@ class KubernetesJobProvider implements JobProvider<KubernetesJobStatus> {
return null
}
def trueCredentials = (credentials as KubernetesNamedAccountCredentials).credentials
def status = new KubernetesJobStatus(trueCredentials.apiAdaptor.getPod(location, id), account)
def pod = trueCredentials.apiAdaptor.getPod(location, id)
def status = new KubernetesJobStatus(pod, account)

String podName = pod.getMetadata().getName()
StringBuilder logs = new StringBuilder()

pod.getSpec().getContainers().collect { container->
logs.append("===== ${container.getName()} =====\n\n")
try {
logs.append(trueCredentials.apiAdaptor.getLog(location, podName, container.getName()))
} catch(Exception e) {
logs.append(e.getMessage())
}
logs.append("\n\n")
}
status.logs = logs.toString()

if (status.jobState in [JobState.Failed, JobState.Succeeded]) {
trueCredentials.apiAdaptor.deletePod(location, id)
}

return status
}

Expand Down