diff --git a/cmd/image/import/import.go b/cmd/image/import/import.go index 7d52052f..cf252c35 100644 --- a/cmd/image/import/import.go +++ b/cmd/image/import/import.go @@ -268,7 +268,7 @@ pvsadm image import -n upstream-core-lon04 -b --object rhel-83-1003 return false, fmt.Errorf("image import job failed to complete, err: %v", err) } if *job.Status.State == jobStateCompleted { - klog.Infof("Image imported successfully, took %s", time.Since(start)) + klog.V(2).Infof("Image uploaded successfully, took %s", time.Since(start).Round(time.Second)) return true, nil } if *job.Status.State == jobStateFailed { @@ -296,14 +296,13 @@ pvsadm image import -n upstream-core-lon04 -b --object rhel-83-1003 return nil } klog.Infof("Waiting for image %s to be active. Please wait...", opt.ImageName) - start = time.Now() return utils.PollUntil(time.Tick(10*time.Second), time.After(opt.WatchTimeout), func() (bool, error) { img, err := pvmclient.ImgClient.Get(*image.ImageID) if err != nil { return false, fmt.Errorf("failed to import the image, err: %v\n\nRun the command \"pvsadm get events -i %s\" to get more information about the failure", err, pvmclient.InstanceID) } if img.State == imageStateActive { - klog.Infof("Successfully imported the image: %s with ID: %s in %s", *image.Name, *image.ImageID, time.Since(start)) + klog.Infof("Successfully imported the image: %s with ID: %s Total time taken: %s", *image.Name, *image.ImageID, time.Since(start).Round(time.Second)) return true, nil } klog.Infof("Waiting for image to be active. Current state: %s", img.State) diff --git a/cmd/image/sync/sync.go b/cmd/image/sync/sync.go index 9b5a1b17..5169750c 100644 --- a/cmd/image/sync/sync.go +++ b/cmd/image/sync/sync.go @@ -56,7 +56,7 @@ func copyWorker(copyJobs <-chan copyWorkload, results chan<- bool, workerId int) klog.Errorf("copy object %s failed, err: %v", copyJob.srcObject, err) results <- false } - duration := time.Since(start) + duration := time.Since(start).Round(time.Second) klog.Infof("Copying object: %s from bucket: %s to bucket: %s took %v", copyJob.srcObject, copyJob.srcBucket, copyJob.tgtBucket, duration) results <- true } @@ -279,7 +279,7 @@ Sample spec.yaml file: } // Calculate total elapsed time - duration := time.Since(start) + duration := time.Since(start).Round(time.Second) klog.Infof("Total elapsed time: %v", duration) return nil }, diff --git a/pkg/client/s3client.go b/pkg/client/s3client.go index 955ba871..2f2213df 100644 --- a/pkg/client/s3client.go +++ b/pkg/client/s3client.go @@ -306,6 +306,6 @@ func (c *S3Client) UploadObject(fileName, objectName, bucketName string) error { return err } fmt.Println() - klog.Infof("Upload completed successfully in %f seconds to location %s", time.Since(startTime).Seconds(), result.Location) + klog.Infof("Upload completed successfully in %s seconds to location %s", time.Since(startTime).Round(time.Second), result.Location) return nil }