-
Notifications
You must be signed in to change notification settings - Fork 40
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
Integrate a spinner to track time taken for long running operations #679 #680
Integrate a spinner to track time taken for long running operations #679 #680
Conversation
Welcome @priyanshikhetwani! It looks like this is your first PR to ppc64le-cloud/pvsadm 🎉 |
Hi @priyanshikhetwani. Thanks for your PR. I'm waiting for a ppc64le-cloud member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
81eba62
to
4e1a69c
Compare
4e1a69c
to
0dfbd9f
Compare
0dfbd9f
to
a0cdf44
Compare
/ok-to-test |
Fixes: #679 |
@priyanshikhetwani, I see there are merge conflicts, can you PTAL? |
1e9493e
to
6573309
Compare
/lgtm |
pkg/utils/utils.go
Outdated
@@ -56,17 +58,38 @@ func RetrieveValFromMap[K comparable, V any](m map[K]V, key K) V { | |||
// PollUntil validates if a certain condition is met at defined poll intervals. | |||
// If a timeout is reached, an associated error is returned to the caller. | |||
// condition contains the use-case specific code that returns true when a certain condition is achieved. | |||
func PollUntil(pollInterval, timeOut <-chan time.Time, condition func() (bool, error)) error { | |||
func PollUntil(pollInterval, timeOut <-chan time.Time, condition func() (string, bool, error)) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have different function which uses spinner and leave this default one as is? may be like SpinnerPollUntil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, makes sense since we are changing the function's signature
pkg/utils/utils.go
Outdated
timeoutMessage := " timed out while waiting for job to complete" | ||
s.Suffix = timeoutMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timeoutMessage := " timed out while waiting for job to complete" | |
s.Suffix = timeoutMessage | |
s.Suffix = " timed out while waiting for job to complete" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cmd/image/import/import.go
Outdated
@@ -262,20 +262,20 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-1003 | |||
return err | |||
} | |||
start := time.Now() | |||
err = utils.PollUntil(time.Tick(2*time.Minute), time.After(opt.WatchTimeout), func() (bool, error) { | |||
var message string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will making this variable available to the block below work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is accessed and modified outside the block as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, @kishen-v can you please check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure Manju, I'll take a look at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mkumatag, I see that it's reused here:
https://github.com/ppc64le-cloud/pvsadm/pull/680/files#diff-ae8fe9bef8e5a7ec3362a0d4dca4f3e432f4b1fe64e7c1dde9b23d98dbc8f937R308-R309
Or, we could switch to short-hand declaration in both cases. Just a thought..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we reusing it? are we sharing anything between those 2 blocks? if not - lets define locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added short-hand declaration, since we aren't sharing anything between the 2 blocks
6573309
to
6030be4
Compare
6030be4
to
b980053
Compare
go.mod
Outdated
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the additional newline
cc @kishen-v
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
cmd/image/import/import.go
Outdated
@@ -262,20 +262,20 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-1003 | |||
return err | |||
} | |||
start := time.Now() | |||
err = utils.PollUntil(time.Tick(2*time.Minute), time.After(opt.WatchTimeout), func() (bool, error) { | |||
var message string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, @kishen-v can you please check
11f51eb
to
282360f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mkumatag, priyanshikhetwani The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
**Summary: ** Integrate a spinner to track time taken for long running operations. #679
What Happened: Multiple logs with the same message is printed on screen which is redundant by nature, a spinner can be used to achieve the objective.
What you expected to happen:
A single line of log to track the status.
**Test: **
Example Output During Polling: