Skip to content

Commit

Permalink
feat: all-rw feature
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryTravyan committed Nov 30, 2022
1 parent 4f62f33 commit 3f79813
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "genin"
version = "0.4.10"
version = "0.4.11"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Download and unzip the archive for the desired architecture.

Universal executable:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/bin/genin-0.4.8-x86_64-musl.tar.gz
tar -xvf genin-0.4.8-x86_64-musl.tar.gz ; sudo install genin /usr/local/bin/
curl -sLO https://binary.picodata.io/repository/raw/genin/bin/genin-0.4.11-x86_64-musl.tar.gz
tar -xvf genin-0.4.11-x86_64-musl.tar.gz ; sudo install genin /usr/local/bin/
```

---
Expand Down Expand Up @@ -85,11 +85,11 @@ sudo yum install -y genin
2. If you want to install `rpm` packages directly without
adding our repository.
```shell
sudo rpm -i https://binary.picodata.io/repository/yum/el/8/x86_64/os/genin-0.4.8-1.el8.x86_64.rpm
sudo rpm -i https://binary.picodata.io/repository/yum/el/8/x86_64/os/genin-0.4.11-1.el8.x86_64.rpm
```
RHEL 7.x, CentOS 7.x
```shell
sudo rpm -i https://binary.picodata.io/repository/yum/el/7/x86_64/os/genin-0.4.8-1.el7.x86_64.rpm
sudo rpm -i https://binary.picodata.io/repository/yum/el/7/x86_64/os/genin-0.4.11-1.el7.x86_64.rpm
```

---
Expand Down Expand Up @@ -117,7 +117,7 @@ sudo apt install -y genin
2. Downloading and installing the package directly:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.8.amd64.deb && sudo dpkg -i genin-0.4.8.amd64.deb
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.11.amd64.deb && sudo dpkg -i genin-0.4.11.amd64.deb
```
---
Expand All @@ -143,7 +143,7 @@ sudo apt install -y genin
2. Downloading and installing the package directly:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.8.amd64.deb && sudo dpkg -i genin-0.4.8.amd64.deb
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.11.amd64.deb && sudo dpkg -i genin-0.4.11.amd64.deb
```
---
Expand All @@ -163,8 +163,8 @@ brew install genin
Use the following command to grab and install Genin in macOS (10.10+) wihtout
homebrew:
```shell
curl -L https://binary.picodata.io/repository/raw/genin/apple/genin-0.4.8-darwin-amd64.zip -o genin-0.4.8-darwin-amd64.zip
unzip genin-0.4.8-darwin-amd64.zip -d ~/bin/
curl -L https://binary.picodata.io/repository/raw/genin/apple/genin-0.4.11-darwin-amd64.zip -o genin-0.4.11-darwin-amd64.zip
unzip genin-0.4.11-darwin-amd64.zip -d ~/bin/
```
> **Note:** The application can then be found under the `~/bin` directory.
> Make sure the directory is in your `$PATH`.
Expand All @@ -182,8 +182,8 @@ brew install [email protected]
#### Windows
Use the following command to grab and install Genin in Windows 7 64 bit or newer:
```shell
curl.exe -L https://binary.picodata.io/repository/raw/genin/windows/genin-0.4.8-darwin-amd64.zip -o genin-0.4.8-windows-amd64.zip
unzip.exe genin-0.4.8-windows-amd64.zip -d %HOME%/.cargo/bin/
curl.exe -L https://binary.picodata.io/repository/raw/genin/windows/genin-0.4.11-darwin-amd64.zip -o genin-0.4.11-windows-amd64.zip
unzip.exe genin-0.4.11-windows-amd64.zip -d %HOME%/.cargo/bin/
```
> **Note:** The application can then be found under the `.cargo/bin` folder inside
> your user profile folder. Make sure it is in your `%PATH%`.
Expand Down
22 changes: 11 additions & 11 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Genin уже заранее скомпилирован под разные ар

Универсальный исполняемый файл:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/bin/genin-0.4.8-x86_64-musl.tar.gz
tar -xvf genin-0.4.8-x86_64-musl.tar.gz ; sudo install genin /usr/local/bin/
curl -sLO https://binary.picodata.io/repository/raw/genin/bin/genin-0.4.11-x86_64-musl.tar.gz
tar -xvf genin-0.4.11-x86_64-musl.tar.gz ; sudo install genin /usr/local/bin/
```

