Skip to content
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

ignore zk node already exist when store provider/consumer metadata #2311

Merged
merged 5 commits into from
Jun 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions metadata/report/zookeeper/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}
Expand All @@ -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.
Expand Down