Optimize code
This commit is contained in:
committed by
Ta-Ching Chen
parent
01bcfad44a
commit
b578819202
@@ -237,7 +237,7 @@ func TestExecutor(t *testing.T) {
|
||||
if err != nil {
|
||||
log.Panicf("failed to get func svc: %v", err)
|
||||
}
|
||||
log.Printf("svc for function created at: %v (in %v)", svc, time.Now().Sub(t1))
|
||||
log.Printf("svc for function created at: %v (in %v)", svc, time.Since(t1))
|
||||
|
||||
// ensure that a pod with the label functionName=f.Metadata.Name exists
|
||||
podCount := countPods(kubeClient, functionNs, map[string]string{"functionName": f.Metadata.Name})
|
||||
|
||||
@@ -100,7 +100,7 @@ func (fsc *FunctionServiceCache) service() {
|
||||
for _, funcSvc := range fscs {
|
||||
fsvc := funcSvc.(*FuncSvc)
|
||||
if fsvc.Environment.Metadata.UID == req.env.UID &&
|
||||
time.Now().Sub(fsvc.Atime) > req.age {
|
||||
time.Since(fsvc.Atime) > req.age {
|
||||
funcObjects = append(funcObjects, fsvc)
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,7 @@ func (fsc *FunctionServiceCache) _touchByAddress(address string) error {
|
||||
}
|
||||
|
||||
func (fsc *FunctionServiceCache) DeleteOld(fsvc *FuncSvc, minAge time.Duration) (bool, error) {
|
||||
if time.Now().Sub(fsvc.Atime) < minAge {
|
||||
if time.Since(fsvc.Atime) < minAge {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ func (gp *GenericPool) _choosePod(newLabels map[string]string) (*apiv1.Pod, erro
|
||||
startTime := time.Now()
|
||||
for {
|
||||
// Retries took too long, error out.
|
||||
if time.Now().Sub(startTime) > gp.podReadyTimeout {
|
||||
if time.Since(startTime) > gp.podReadyTimeout {
|
||||
log.Printf("[%v] Erroring out, timed out", newLabels)
|
||||
return nil, errors.New("timeout: waited too long to get a ready pod")
|
||||
}
|
||||
@@ -260,7 +260,7 @@ func (gp *GenericPool) _choosePod(newLabels map[string]string) (*apiv1.Pod, erro
|
||||
continue
|
||||
}
|
||||
}
|
||||
log.Printf("Chosen pod: %v (in %v)", chosenPod.ObjectMeta.Name, time.Now().Sub(startTime))
|
||||
log.Printf("Chosen pod: %v (in %v)", chosenPod.ObjectMeta.Name, time.Since(startTime))
|
||||
return chosenPod, nil
|
||||
}
|
||||
}
|
||||
@@ -510,7 +510,7 @@ func (gp *GenericPool) waitForReadyPod() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if time.Now().Sub(startTime) > gp.podReadyTimeout {
|
||||
if time.Since(startTime) > gp.podReadyTimeout {
|
||||
return errors.New("timeout: waited too long for pod to be ready")
|
||||
}
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
|
||||
Reference in New Issue
Block a user