Skip to content

Commit c51f0e3

Browse files
authored
Fix a bug where unixtime with nanosec could not be parsed (#8)
1 parent 4b48936 commit c51f0e3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

internal/testing/cluster_upgrade.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ kubectl label node "${K8S_CLUSTER_NAME}-worker" --kubeconfig=kubeconfig shredder
1212
# OSX uses BSD tools while Linux uses GNU tools. They are similar but not the same.
1313
if [[ "$(uname)" = Linux ]]
1414
then
15-
EXPIRES_ON=$(date -d '+1 minutes' +"%s")
15+
EXPIRES_ON=$(date -d '+1 minutes' +"%s".000)
1616
else
17-
EXPIRES_ON=$(date -v '+1M' -u +'%s')
17+
EXPIRES_ON=$(date -v '+1M' -u +'%s'.000)
1818
fi
1919

2020
kubectl label node "${K8S_CLUSTER_NAME}-worker" --kubeconfig=kubeconfig --overwrite shredder.ethos.adobe.net/parked-node-expires-on="${EXPIRES_ON}"

pkg/utils/k8s.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ func PodHasLabel(pod v1.Pod, key string) bool {
7676

7777
// GetParkedNodeExpiryTime get the time a parked node TTL expires
7878
func GetParkedNodeExpiryTime(node v1.Node, expiresOnLabel string) (time.Time, error) {
79-
i, err := strconv.ParseInt(node.Labels[expiresOnLabel], 10, 64)
79+
i, err := strconv.ParseFloat(node.Labels[expiresOnLabel], 64)
8080
if err != nil {
8181
return time.Now().UTC(), errors.Errorf("Failed to parse label %s with value %s", expiresOnLabel, node.Labels[expiresOnLabel])
8282
}
83-
return time.Unix(i, 0).UTC(), nil
83+
return time.Unix(int64(i), 0).UTC(), nil
8484
}

0 commit comments

Comments
 (0)