Skip to content

Commit

Permalink
do not append ObservedGeneration for RemoteResource conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
kobzonega committed Jul 17, 2024
1 parent 1eaae78 commit 02a6a03
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 42 deletions.
6 changes: 3 additions & 3 deletions internal/controllers/database/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (r *Reconciler) waitForNodeSetsToProvisioned(
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
ObservedGeneration: database.Generation,
Message: "Successfully scaled to desired number of nodes",
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", database.Spec.Nodes),
})
return r.updateStatus(ctx, database, StatusUpdateRequeueDelay)
}
Expand Down Expand Up @@ -343,7 +343,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
ObservedGeneration: database.Generation,
Message: "Number of running nodes does not match expected",
Message: fmt.Sprintf("Number of running nodes does not match expected: %d != %d", foundStatefulSet.Status.ReadyReplicas, database.Spec.Nodes),
})
return r.updateStatus(ctx, database, DefaultRequeueDelay)
}
Expand All @@ -354,7 +354,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
ObservedGeneration: database.Generation,
Message: "Successfully scaled to desired number of nodes",
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", database.Spec.Nodes),
})
return r.updateStatus(ctx, database, StatusUpdateRequeueDelay)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/databasenodeset/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
ObservedGeneration: databaseNodeSet.Generation,
Message: "Number of running nodes does not match expected",
Message: fmt.Sprintf("Number of running nodes does not match expected: %d != %d", foundStatefulSet.Status.ReadyReplicas, databaseNodeSet.Spec.Nodes),
})
return r.updateStatus(ctx, databaseNodeSet, DefaultRequeueDelay)
}
Expand All @@ -253,7 +253,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
ObservedGeneration: databaseNodeSet.Generation,
Message: "Successfully scaled to desired number of nodes",
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", databaseNodeSet.Spec.Nodes),
})
return r.updateStatus(ctx, databaseNodeSet, StatusUpdateRequeueDelay)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/storage/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Type: StorageProvisionedCondition,
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
Message: "Number of running nodes does not match expected",
Message: fmt.Sprintf("Number of running nodes does not match expected: %d != %d", foundStatefulSet.Status.ReadyReplicas, storage.Spec.Nodes),
})
return r.updateStatus(ctx, storage, DefaultRequeueDelay)
}
Expand All @@ -168,7 +168,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Type: StorageProvisionedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
Message: "Successfully scaled to desired number of nodes",
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", storage.Spec.Nodes),
})
return r.updateStatus(ctx, storage, StatusUpdateRequeueDelay)
}
Expand Down Expand Up @@ -266,7 +266,7 @@ func (r *Reconciler) waitForNodeSetsToProvisioned(
Type: StorageProvisionedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
Message: "Successfully scaled to desired number of nodes",
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", storage.Spec.Nodes),
})
return r.updateStatus(ctx, storage, StatusUpdateRequeueDelay)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/storagenodeset/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Type: NodeSetProvisionedCondition,
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
Message: "Number of running nodes does not match expected",
Message: fmt.Sprintf("Number of running nodes does not match expected: %d != %d", foundStatefulSet.Status.ReadyReplicas, storageNodeSet.Spec.Nodes),
})
return r.updateStatus(ctx, storageNodeSet, DefaultRequeueDelay)
}
Expand All @@ -248,7 +248,7 @@ func (r *Reconciler) waitForStatefulSetToScale(
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
ObservedGeneration: storageNodeSet.Generation,
Message: "Successfully scaled to desired number of nodes",
Message: fmt.Sprintf("Successfully scaled to desired number of nodes: %d", storageNodeSet.Spec.Nodes),
})
return r.updateStatus(ctx, storageNodeSet, StatusUpdateRequeueDelay)
}
Expand Down
29 changes: 13 additions & 16 deletions internal/resources/remotedatabasenodeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,40 +203,37 @@ func (b *RemoteDatabaseNodeSetResource) CreateRemoteResourceStatus(
meta.SetStatusCondition(
&b.Status.RemoteResources[len(b.Status.RemoteResources)-1].Conditions,
metav1.Condition{
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionUnknown,
Reason: ReasonInProgress,
ObservedGeneration: b.Generation,
Message: "Sync remoteObject in progress",
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionUnknown,
Reason: ReasonInProgress,
Message: "Sync remoteObject in progress",
},
)
}

func (b *RemoteDatabaseNodeSetResource) UpdateRemoteResourceStatus(
remoteResource *api.RemoteResource,
status metav1.ConditionStatus,
message string,
resourceVersion string,
) {
if status == metav1.ConditionFalse {
meta.SetStatusCondition(&remoteResource.Conditions,
metav1.Condition{
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
ObservedGeneration: b.Generation,
Message: fmt.Sprintf("Failed to sync remoteObject to resourceVersion %s", message),
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
Message: fmt.Sprintf("Failed to sync remoteObject to resourceVersion %s", resourceVersion),
})
remoteResource.State = ResourceSyncPending
}

if status == metav1.ConditionTrue {
meta.SetStatusCondition(&remoteResource.Conditions,
metav1.Condition{
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
ObservedGeneration: b.Generation,
Message: fmt.Sprintf("Successfully synced remoteObject to resourceVersion %s", message),
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
Message: fmt.Sprintf("Successfully synced remoteObject to resourceVersion %s", resourceVersion),
})
remoteResource.State = ResourceSyncSuccess
}
Expand Down
29 changes: 13 additions & 16 deletions internal/resources/remotestoragenodeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,40 +182,37 @@ func (b *RemoteStorageNodeSetResource) CreateRemoteResourceStatus(remoteObj clie
meta.SetStatusCondition(
&b.Status.RemoteResources[len(b.Status.RemoteResources)-1].Conditions,
metav1.Condition{
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionUnknown,
Reason: ReasonInProgress,
ObservedGeneration: b.Generation,
Message: "Sync remoteObject in progress",
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionUnknown,
Reason: ReasonInProgress,
Message: "Sync remoteObject in progress",
},
)
}

func (b *RemoteStorageNodeSetResource) UpdateRemoteResourceStatus(
remoteResource *api.RemoteResource,
status metav1.ConditionStatus,
message string,
resourceVersion string,
) {
if status == metav1.ConditionFalse {
meta.SetStatusCondition(&remoteResource.Conditions,
metav1.Condition{
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
ObservedGeneration: b.Generation,
Message: fmt.Sprintf("Failed to sync remoteObject to resourceVersion %s", message),
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionFalse,
Reason: ReasonInProgress,
Message: fmt.Sprintf("Failed to sync remoteObject to resourceVersion %s", resourceVersion),
})
remoteResource.State = ResourceSyncPending
}

if status == metav1.ConditionTrue {
meta.SetStatusCondition(&remoteResource.Conditions,
metav1.Condition{
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
ObservedGeneration: b.Generation,
Message: fmt.Sprintf("Successfully synced remoteObject to resourceVersion %s", message),
Type: RemoteResourceSyncedCondition,
Status: metav1.ConditionTrue,
Reason: ReasonCompleted,
Message: fmt.Sprintf("Successfully synced remoteObject to resourceVersion %s", resourceVersion),
})
remoteResource.State = ResourceSyncSuccess
}
Expand Down

0 comments on commit 02a6a03

Please sign in to comment.