Fix and tests for SelectorUpdatedBefore

This commit is contained in:
Michail Kargakis
2017-01-04 16:44:13 +01:00
parent df7a655d30
commit 5dc96b5238
4 changed files with 173 additions and 14 deletions

View File

@@ -1003,7 +1003,7 @@ func DeploymentDeepCopy(deployment *extensions.Deployment) (*extensions.Deployme
}
// SelectorUpdatedBefore returns true if the former deployment's selector
// is updated before the latter, false otherwise
// is updated before the latter, false otherwise.
func SelectorUpdatedBefore(d1, d2 *extensions.Deployment) bool {
t1, t2 := LastSelectorUpdate(d1), LastSelectorUpdate(d2)
return t1.Before(t2)
@@ -1013,7 +1013,7 @@ func SelectorUpdatedBefore(d1, d2 *extensions.Deployment) bool {
func LastSelectorUpdate(d *extensions.Deployment) metav1.Time {
t := d.Annotations[SelectorUpdateAnnotation]
if len(t) > 0 {
parsedTime, err := time.Parse(t, time.RFC3339)
parsedTime, err := time.Parse(time.RFC3339, t)
// If failed to parse the time, use creation timestamp instead
if err != nil {
return d.CreationTimestamp