Skip to content

Commit f224b55

Browse files
committed
fix: Make sure the new resource version is returned after update when using Nacos as storage
1 parent 15c3aaa commit f224b55

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/apiserver/pkg/registry/nacos_rest.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ func (n *nacosREST) write(encoder runtime.Encoder, group, dataId, oldMd5 string,
578578
if err != nil {
579579
return err
580580
}
581+
oldResourceVersion := accessor.GetResourceVersion()
581582
// No resource version saved into nacos
582583
accessor.SetResourceVersion("")
583584

@@ -589,7 +590,13 @@ func (n *nacosREST) write(encoder runtime.Encoder, group, dataId, oldMd5 string,
589590
if err != nil {
590591
return err
591592
}
592-
return n.writeRaw(group, dataId, content, oldMd5)
593+
err = n.writeRaw(group, dataId, content, oldMd5)
594+
if err == nil {
595+
accessor.SetResourceVersion(calculateMd5(content))
596+
} else {
597+
accessor.SetResourceVersion(oldResourceVersion)
598+
}
599+
return err
593600
}
594601

595602
func (n *nacosREST) writeRaw(group, dataId, content, oldMd5 string) error {

0 commit comments

Comments
 (0)