-
Notifications
You must be signed in to change notification settings - Fork 2
feat(backup): validate extra_volumes paths during database creation and update #44
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
Merged
tsivaprasad
merged 6 commits into
main
from
PLAT-94-validate-host-path-mount-with-pgedge-docker-image
Jun 9, 2025
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aef466e
Enabled volume validation during database creation and update to veri…
tsivaprasad 82ffe4e
Addressing review comments and improve volume validation handling
tsivaprasad 2391ce5
Addressing review comments
tsivaprasad 9e51304
Refactor code and addressing review comments
tsivaprasad 4edb849
Removing extra_volumes specific check
tsivaprasad 900c31a
Simplify workflow and activity code for better clarity
tsivaprasad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| kind: Added | ||
| body: Enabled volume validation during database creation and update to verify that specified extra_volumes paths exist and are accessible. | ||
| time: 2025-06-06T18:08:46.195576+05:30 |
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package activities | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
|
|
||
| "github.com/cschleiden/go-workflows/activity" | ||
| "github.com/cschleiden/go-workflows/workflow" | ||
| "github.com/google/uuid" | ||
| "github.com/pgEdge/control-plane/server/internal/database" | ||
| "github.com/samber/do" | ||
| ) | ||
|
|
||
| type ValidateVolumesInput struct { | ||
| DatabaseID uuid.UUID `json:"database_id"` | ||
| Spec *database.InstanceSpec `json:"spec"` | ||
| } | ||
|
|
||
| type ValidateVolumesOutput struct { | ||
| Valid bool `json:"valid"` | ||
| Errors []string `json:"errors,omitempty"` | ||
| } | ||
|
|
||
| func (a *Activities) ExecuteValidateVolumes( | ||
| ctx workflow.Context, | ||
| hostID uuid.UUID, | ||
| input *ValidateVolumesInput, | ||
| ) workflow.Future[*ValidateVolumesOutput] { | ||
| options := workflow.ActivityOptions{ | ||
| Queue: workflow.Queue(hostID.String()), | ||
| RetryOptions: workflow.RetryOptions{ | ||
| MaxAttempts: 1, | ||
| }, | ||
| } | ||
| return workflow.ExecuteActivity[*ValidateVolumesOutput](ctx, options, a.ValidateVolumes, input) | ||
| } | ||
|
|
||
| func (a *Activities) ValidateVolumes(ctx context.Context, input *ValidateVolumesInput) (*ValidateVolumesOutput, error) { | ||
| logger := activity.Logger(ctx) | ||
|
|
||
| fail := func(err error, msg string) (*ValidateVolumesOutput, error) { | ||
| logger.Error(msg, "error", err) | ||
| return &ValidateVolumesOutput{ | ||
| Valid: false, | ||
| Errors: []string{msg + ": " + err.Error()}, | ||
| }, err | ||
| } | ||
|
|
||
| if input == nil { | ||
| return fail(errors.New("input is nil"), "input cannot be nil") | ||
| } | ||
| if input.DatabaseID == uuid.Nil { | ||
| return fail(errors.New("invalid UUID"), "invalid database ID") | ||
| } | ||
|
|
||
| logger = logger.With("database_id", input.DatabaseID.String()) | ||
| logger.Info("starting volume validation") | ||
|
|
||
| if input.Spec == nil { | ||
| return fail(errors.New("spec is nil"), "spec is required for volume validation") | ||
| } | ||
|
|
||
| orch, err := do.Invoke[database.Orchestrator](a.Injector) | ||
| if err != nil { | ||
| return fail(err, "failed to resolve orchestrator") | ||
| } | ||
|
|
||
| result, err := orch.ValidateVolumes(ctx, input.Spec) | ||
| if err != nil { | ||
| return fail(err, "volume validation failed") | ||
| } | ||
|
|
||
| logger.Info("volume validation completed", "success", result.Success) | ||
| return &ValidateVolumesOutput{ | ||
| Valid: result.Success, | ||
| }, nil | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.