Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix wrong duration showed for image import #673

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 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.V(2).Infof("Image uploaded successfully, took %s", time.Since(start).Round(time.Second))
return true, nil
}
if *job.Status.State == jobStateFailed {
Expand Down Expand Up @@ -296,14 +296,13 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --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)
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 %s seconds to location %s", time.Since(startTime).Round(time.Second), result.Location)
return nil
}