-
Notifications
You must be signed in to change notification settings - Fork 9
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
Serve metrics under a dedicated port #48
Changes from 2 commits
16f2411
7ab8bde
0a91415
d8e6c10
974f733
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ class EtcdMember: | |
API_VERSION = '/v2/' | ||
DEFAULT_CLIENT_PORT = 2379 | ||
DEFAULT_PEER_PORT = 2380 | ||
DEFAULT_METRICS_PORT = 2381 | ||
AG_TAG = 'aws:autoscaling:groupName' | ||
CF_TAG = 'aws:cloudformation:stack-name' | ||
|
||
|
@@ -56,6 +57,7 @@ def __init__(self, arg, region=None): | |
|
||
self.client_port = self.DEFAULT_CLIENT_PORT | ||
self.peer_port = self.DEFAULT_PEER_PORT | ||
self.metrics_port = self.DEFAULT_METRICS_PORT | ||
|
||
self.client_urls = [] # these values could be assigned only from the running etcd | ||
self.peer_urls = [] # cluster by performing http://addr:client_port/v2/members api call | ||
|
@@ -242,7 +244,8 @@ def delete_member(self, member): | |
return result | ||
|
||
def etcd_arguments(self, data_dir, initial_cluster, cluster_state): | ||
return [ | ||
# common flags that always have to be set | ||
arguments = [ | ||
'-name', | ||
self.instance_id, | ||
'--data-dir', | ||
|
@@ -263,6 +266,22 @@ def etcd_arguments(self, data_dir, initial_cluster, cluster_state): | |
cluster_state | ||
] | ||
|
||
# this section handles etcd version specific flags | ||
etcdversion = os.environ.get('ETCDVERSION') | ||
if etcdversion: | ||
etcdversion = list(map(lambda x: int(x), etcdversion.split('.'))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You could also use tuples which are immutable ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I changed it. |
||
# don't try to add additonal flags if we encounter an unexpected version format | ||
if len(etcdversion) == 3: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this is worth it TBH. If they decide to do a |
||
# etcd >= v3.3: serve metrics on an additonal port | ||
if etcdversion[0] >= 3 and etcdversion[1] >= 3: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
arguments += [ | ||
'-listen-metrics-urls', | ||
'http://0.0.0.0:{}'.format(self.metrics_port), | ||
] | ||
|
||
# return final list of arguments | ||
return arguments | ||
|
||
|
||
class EtcdCluster: | ||
REGIONS = [] # more then one (1) Region if this a Multi-Region-Cluster | ||
|
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.
There is still one corner case left, it breaks upgrade from 3.2 to 3.3 :(
During the upgrade first it starts the old binary in order to get data, than it stops it and starts the new binary.
Current change will try to apply
-listen-metrics-urls
to the old binary and fail if the old version is 3.2In order to solve it, let's introduce one more argument to this method,
run_old
and pass its value from https://github.com/linki/stups-etcd-cluster/blob/0a914150be28b93ff77b56747b0cf09a010138dc/etcd.py#L474:And the line 270 has to be changed to: