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

feat: Add cachedimage pulling progress status #402

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
13 changes: 4 additions & 9 deletions internal/controller/kuik/cachedimage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,12 @@
lastUpdateTime := time.Now()
lastWriteComplete := int64(0)
onUpdated := func(update v1.Update) {
needUpdate := false

Check failure on line 350 in internal/controller/kuik/cachedimage_controller.go

View workflow job for this annotation

GitHub Actions / Unit Testing (1.26)

needUpdate declared and not used

Check failure on line 350 in internal/controller/kuik/cachedimage_controller.go

View workflow job for this annotation

GitHub Actions / Unit Testing (1.27)

needUpdate declared and not used

Check failure on line 350 in internal/controller/kuik/cachedimage_controller.go

View workflow job for this annotation

GitHub Actions / Unit Testing (1.25)

needUpdate declared and not used

Check failure on line 350 in internal/controller/kuik/cachedimage_controller.go

View workflow job for this annotation

GitHub Actions / Unit Testing (1.24)

needUpdate declared and not used

Check failure on line 350 in internal/controller/kuik/cachedimage_controller.go

View workflow job for this annotation

GitHub Actions / Unit Testing (1.28)

needUpdate declared and not used
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, but now the code isn't compiling...

Error: internal/controller/kuik/cachedimage_controller.go:350:3: needUpdate declared and not used

if lastWriteComplete != update.Complete && update.Complete == update.Total {
// Update is needed whenever the writing complmetes.
needUpdate = true
}

isCompleted := lastWriteComplete != update.Complete && update.Complete == update.Total

if time.Since(lastUpdateTime).Seconds() >= 5 {
// Update is needed if last update is more than 5 seconds ago
needUpdate = true
}
if needUpdate {
if time.Since(lastUpdateTime).Seconds() >= 5 || isCompleted {
// Update is needed if last update is more than 5 seconds ago, or the current progress indicates the remote writing has just completed.
updateStatus(r.Client, cachedImage, desc, func(status *kuikv1alpha1.CachedImageStatus) {
cachedImage.Status.Progress.Total = update.Total
cachedImage.Status.Progress.Available = update.Complete
Expand Down
Loading