-
Notifications
You must be signed in to change notification settings - Fork 58
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
Volumes in recipes should be used to override LabelSelector and ignored for velero backups #1739
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,44 +79,35 @@ func GetPVCSelector(ctx context.Context, reader client.Reader, vrg ramen.VolumeR | |
ramenConfig ramen.RamenConfig, | ||
log logr.Logger, | ||
) (PvcSelector, error) { | ||
var recipeElements RecipeElements | ||
recipeElements, err := RecipeElementsGet(ctx, reader, vrg, ramenConfig, log) | ||
if err != nil { | ||
return recipeElements.PvcSelector, err | ||
} | ||
|
||
return recipeElements.PvcSelector, recipeVolumesAndOptionallyWorkflowsGet( | ||
ctx, reader, vrg, ramenConfig, log, &recipeElements, | ||
func(recipe.Recipe, *RecipeElements, ramen.VolumeReplicationGroup, ramen.RamenConfig) error { | ||
return nil | ||
}, | ||
) | ||
return recipeElements.PvcSelector, nil | ||
} | ||
|
||
func RecipeElementsGet(ctx context.Context, reader client.Reader, vrg ramen.VolumeReplicationGroup, | ||
ramenConfig ramen.RamenConfig, log logr.Logger, recipeElements *RecipeElements, | ||
) error { | ||
return recipeVolumesAndOptionallyWorkflowsGet(ctx, reader, vrg, ramenConfig, log, recipeElements, | ||
recipeWorkflowsGet, | ||
) | ||
} | ||
ramenConfig ramen.RamenConfig, log logr.Logger, | ||
) (RecipeElements, error) { | ||
var recipeElements RecipeElements | ||
|
||
func recipeVolumesAndOptionallyWorkflowsGet(ctx context.Context, reader client.Reader, vrg ramen.VolumeReplicationGroup, | ||
ramenConfig ramen.RamenConfig, log logr.Logger, recipeElements *RecipeElements, | ||
workflowsGet func(recipe.Recipe, *RecipeElements, ramen.VolumeReplicationGroup, ramen.RamenConfig) error, | ||
) error { | ||
if vrg.Spec.KubeObjectProtection == nil { | ||
*recipeElements = RecipeElements{ | ||
recipeElements = RecipeElements{ | ||
PvcSelector: getPVCSelector(vrg, ramenConfig, nil, nil), | ||
} | ||
|
||
return nil | ||
return recipeElements, nil | ||
} | ||
|
||
if vrg.Spec.KubeObjectProtection.RecipeRef == nil { | ||
*recipeElements = RecipeElements{ | ||
recipeElements = RecipeElements{ | ||
PvcSelector: getPVCSelector(vrg, ramenConfig, nil, nil), | ||
CaptureWorkflow: captureWorkflowDefault(vrg, ramenConfig), | ||
RecoverWorkflow: recoverWorkflowDefault(vrg, ramenConfig), | ||
} | ||
|
||
return nil | ||
return recipeElements, nil | ||
} | ||
|
||
recipeNamespacedName := types.NamespacedName{ | ||
|
@@ -126,11 +117,11 @@ func recipeVolumesAndOptionallyWorkflowsGet(ctx context.Context, reader client.R | |
|
||
recipe := recipe.Recipe{} | ||
if err := reader.Get(ctx, recipeNamespacedName, &recipe); err != nil { | ||
return fmt.Errorf("recipe %v get error: %w", recipeNamespacedName.String(), err) | ||
return recipeElements, fmt.Errorf("recipe %v get error: %w", recipeNamespacedName.String(), err) | ||
} | ||
|
||
if err := RecipeParametersExpand(&recipe, vrg.Spec.KubeObjectProtection.RecipeParameters, log); err != nil { | ||
return err | ||
return recipeElements, fmt.Errorf("recipe %v parameters expansion error: %w", recipeNamespacedName.String(), err) | ||
} | ||
|
||
var selector PvcSelector | ||
|
@@ -141,15 +132,19 @@ func recipeVolumesAndOptionallyWorkflowsGet(ctx context.Context, reader client.R | |
recipe.Spec.Volumes.LabelSelector) | ||
} | ||
|
||
*recipeElements = RecipeElements{ | ||
recipeElements = RecipeElements{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should pvcSelector be added with a OR logic between selector defined in drpc and recipe? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The expectation is that recipe overrides everything that is defined in the drpc. |
||
PvcSelector: selector, | ||
} | ||
|
||
if err := workflowsGet(recipe, recipeElements, vrg, ramenConfig); err != nil { | ||
return err | ||
if err := recipeWorkflowsGet(recipe, &recipeElements, vrg, ramenConfig); err != nil { | ||
return recipeElements, fmt.Errorf("recipe %v workflows get error: %w", recipeNamespacedName.String(), err) | ||
} | ||
|
||
if err := recipeNamespacesValidate(recipeElements, vrg, ramenConfig); err != nil { | ||
return recipeElements, fmt.Errorf("recipe %v namespaces validation error: %w", recipeNamespacedName.String(), err) | ||
} | ||
|
||
return recipeNamespacesValidate(*recipeElements, vrg, ramenConfig) | ||
return recipeElements, nil | ||
} | ||
|
||
func RecipeParametersExpand(recipe *recipe.Recipe, parameters map[string][]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.
(nit) This line is a bit confusing. It references returning
recipeElements.PvcSelector
on an error, but sincefilterPVC()
skipsPvcSelector
in case of an error, I suggest returningPvcSelector{}
instead. This would improve readability.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 merged this PR and fixed this nit in the next PR #1738