-
Notifications
You must be signed in to change notification settings - Fork 119
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
Provide a way to run a Plugin
in a zone leader replica
#1044
Conversation
ce06e38
to
3525953
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically looks great! Left a few suggestions. 😉
@@ -64,7 +64,8 @@ defaults: | |||
"port": 36463, | |||
"protocol": null, | |||
"path": null | |||
} | |||
}, | |||
"zone": null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be in replication
because zone
is only used when replication is enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I designed PluginTarget.ZONE_LEADER_ONLY
to run with a standalone mode for the convenience of testing.
|
||
import com.linecorp.armeria.common.util.SystemInfo; | ||
|
||
final class ZoneResolver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this converts a value in the configuration file, how about using ConfigValueConverter
?
I also had the plan to add classpath
support in DefaultConfigValueConverter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classpath
seems useful. That said, I decided not to add classpath
support but use a custom ConfigValueConverter
to dynamically load a zone name.
It would take some time for me to design whether to call the function by convention such as one method with no-args or provide an API. Let me revisit it when I come to a conclusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a review on naming, but looks good 👍
@@ -262,6 +263,16 @@ Core properties | |||
|
|||
- the path of the management service. If not specified, the management service is mounted at ``/internal/management``. | |||
|
|||
- ``zone`` (string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think zone
may be confusing for users since it seems like a generic field which handles multi-zone deployment, but only affects plugin behavior - especially since there hasn't been a notion of zone
in central dogma before (only internally).
What do you think of naming this more specifically if you don't have plans to expand the functionality of this field?
e.g.
plugin-group-id
/plugin-zone-id
Alternatively, I think just using groupId
of the server itself may be clearer - I think it is possible to deduce it from the peerId once a zk server starts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. As you said, it's currently only used for plugins, but I didn't think the usage of it is limited to the plugins. It would also be useful to expose zone
in the UI. When creating a mirroring job, I plan to take a zone
to run. Textual information is better than groupId
which is a number.
Additionally, we may allow creating repositories only in certain zones later, as cloud providers do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By adding a coupling with zone, users won't be able to run plugins with arbitrary groups: i.e. run pluginA for ZoneA,ZoneB, run pluginB for ZoneC.
Having said this, I agree it's probably fine to proceed as-is since we haven't had requirements for this kind of use-case yet and we can always add a new Plugin type.
Textual information is better than groupId which is a number.
Sounds fine, but when developing this field further I think it may still be useful if the relationship between groupId
and zone
is better defined. (Perhaps we can maintain an internal mapping of zone <-> groupId
if only numbers are allowed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fine, but when developing this field further I think it may still be useful if the relationship between groupId and zone is better defined. (Perhaps we can maintain an internal mapping of zone <-> groupId if only numbers are allowed)
I will think about this part further while working on mirroring. I need to change the configuration format to take all available zones to expose as a select box in the following PR.
For example:
zone: {
currentZone: "ZoneA",
allZones: ["ZoneA", "ZoneB", "ZoneC"]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👍 👍 👍
Motivation:
When Central Dogma works on multiple IDC, we may need to run a
Plugin
in a specific zone due to network latency, firewall policy, or load balancing.Modifications:
PluginTarget.ZONE_LEADER_ONLY
to run aPlugin
in each zone leader.ZoneProvider
interface to dynamically resolve a zone name.zone
viadogma.json
andCentralDogmaBuilder
.zone
starts withclasspath:
, the class is loaded and cast toZoneProvider
.$
, the value is read from the environment variable.onTakeZoneLeadership
andonReleaseZoneLeadership
to the methods and fields whereonTakeLeadership
andonReleaseLeadership
were defined before./leader/{zone}
is used to take the zone leadership.Result:
You can now run a
Plugin
in a zone leader with the following:dogma.json
Plugin