Skip to content

Commit

Permalink
fix wrong duration showed for image import
Browse files Browse the repository at this point in the history
  • Loading branch information
arshadda authored and arshadda committed Sep 23, 2024
1 parent 94d368e commit e98e678
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/image/import/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --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.Infof("Image imported successfully, took %s", time.Since(start).Round(time.Second))
return true, nil
}
if *job.Status.State == jobStateFailed {
Expand Down Expand Up @@ -303,7 +303,7 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-1003
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 in %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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/image/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/s3client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 %f seconds to location %s", time.Since(startTime).Round(time.Second), result.Location)

Check failure on line 309 in pkg/client/s3client.go

View workflow job for this annotation

GitHub Actions / Build

k8s.io/klog/v2.Infof format %f has arg time.Since(startTime).Round(time.Second) of wrong type time.Duration
return nil
}

0 comments on commit e98e678

Please sign in to comment.