feat: Add owner references to all resources#2199
Closed
mbegenau wants to merge 3 commits into
Closed
Conversation
mbegenau
force-pushed
the
feat-498-ownerReferences
branch
from
February 2, 2023 18:25
6a81980 to
47ad395
Compare
mbegenau
marked this pull request as ready for review
February 2, 2023 18:26
mbegenau
requested review from
FxKu,
Jan-M,
hughcapet,
idanovinda,
jopadi and
sdudoladov
as code owners
February 2, 2023 18:26
mbegenau
force-pushed
the
feat-498-ownerReferences
branch
from
April 7, 2023 19:06
47ad395 to
1a91adb
Compare
Contributor
|
It would be cool to add support for OwnerReferences references. Is there anything that prevents us from adopting this PR? |
|
+1 |
2 similar comments
|
+1 |
Contributor
|
+1 |
mbegenau
force-pushed
the
feat-498-ownerReferences
branch
from
August 24, 2023 19:26
fb4d2ed to
cb55d11
Compare
|
+1 |
|
+1 any news? |
Contributor
|
Hello everyone! |
|
+1 |
FxKu
reviewed
Jul 1, 2024
FxKu
reviewed
Jul 1, 2024
Comment on lines
+2347
to
+2354
| if podDisruptionBudget.ObjectMeta.Namespace != "myapp" { | ||
| return fmt.Errorf("Object Namespace incorrect.") | ||
| } | ||
| if !reflect.DeepEqual(podDisruptionBudget.Labels, map[string]string{"team": "myapp", "cluster-name": "myapp-database"}) { | ||
|
|
||
| return fmt.Errorf("Labels incorrect.") | ||
| } | ||
| if !reflect.DeepEqual(podDisruptionBudget.Spec.Selector, &metav1.LabelSelector{ |
Contributor
There was a problem hiding this comment.
Suggested change
| if podDisruptionBudget.ObjectMeta.Namespace != "myapp" { | |
| return fmt.Errorf("Object Namespace incorrect.") | |
| } | |
| if !reflect.DeepEqual(podDisruptionBudget.Labels, map[string]string{"team": "myapp", "cluster-name": "myapp-database"}) { | |
| return fmt.Errorf("Labels incorrect.") | |
| } | |
| if !reflect.DeepEqual(podDisruptionBudget.Spec.Selector, &metav1.LabelSelector{ | |
| masterLabelSelectorDisabled := cluster.OpConfig.PDBMasterLabelSelector != nil && !*cluster.OpConfig.PDBMasterLabelSelector | |
| if podDisruptionBudget.ObjectMeta.Namespace != "myapp" { | |
| return fmt.Errorf("Object Namespace incorrect.") | |
| } | |
| if !reflect.DeepEqual(podDisruptionBudget.Labels, map[string]string{"team": "myapp", "cluster-name": "myapp-database"}) { | |
| return fmt.Errorf("Labels incorrect.") | |
| } | |
| if !masterLabelSelectorDisabled && | |
| !reflect.DeepEqual(podDisruptionBudget.Spec.Selector, &metav1.LabelSelector{ |
Contributor
There was a problem hiding this comment.
And final test case must be changed to
{
scenario: "With PDBMasterLabelSelector disabled",
spec: New(
Config{OpConfig: config.Config{Resources: config.Resources{ClusterNameLabel: "cluster-name", PodRoleLabel: "spilo-role"}, PDBNameFormat: "postgres-{cluster}-pdb", EnablePodDisruptionBudget: util.True(), PDBMasterLabelSelector: util.False()}},
k8sutil.KubernetesClient{},
acidv1.Postgresql{
ObjectMeta: metav1.ObjectMeta{Name: "myapp-database", Namespace: "myapp"},
Spec: acidv1.PostgresSpec{TeamID: "myapp", NumberOfInstances: 3}},
logger,
eventRecorder),
check: []func(cluster *Cluster, podDisruptionBudget *policyv1.PodDisruptionBudget) error{
testPodDisruptionBudgetOwnerReference,
hasName("postgres-myapp-database-pdb"),
hasMinAvailable(1),
testLabelsAndSelectors,
},
},
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.
Previously, only the Service and Deployment resource managed by the operator had an OwnerReference linking it to the StatefulSet. Now, all managed resources get an OwnerReference pointing to the Postgresql resource.
Fixes #498.