---
Expand Down Expand Up @@ -88,11 +88,11 @@ sudo yum install -y genin
2. Так же вы можете установить пакет `rpm` напрямую без добавления нашего репозитория.
RHEL 8.x, CentOS 8.x, Rockylinux 8.x, recent Fedora version
```shell
sudo rpm -i https://binary.picodata.io/repository/yum/el/8/x86_64/os/genin-0.4.8-1.el8.x86_64.rpm
sudo rpm -i https://binary.picodata.io/repository/yum/el/8/x86_64/os/genin-0.4.11-1.el8.x86_64.rpm
```
RHEL 7.x, CentOS 7.x
```shell
sudo rpm -i https://binary.picodata.io/repository/yum/el/7/x86_64/os/genin-0.4.8-1.el7.x86_64.rpm
sudo rpm -i https://binary.picodata.io/repository/yum/el/7/x86_64/os/genin-0.4.11-1.el7.x86_64.rpm
```
> **Note:** будьте внимательны, так как при выборе не правильной версии ос могут быть ошибки
> при установке `rpm`
Expand All @@ -119,7 +119,7 @@ sudo apt install -y genin

2. Загрузкой и установкой пакета напрямую:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.8.amd64.deb && sudo dpkg -i genin-0.4.8.amd64.deb
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.11.amd64.deb && sudo dpkg -i genin-0.4.11.amd64.deb
```

---
Expand All @@ -144,7 +144,7 @@ sudo apt install -y genin

2. Загрузкой и установкой пакета напрямую:
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.8.amd64.deb && sudo dpkg -i genin-0.4.8.amd64.deb
curl -sLO https://binary.picodata.io/repository/raw/genin/deb/genin-0.4.11.amd64.deb && sudo dpkg -i genin-0.4.11.amd64.deb
```

---
Expand All @@ -164,8 +164,8 @@ brew install genin
Для установки без помощи homebrew используйте следующие команды для загрузки и установки
Genin на macOS (10.10+):
```shell
curl -sLO https://binary.picodata.io/repository/raw/genin/osx/genin-0.4.8-x86_64-macosx.tar.gz
unzip genin-0.4.8-darwin-amd64.zip -d ~/bin/
curl -sLO https://binary.picodata.io/repository/raw/genin/osx/genin-0.4.11-x86_64-macosx.tar.gz
unzip genin-0.4.11-darwin-amd64.zip -d ~/bin/
```

---
Expand All @@ -189,8 +189,8 @@ brew install [email protected]
Используйте следующие команды для скачивания и установки Genin на операционных системах
Windows 7 64 и новее.
```shell
curl.exe -sLO https://binary.picodata.io/repository/raw/genin/win/genin-0.4.8-win64.zip
unzip.exe genin-0.4.8-win64.zip -d %HOME%/.cargo/bin/
curl.exe -sLO https://binary.picodata.io/repository/raw/genin/win/genin-0.4.11-win64.zip
unzip.exe genin-0.4.11-win64.zip -d %HOME%/.cargo/bin/
```
> **Note:** Genin будет распакован в директорию `.cargo/bin` которая находится в домашнем
> каталоге важего пользователя. Перед использованием приложения пожалуйста удостоверьтесь
Expand All @@ -200,7 +200,7 @@ unzip.exe genin-0.4.8-win64.zip -d %HOME%/.cargo/bin/
```
genin --version
```
Если вы видите сообщение `genin 0.4.8` значит установка прошла успешно.
Если вы видите сообщение `genin 0.4.11` значит установка прошла успешно.

