-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29269 from kannon92/fix-machine-phase-deletion
OCPBUGS-44244: use node node in deleted machine phases
- Loading branch information
Showing
8 changed files
with
464 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package utility | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"regexp" | ||
"time" | ||
) | ||
|
||
// SystemdJournalLogTime returns Now if there is trouble reading the time. This will stack the event intervals without | ||
// parsable times at the end of the run, which will be more clearly visible as a problem than not reporting them. | ||
func SystemdJournalLogTime(logLine string) time.Time { | ||
var kubeletTimeRegex = regexp.MustCompile(`^(?P<MONTH>\S+)\s(?P<DAY>\S+)\s(?P<TIME>\S+)`) | ||
kubeletTimeRegex.MatchString(logLine) | ||
if !kubeletTimeRegex.MatchString(logLine) { | ||
return time.Now() | ||
} | ||
|
||
month := "" | ||
day := "" | ||
year := fmt.Sprintf("%d", time.Now().Year()) | ||
timeOfDay := "" | ||
subMatches := kubeletTimeRegex.FindStringSubmatch(logLine) | ||
subNames := kubeletTimeRegex.SubexpNames() | ||
for i, name := range subNames { | ||
switch name { | ||
case "MONTH": | ||
month = subMatches[i] | ||
case "DAY": | ||
day = subMatches[i] | ||
case "TIME": | ||
timeOfDay = subMatches[i] | ||
} | ||
} | ||
|
||
timeString := fmt.Sprintf("%s %s %s %s UTC", day, month, year, timeOfDay) | ||
ret, err := time.Parse("02 Jan 2006 15:04:05.999999999 MST", timeString) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Failure parsing time format: %v for %q\n", err, timeString) | ||
return time.Now() | ||
} | ||
|
||
return ret | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.