-
Notifications
You must be signed in to change notification settings - Fork 2
feat(images): add DVCR image presence monitoring #1622
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
Draft
loktev-d
wants to merge
7
commits into
main
Choose a base branch
from
feat/images/dvcr-image-presence-monitoring
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Daniil Loktev <[email protected]>
Contributor
Reviewer's GuideIntroduces a periodic DVCR image presence monitor for VirtualImage and ClusterVirtualImage using the existing GC framework and minimal API surface changes. Sequence diagram for periodic DVCR image presence monitoringsequenceDiagram
participant CronScheduler
participant ImageMonitorManager
participant DVCRRegistry
participant K8sAPI
CronScheduler->>ImageMonitorManager: Trigger ListForDelete()
ImageMonitorManager->>K8sAPI: List VirtualImage/ClusterVirtualImage
loop For each Ready image
ImageMonitorManager->>DVCRRegistry: CheckImageExists(registryURL)
alt Image exists
ImageMonitorManager-->>CronScheduler: No action
else Image missing
ImageMonitorManager->>K8sAPI: Update Status.Phase to ImageLost
ImageMonitorManager->>K8sAPI: Set Condition Reason=ImageLost
end
end
ER diagram for updated VirtualImage and ClusterVirtualImage status phaseserDiagram
VIRTUALIMAGE {
string id
ImagePhase phase
string progress
string registry_url
}
CLUSTERVIRTUALIMAGE {
string id
ImagePhase phase
string progress
string registry_url
}
IMAGEPHASE {
string name
}
VIRTUALIMAGE ||--o| IMAGEPHASE : "has phase"
CLUSTERVIRTUALIMAGE ||--o| IMAGEPHASE : "has phase"
IMAGEPHASE {
Pending
Provisioning
WaitForUserUpload
Ready
Failed
Terminating
ImageLost
PVCLost
}
Class diagram for DVCR image presence monitoringclassDiagram
class VirtualImage {
+Status: VirtualImageStatus
+Spec: VirtualImageSpec
}
class ClusterVirtualImage {
+Status: ClusterVirtualImageStatus
+Spec: ClusterVirtualImageSpec
}
class VirtualImageStatus {
+Phase: ImagePhase
+Progress: string
+Conditions: []Condition
+Target: TargetInfo
}
class ClusterVirtualImageStatus {
+Phase: ImagePhase
+Progress: string
+Conditions: []Condition
+Target: TargetInfo
}
class ImagePhase {
<<enum>>
Pending
Provisioning
WaitForUserUpload
Ready
Failed
Terminating
ImageLost
PVCLost
}
class ImageMonitorManager {
+client: Client
+dvcrSettings: DVCRSettings
+New()
+ShouldBeDeleted(obj)
+ListForDelete(ctx, now)
+checkImage(ctx, registryURL)
+markImageLost(ctx, obj, registryURL)
+getAuthCredentials(ctx)
}
class DVCRSettings {
+AuthSecret: string
+AuthSecretNamespace: string
+InsecureTLS: string
}
class ImageChecker {
<<interface>>
+CheckImageExists(ctx, imageURL)
}
class DefaultImageChecker {
+username: string
+password: string
+insecure: bool
+CheckImageExists(ctx, imageURL)
}
VirtualImageStatus --> ImagePhase
ClusterVirtualImageStatus --> ImagePhase
ImageMonitorManager --> DVCRSettings
ImageMonitorManager --> ImageChecker
DefaultImageChecker ..|> ImageChecker
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `images/virtualization-artifact/pkg/dvcr/checker.go:126-127` </location>
<code_context>
+ contains(errStr, "404")
+}
+
+// contains checks if a string contains a substring (case-insensitive helper).
+func contains(s, substr string) bool {
+ return len(s) >= len(substr) && (s == substr || containsHelper(s, substr))
+}
</code_context>
<issue_to_address>
**suggestion:** Use strings.Contains for substring checks instead of custom implementation.
Refactor the 'contains' and 'containsHelper' functions to use 'strings.Contains' for improved readability and reliability.
Suggested implementation:
```golang
import "strings"
// contains checks if a string contains a substring.
func contains(s, substr string) bool {
return strings.Contains(s, substr)
}
```
If there is a `containsHelper` function elsewhere in the file, it should be removed as it is no longer needed.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Signed-off-by: Daniil Loktev <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Why do we need it, and what problem does it solve?
What is the expected result?
Checklist
Changelog entries