---
## Руководство по использованию
Expand Down
4 changes: 4 additions & 0 deletions src/task/cluster/ins/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,8 @@ impl InstanceV2Config {
..self
}
}

pub fn with_all_rw(self, all_rw: Option<bool>) -> Self {
Self { all_rw, ..self }
}
}
5 changes: 4 additions & 1 deletion src/task/cluster/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ impl<'de> Deserialize<'de> for TopologySet {
#[serde(default)]
roles: Vec<Role>,
#[serde(default)]
all_rw: Option<bool>,
#[serde(default)]
cartridge_extra_env: IndexMap<String, Value>,
#[serde(default)]
config: InstanceV2Config,
Expand All @@ -330,6 +332,7 @@ impl<'de> Deserialize<'de> for TopologySet {
weight,
failure_domains,
mut roles,
all_rw,
cartridge_extra_env,
config,
vars,
Expand All @@ -352,7 +355,7 @@ impl<'de> Deserialize<'de> for TopologySet {
failure_domains,
roles,
cartridge_extra_env,
config,
config: config.with_all_rw(all_rw),
vars,
}
},
Expand Down
84 changes: 84 additions & 0 deletions src/task/inventory/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,87 @@ all:

assert_eq!(inventory, inventory_model);
}

#[test]
fn all_rw_only_in_replicaset() {
let cluster_v2_str: String = r#"---
topology:
- name: storage
replicasets_count: 1
roles:
- storage
all_rw: true
hosts:
- name: datacenter-1
hosts:
- name: server-1
config:
http_port: 8081
binary_port: 3031
address: 192.168.16.11
failover:
mode: stateful
state_provider: stateboard
stateboard_params:
uri: "192.168.16.11:4401"
password: password
vars:
ansible_user: ansible
ansible_password: ansible
cartridge_app_name: myapp
cartridge_cluster_cookie: myapp-cookie
cartridge_package_path: /tmp/myapp.rpm
cartridge_bootstrap_vshard: true"#
.into();

let cluster: Cluster = serde_yaml::from_str(&cluster_v2_str).unwrap();

let inventory_model_str: String = r#"---
all:
vars:
ansible_user: ansible
ansible_password: ansible
cartridge_app_name: myapp
cartridge_cluster_cookie: myapp-cookie
cartridge_package_path: /tmp/myapp.rpm
cartridge_bootstrap_vshard: true
cartridge_failover_params:
mode: stateful
state_provider: stateboard
stateboard_params:
uri: "192.168.16.11:4401"
password: password
hosts:
storage-1:
config:
advertise_uri: "192.168.16.11:3031"
http_port: 8081
stateboard:
stateboard: true
config:
listen: "192.168.16.11:4401"
password: password
children:
storage-1-replicaset:
vars:
replicaset_alias: storage-1
failover_priority:
- storage-1
roles:
- storage
all_rw: true
hosts:
storage-1: ~
server-1:
vars:
ansible_host: 192.168.16.11
hosts:
storage-1: ~
stateboard: ~"#.into();

let inventory_model: Inventory = serde_yaml::from_str(&inventory_model_str).unwrap();

let inventory = Inventory::try_from(&Some(cluster)).unwrap();

assert_eq!(inventory, inventory_model);
}
4 changes: 2 additions & 2 deletions test/resources/test-2-new-cluster.genin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ failover:
prefix: cartridge/myapp
lock_delay: 30
endpoints:
- "http://192.168.16.11:5699"
- "http://192.168.16.12:5699"
- 'http://192.168.16.11:5699'
- 'http://192.168.16.12:5699'
username: change_me
password: change_me
vars:
Expand Down

0 comments on commit 3f79813

Please sign in to comment.