-
Notifications
You must be signed in to change notification settings - Fork 69
K8SPG-938 fix conditions #1435
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
base: main
Are you sure you want to change the base?
K8SPG-938 fix conditions #1435
Changes from all commits
1534740
86212bb
88b5083
fb68b5f
cc51389
877564e
16509e8
ba5919f
2898177
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 |
|---|---|---|
|
|
@@ -157,13 +157,13 @@ func updateConditions(cr *v2.PerconaPGCluster, status *v1beta1.PostgresClusterSt | |
|
|
||
| syncPgbackrestFromPostgresToPercona(cr, status) | ||
|
|
||
| repoCondition := meta.FindStatusCondition(status.Conditions, postgrescluster.ConditionRepoHostReady) | ||
| repoCondition := meta.FindStatusCondition(cr.Status.Conditions, postgrescluster.ConditionRepoHostReady) | ||
| if repoCondition == nil || repoCondition.Status != metav1.ConditionTrue { | ||
| setClusterNotReadyCondition(metav1.ConditionFalse, postgrescluster.ConditionRepoHostReady) | ||
| return | ||
| } | ||
|
|
||
| backupCondition := meta.FindStatusCondition(status.Conditions, postgrescluster.ConditionReplicaCreate) | ||
| backupCondition := meta.FindStatusCondition(cr.Status.Conditions, postgrescluster.ConditionReplicaCreate) | ||
| if backupCondition == nil || backupCondition.Status != metav1.ConditionTrue { | ||
| setClusterNotReadyCondition(metav1.ConditionFalse, postgrescluster.ConditionReplicaCreate) | ||
| return | ||
|
|
@@ -175,21 +175,14 @@ func updateConditions(cr *v2.PerconaPGCluster, status *v1beta1.PostgresClusterSt | |
|
|
||
| func syncConditionsFromPostgresToPercona(cr *v2.PerconaPGCluster, postgresStatus *v1beta1.PostgresClusterStatus) { | ||
| for _, pcCond := range postgresStatus.Conditions { | ||
| existing := meta.FindStatusCondition(cr.Status.Conditions, pcCond.Type) | ||
| if existing != nil { | ||
| continue | ||
| } | ||
|
|
||
| newCond := metav1.Condition{ | ||
| _ = meta.SetStatusCondition(&cr.Status.Conditions, metav1.Condition{ | ||
|
Contributor
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. Adding this comment here regarding unit testing. Agreeing with @egegunes, IMO we could add comprehensive unit test
Contributor
Author
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. updateConditions is already covered by integration tests. Should I add unit tests for it as well, or replace the integration tests with unit tests? |
||
| Type: pcCond.Type, | ||
| Status: pcCond.Status, | ||
| Reason: pcCond.Reason, | ||
| Message: pcCond.Message, | ||
| LastTransitionTime: pcCond.LastTransitionTime, | ||
| ObservedGeneration: cr.Generation, | ||
| } | ||
|
|
||
| cr.Status.Conditions = append(cr.Status.Conditions, newCond) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
Since status and cr are already synced, does it matter switching to cr.Status from status? Just trying to understand if this change needs to be made after all.
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.
You're right. After sync they're the same. I'm suggesting cr.Status.Conditions mainly for consistency - setClusterNotReadyCondition uses it, so the checks should too. But it's not critical, we can keep status.Conditions.
WDYT?
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.
sounds good!