diff --git a/metadata/report/zookeeper/report.go b/metadata/report/zookeeper/report.go index 6e2525da9c..9a55865a89 100644 --- a/metadata/report/zookeeper/report.go +++ b/metadata/report/zookeeper/report.go @@ -28,6 +28,7 @@ import ( gxset "github.com/dubbogo/gost/container/set" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( @@ -79,7 +80,7 @@ func (m *zookeeperMetadataReport) PublishAppMetadata(metadataIdentifier *identif return err } err = m.client.CreateWithValue(k, data) - if err == zk.ErrNodeExists { + if perrors.Is(err, zk.ErrNodeExists) { logger.Debugf("Try to create the node data failed. In most cases, it's not a problem. ") return nil } @@ -89,13 +90,23 @@ func (m *zookeeperMetadataReport) PublishAppMetadata(metadataIdentifier *identif // StoreProviderMetadata stores the metadata. func (m *zookeeperMetadataReport) StoreProviderMetadata(providerIdentifier *identifier.MetadataIdentifier, serviceDefinitions string) error { k := m.rootDir + providerIdentifier.GetFilePathKey() - return m.client.CreateWithValue(k, []byte(serviceDefinitions)) + err := m.client.CreateWithValue(k, []byte(serviceDefinitions)) + if perrors.Is(err, zk.ErrNodeExists) { + logger.Debugf("Try to store provider metadata failed. In most cases, it's not a problem. ") + return nil + } + return err } // StoreConsumerMetadata stores the metadata. func (m *zookeeperMetadataReport) StoreConsumerMetadata(consumerMetadataIdentifier *identifier.MetadataIdentifier, serviceParameterString string) error { k := m.rootDir + consumerMetadataIdentifier.GetFilePathKey() - return m.client.CreateWithValue(k, []byte(serviceParameterString)) + err := m.client.CreateWithValue(k, []byte(serviceParameterString)) + if perrors.Is(err, zk.ErrNodeExists) { + logger.Debugf("Try to store consumer metadata failed. In most cases, it's not a problem. ") + return nil + } + return err } // SaveServiceMetadata saves the metadata.