-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: Add owner references to all resources #2199
Conversation
6a81980
to
47ad395
Compare
47ad395
to
1a91adb
Compare
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 |
+1 |
fb4d2ed
to
cb55d11
Compare
+1 |
2 similar comments
+1 |
+1 |
+1 any news? |
Hello everyone! |
+1 |
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{ |
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.
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{ |
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.
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,
},
},
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.