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

fix: FilePeers implies no Redis #1251

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
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
24 changes: 8 additions & 16 deletions cmd/refinery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func main() {
os.Exit(1)
}

// set up the peer management and pubsub implementations
var peers peer.Peers
var pubsubber pubsub.PubSub
ptype, err := c.GetPeerManagementType()
Expand All @@ -124,24 +125,15 @@ func main() {
}
switch ptype {
case "file":
// we want to use the file peers object to ask if we have only one peer, so we need to instantiate it
// with a dummy metrics object. we'll replace it with the real one later.
peers = &peer.FilePeers{Cfg: c, Metrics: &metrics.NullMetrics{}}
// if we only have one, we can use the local pubsub implementation.
peerList, err := peers.GetPeers()
if err != nil {
panic(err)
}
if len(peerList) == 1 {
pubsubber = &pubsub.LocalPubSub{}
} else {
pubsubber = &pubsub.GoRedisPubSub{}
}
// now erase the peers Metrics object so that it will get injected with the right one later
peers.(*peer.FilePeers).Metrics = nil
// In the case of file peers, we do not use Redis for anything, including pubsub, so
// we use the local pubsub implementation. Even if we have multiple peers, these
// peers cannot communicate using pubsub.
peers = &peer.FilePeers{}
pubsubber = &pubsub.LocalPubSub{}
case "redis":
pubsubber = &pubsub.GoRedisPubSub{}
// if we're using redis, we need to set it up for both peers and pubsub
peers = &peer.RedisPubsubPeers{}
pubsubber = &pubsub.GoRedisPubSub{}
default:
// this should have been caught by validation
panic("invalid config option 'PeerManagement.Type'")
Expand Down
11 changes: 7 additions & 4 deletions config/metadata/configMeta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,15 @@ groups:
Peer management is the mechanism by which Refinery locates its peers.

`file` means that Refinery gets its peer list from the Peers list in
this config file.
this config file. It also prevents Refinery from using a publish/subscribe
mechanism to propagate peer lists, stress levels, and configuration changes.

`redis` means that Refinery uses a Publish/Subscribe mechanism,
implemented on Redis, to propagate peer lists much more quickly than
the legacy mechanism. This is the recommended setting, especially for
new installations.
implemented on Redis, to propagate peer lists, stress levels, and
notification of configuration changes much more quickly than the
legacy mechanism. This is the recommended setting, especially for new
installations. If this is specified, fields in `RedisPeerManagement`
must also be set.

- name: Identifier
v1group: PeerManagement
Expand Down
Loading