feat(vd): validate sc for vi(pvc) from vd and vd from vi(pvc)#1563
Draft
feat(vd): validate sc for vi(pvc) from vd and vd from vi(pvc)#1563
Conversation
Contributor
Reviewer's GuideThis PR introduces a StorageClassMatchValidator for both VirtualDisk and VirtualImage webhooks, adding logic to fetch the default storage class and ensure that PVC-based resources created via object references share matching storage classes, and it integrates this validator into the respective webhook controllers. Sequence diagram for storage class validation when creating VirtualDisk from VirtualImagesequenceDiagram
participant VDWebhook
participant StorageClassMatchValidator
participant K8sClient
participant VirtualImage
VDWebhook->>StorageClassMatchValidator: ValidateCreate(ctx, vd)
StorageClassMatchValidator->>K8sClient: Fetch VirtualImage by ObjectRef
K8sClient-->>StorageClassMatchValidator: VirtualImage object
StorageClassMatchValidator->>StorageClassMatchValidator: Compare storage classes (VD vs VI)
StorageClassMatchValidator-->>VDWebhook: Return error if mismatch
Class diagram for StorageClassMatchValidator and integration with webhook validatorsclassDiagram
class StorageClassMatchValidator {
+client: Client
+scService: VirtualDiskStorageClassService | VirtualImageStorageClassService
+ValidateCreate(ctx, obj): (Warnings, error)
+ValidateUpdate(ctx, oldObj, newObj): (Warnings, error)
+Validate(ctx, obj): (Warnings, error)
}
class VirtualDiskValidator {
+validators: []Validator
}
class VirtualImageValidator {
+logger: Logger
+client: Client
+scService: VirtualImageStorageClassService
+storageClassMatchValidator: StorageClassMatchValidator
}
StorageClassMatchValidator <|-- VirtualDiskValidator : used by
StorageClassMatchValidator <|-- VirtualImageValidator : used by
VirtualDiskValidator o-- StorageClassMatchValidator
VirtualImageValidator o-- StorageClassMatchValidator
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
178252d to
1d83ca0
Compare
Contributor
|
Workflow has started. |
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
Contributor
|
Workflow has started. The target step completed with status: failure. |
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
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