Skip to content

Commit

Permalink
Handle the case where the seconds value of the time is zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoleman0redhat0com committed Oct 11, 2024
1 parent ae07704 commit 51caeba
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,10 @@ public String getLogsFromPod(Pod pod, Instant sinceInstant, int sinceSeconds) {
if (sinceInstant == null && sinceSeconds == -1) {
return getKubernetesClient().pods().inNamespace(pod.getMetadata().getNamespace()).resource(pod).getLog();
} else if (sinceInstant != null) {
// TODO problem with time zones (UTC is not guaranteed)
// If seconds is zero, atOffset().toString() will truncate the string
// which the pod cannot parse, causing an error
if (sinceInstant.atOffset(ZoneOffset.UTC).getSecond() == 0)
sinceInstant = sinceInstant.minusSeconds(1);
return getKubernetesClient().pods().inNamespace(pod.getMetadata().getNamespace()).resource(pod)
.sinceTime(sinceInstant.atOffset(ZoneOffset.UTC).toString()).getLog();
} else {
Expand Down

0 comments on commit 51caeba

Please sign in to comment.