fix: comment and reply observed version for status (#5800)

#### What type of PR is this?
/kind bug
/area core
/milestone 2.15.x

#### What this PR does / why we need it:
修复由于没有更新 observed version 导致评论和回复的 reconciler 执行次数控制没有生效的问题

#### Does this PR introduce a user-facing change?
```release-note
None
```
pull/5780/head
guqing 2024-04-25 15:49:11 +08:00 committed by GitHub
parent a644c40cfd
commit 9054e1fb92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -80,6 +80,11 @@ public class CommentReconciler implements Reconciler<Reconciler.Request> {
updateUnReplyCountIfNecessary(comment); updateUnReplyCountIfNecessary(comment);
updateSameSubjectRefCommentCounter(comment); updateSameSubjectRefCommentCounter(comment);
// version + 1 is required to truly equal version
// as a version will be incremented after the update
comment.getStatusOrDefault()
.setObservedVersion(comment.getMetadata().getVersion() + 1);
client.update(comment); client.update(comment);
}); });
return new Result(false, null); return new Result(false, null);

View File

@ -57,6 +57,11 @@ public class ReplyReconciler implements Reconciler<Reconciler.Request> {
) )
); );
} }
// version + 1 is required to truly equal version
// as a version will be incremented after the update
reply.getStatus().setObservedVersion(reply.getMetadata().getVersion() + 1);
client.update(reply); client.update(reply);
replyNotificationSubscriptionHelper.subscribeNewReplyReasonForReply(reply); replyNotificationSubscriptionHelper.subscribeNewReplyReasonForReply(reply);