Skip to content

Commit 5eda221

Browse files
authored
[New Scheduler] Etcd installation & Implements EtcdClient (#5031)
* Implements EtcdClient * Add license header * Add configuration for tests * Exclude etcd config from controller & invoker * Add config for etcd test * Separate etcd test from whisk unit test * Apply scala compilation
1 parent 1753946 commit 5eda221

File tree

19 files changed

+1084
-1
lines changed

19 files changed

+1084
-1
lines changed

ansible/environments/docker-machine/hosts.j2.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ invoker1 ansible_host={{ docker_machine_ip }}
3939
[elasticsearch:children]
4040
db
4141

42+
[etcd]
43+
etcd0 ansible_host={{ docker_machine_ip }}
44+
{% if mode is defined and 'HA' in mode %}
45+
etcd1 ansible_host={{ docker_machine_ip }}
46+
4247
; define variables
4348
[all:vars]
4449
ansible_connection=ssh

ansible/environments/local/hosts.j2.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ db
3939

4040
[apigateway]
4141
172.17.0.1 ansible_host=172.17.0.1 ansible_connection=local
42+
43+
[etcd]
44+
etcd0 ansible_host=172.17.0.1 ansible_connection=local

ansible/environments/vagrant/hosts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ invoker0 ansible_host=172.17.0.1 ansible_connection=local
2727

2828
[apigateway]
2929
172.17.0.1 ansible_host=172.17.0.1 ansible_connection=local
30+
31+
[etcd]
32+
etcd0 ansible_host=172.17.0.1 ansible_connection=local

ansible/etcd.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
---
18+
# This playbook deploys Openwhisk Invokers.
19+
20+
- hosts: etcd
21+
roles:
22+
- etcd

ansible/group_vars/all

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ whisk:
5151
feature_flags:
5252
require_api_key_annotation: "{{ require_api_key_annotation | default(true) | lower }}"
5353
require_response_payload: "{{ require_response_payload | default(true) | lower }}"
54+
cluster_name: "{{ whisk_cluster_name | default('whisk') }}"
5455

5556
##
5657
# configuration parameters related to support runtimes (see org.apache.openwhisk.core.entity.ExecManifest for schema of the manifest).
@@ -424,3 +425,28 @@ user_events: "{{ user_events_enabled | default(false) | lower }}"
424425

425426
durationChecker:
426427
timeWindow: "{{ duration_checker_time_window | default('1 d') }}"
428+
429+
etcd:
430+
version: "{{ etcd_version | default('v3.4.0') }}"
431+
client:
432+
port: 2379
433+
server:
434+
port: 2480
435+
cluster:
436+
token: "{{ etcd_cluster_token | default('openwhisk-etcd-token') }}"
437+
dir:
438+
data: "{{ etcd_data_dir | default('') }}"
439+
lease:
440+
timeout: "{{ etcd_lease_timeout | default(1) }}"
441+
loglevel: "{{ etcd_log_level | default('info') }}"
442+
quota_backend_bytes: "{{ etcd_quota_backend_bytes | default(0) }}"
443+
snapshot_count: "{{ etcd_snapshot_count | default(100000) }}"
444+
auto_compaction_retention: "{{ etcd_auto_compaction_retention | default(1) }}"
445+
auto_compaction_mode: "{{ etcd_auto_compaction_mode | default('periodic') }}"
446+
pool_threads: "{{ etcd_pool_threads | default(10) }}"
447+
448+
etcd_connect_string: "{% set ret = [] %}\
449+
{% for host in groups['etcd'] %}\
450+
{{ ret.append( hostvars[host].ansible_host + ':' + ((etcd.client.port+loop.index-1)|string) ) }}\
451+
{% endfor %}\
452+
{{ ret | join(',') }}"

ansible/roles/etcd/tasks/clean.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
---
18+
# Remove etcd containers.
19+
20+
- name: remove etcd
21+
docker_container:
22+
name: etcd{{ groups['etcd'].index(inventory_hostname) }}
23+
keep_volumes: True
24+
state: absent
25+
ignore_errors: True

ansible/roles/etcd/tasks/deploy.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
---
18+
# This role will install etcd in group 'etcd' in the environment inventory
19+
20+
- name: "Set the name of the etcd node"
21+
set_fact:
22+
name: "etcd{{ groups['etcd'].index(inventory_hostname) }}"
23+
24+
- name: "set the volume_dir"
25+
set_fact:
26+
volume_dir: "{{ etcd.dir.data }}/etcd{{ groups['etcd'].index(inventory_hostname) }}:/etcd-data"
27+
when: etcd_data_dir is defined
28+
29+
30+
- name: "Set the cluster of the etcd cluster"
31+
set_fact:
32+
cluster: "{% set etcdhosts = [] %}
33+
{% for host in groups['etcd'] %}
34+
{{ etcdhosts.append('etcd' + ((loop.index-1)|string) + '=' + 'http://' + hostvars[host].ansible_host + ':' + ((2480+loop.index-1)|string) ) }}
35+
{% endfor %}
36+
{{ etcdhosts | join(',') }}"
37+
38+
- name: (re)start etcd
39+
docker_container:
40+
name: etcd{{ groups['etcd'].index(inventory_hostname) }}
41+
image: quay.io/coreos/etcd:{{ etcd.version }}
42+
state: started
43+
recreate: true
44+
restart_policy: "{{ docker.restart.policy }}"
45+
volumes: "{{volume_dir | default([])}}"
46+
command: "/usr/local/bin/etcd \
47+
--data-dir=/etcd-data --name '{{ name }}' \
48+
--initial-advertise-peer-urls http://{{ ansible_host }}:{{ etcd.server.port + groups['etcd'].index(inventory_hostname) }} \
49+
--advertise-client-urls http://{{ ansible_host }}:{{ etcd.client.port + groups['etcd'].index(inventory_hostname) }} \
50+
--listen-peer-urls http://0.0.0.0:{{ etcd.server.port + groups['etcd'].index(inventory_hostname) }} \
51+
--listen-client-urls http://0.0.0.0:{{ etcd.client.port + groups['etcd'].index(inventory_hostname) }} \
52+
--initial-cluster {{ cluster }} \
53+
--initial-cluster-state new --initial-cluster-token {{ etcd.cluster.token }} \
54+
--quota-backend-bytes {{ etcd.quota_backend_bytes }} \
55+
--snapshot-count {{ etcd.snapshot_count }} \
56+
--auto-compaction-retention {{ etcd.auto_compaction_retention }} \
57+
--auto-compaction-mode {{ etcd.auto_compaction_mode }} \
58+
--log-level {{ etcd.loglevel }}"
59+
ports:
60+
- "{{ etcd.client.port + groups['etcd'].index(inventory_hostname) }}:{{ etcd.client.port + groups['etcd'].index(inventory_hostname) }}"
61+
- "{{ etcd.server.port + groups['etcd'].index(inventory_hostname) }}:{{ etcd.server.port + groups['etcd'].index(inventory_hostname) }}"
62+
pull: "{{ etcd.pull_etcd | default(true) }}"
63+
64+
- name: wait until etcd in this host is up and running
65+
uri:
66+
url: "http://{{ ansible_host }}:{{ etcd.client.port + groups['etcd'].index(inventory_hostname) }}/health"
67+
register: result
68+
until: result.status == 200
69+
retries: 12
70+
delay: 5

ansible/roles/etcd/tasks/main.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
---
18+
# This role will install etcd in group 'etcd' in the environment inventory
19+
# In deploy mode it will deploy etcd containers.
20+
# In clean mode it will remove etcd containers.
21+
22+
- import_tasks: deploy.yml
23+
when: mode == "deploy"
24+
25+
- import_tasks: clean.yml
26+
when: mode == "clean"

common/scala/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ dependencies {
7373
//for mesos
7474
compile "com.adobe.api.platform.runtime:mesos-actor:0.0.17"
7575

76+
// for etcd
77+
compile("com.ibm.etcd:etcd-java:0.0.13")
78+
7679
//tracing support
7780
compile "io.opentracing:opentracing-api:0.31.0"
7881
compile "io.opentracing:opentracing-util:0.31.0"

common/scala/src/main/resources/application.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ whisk {
383383
local-image-prefix = "whisk"
384384
}
385385

386+
# cluster name related etcd configuration
387+
cluster {
388+
name = "whisk"
389+
}
390+
386391
user-events {
387392
enabled = false
388393
}

0 commit comments

Comments
 (0)