Merge pull request #59727 from wgliang/master.time
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. should use time.Since instead of time.Now().Sub **What this PR does / why we need it**: should use time.Since instead of time.Now().Sub **Special notes for your reviewer**:
This commit is contained in:
@@ -1141,7 +1141,7 @@ func deleteNS(c clientset.Interface, dynamicClient dynamic.DynamicInterface, nam
|
||||
// no remaining content, but namespace was not deleted (namespace controller is probably wedged)
|
||||
return fmt.Errorf("namespace %v was not deleted with limit: %v, namespace is empty but is not yet removed", namespace, err)
|
||||
}
|
||||
Logf("namespace %v deletion completed in %s", namespace, time.Now().Sub(startTime))
|
||||
Logf("namespace %v deletion completed in %s", namespace, time.Since(startTime))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3053,13 +3053,13 @@ func DeleteResourceAndPods(clientset clientset.Interface, internalClientset inte
|
||||
if err := testutils.DeleteResourceUsingReaperWithRetries(internalClientset, kind, ns, name, nil, scaleClient); err != nil {
|
||||
return fmt.Errorf("error while stopping %v: %s: %v", kind, name, err)
|
||||
}
|
||||
deleteTime := time.Now().Sub(startTime)
|
||||
deleteTime := time.Since(startTime)
|
||||
Logf("Deleting %v %s took: %v", kind, name, deleteTime)
|
||||
err = waitForPodsInactive(ps, 100*time.Millisecond, 10*time.Minute)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error while waiting for pods to become inactive %s: %v", name, err)
|
||||
}
|
||||
terminatePodTime := time.Now().Sub(startTime) - deleteTime
|
||||
terminatePodTime := time.Since(startTime) - deleteTime
|
||||
Logf("Terminating %v %s pods took: %v", kind, name, terminatePodTime)
|
||||
// this is to relieve namespace controller's pressure when deleting the
|
||||
// namespace after a test.
|
||||
@@ -3067,7 +3067,7 @@ func DeleteResourceAndPods(clientset clientset.Interface, internalClientset inte
|
||||
if err != nil {
|
||||
return fmt.Errorf("error while waiting for pods gone %s: %v", name, err)
|
||||
}
|
||||
gcPodTime := time.Now().Sub(startTime) - terminatePodTime
|
||||
gcPodTime := time.Since(startTime) - terminatePodTime
|
||||
Logf("Garbage collecting %v %s pods took: %v", kind, name, gcPodTime)
|
||||
return nil
|
||||
}
|
||||
@@ -3105,7 +3105,7 @@ func DeleteResourceAndWaitForGC(c clientset.Interface, kind schema.GroupKind, ns
|
||||
if err := testutils.DeleteResourceWithRetries(c, kind, ns, name, deleteOption); err != nil {
|
||||
return err
|
||||
}
|
||||
deleteTime := time.Now().Sub(startTime)
|
||||
deleteTime := time.Since(startTime)
|
||||
Logf("Deleting %v %s took: %v", kind, name, deleteTime)
|
||||
|
||||
var interval, timeout time.Duration
|
||||
@@ -3129,7 +3129,7 @@ func DeleteResourceAndWaitForGC(c clientset.Interface, kind schema.GroupKind, ns
|
||||
if err != nil {
|
||||
return fmt.Errorf("error while waiting for pods to become inactive %s: %v", name, err)
|
||||
}
|
||||
terminatePodTime := time.Now().Sub(startTime) - deleteTime
|
||||
terminatePodTime := time.Since(startTime) - deleteTime
|
||||
Logf("Terminating %v %s pods took: %v", kind, name, terminatePodTime)
|
||||
|
||||
err = waitForPodsGone(ps, interval, 10*time.Minute)
|
||||
|
@@ -276,7 +276,7 @@ func runDensityTest(dtc DensityTestConfig, testPhaseDurations *timer.TestPhaseTi
|
||||
logStopCh := make(chan struct{})
|
||||
go logPodStartupStatus(dtc.ClientSets[0], dtc.PodCount, map[string]string{"type": "densityPod"}, dtc.PollInterval, logStopCh)
|
||||
wg.Wait()
|
||||
startupTime := time.Now().Sub(startTime)
|
||||
startupTime := time.Since(startTime)
|
||||
close(logStopCh)
|
||||
framework.Logf("E2E startup time for %d pods: %v", dtc.PodCount, startupTime)
|
||||
framework.Logf("Throughput (pods/s) during cluster saturation phase: %v", float32(dtc.PodCount)/float32(startupTime/time.Second))
|
||||
|
@@ -29,11 +29,11 @@ func main() {
|
||||
started := time.Now()
|
||||
http.HandleFunc("/started", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(200)
|
||||
data := (time.Now().Sub(started)).String()
|
||||
data := (time.Since(started)).String()
|
||||
w.Write([]byte(data))
|
||||
})
|
||||
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||
duration := time.Now().Sub(started)
|
||||
duration := time.Since(started)
|
||||
if duration.Seconds() > 10 {
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte(fmt.Sprintf("error: %v", duration.Seconds())))
|
||||
|
@@ -45,7 +45,7 @@ func main() {
|
||||
duration := time.Duration(*durationSec) * time.Second
|
||||
start := time.Now()
|
||||
first := systemstat.GetProcCPUSample()
|
||||
for time.Now().Sub(start) < duration {
|
||||
for time.Since(start) < duration {
|
||||
cpu := systemstat.GetProcCPUAverage(first, systemstat.GetProcCPUSample(), systemstat.GetUptime().Uptime)
|
||||
if cpu.TotalPct < millicoresPct {
|
||||
doSomething()
|
||||
|
Reference in New Issue
Block a user