Skip to content

Commit

Permalink
Merge pull request hyperledger-iroha#1024 from hyperledger/feature-re…
Browse files Browse the repository at this point in the history
…move-redis-deps

Remove redundant Redis dependencies and mentions
  • Loading branch information
igor-egorov authored Mar 1, 2018
2 parents 2978dce + 1239d24 commit 432276b
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 102 deletions.
12 changes: 2 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ pipeline {
IROHA_POSTGRES_HOST = "pg-${GIT_COMMIT}-${BUILD_NUMBER}"
IROHA_POSTGRES_USER = "pg-user-${GIT_COMMIT}"
IROHA_POSTGRES_PASSWORD = "${GIT_COMMIT}"
IROHA_REDIS_HOST = "redis-${GIT_COMMIT}-${BUILD_NUMBER}"
IROHA_POSTGRES_PORT = 5432
IROHA_REDIS_PORT = 6379

CTEST_OUTPUT_ON_FAILURE = 1
}
Expand All @@ -58,17 +56,11 @@ pipeline {
+ " --name ${env.IROHA_POSTGRES_HOST}"
+ " --network=${env.IROHA_NETWORK}")

def r_c = docker.image('redis:3.2.8').run(""
+ " --name ${env.IROHA_REDIS_HOST}"
+ " --network=${env.IROHA_NETWORK}")

docker.image("${env.DOCKER_IMAGE}").inside(""
+ " -e IROHA_POSTGRES_HOST=${env.IROHA_POSTGRES_HOST}"
+ " -e IROHA_POSTGRES_PORT=${env.IROHA_POSTGRES_PORT}"
+ " -e IROHA_POSTGRES_USER=${env.IROHA_POSTGRES_USER}"
+ " -e IROHA_POSTGRES_PASSWORD=${env.IROHA_POSTGRES_PASSWORD}"
+ " -e IROHA_REDIS_HOST=${env.IROHA_REDIS_HOST}"
+ " -e IROHA_REDIS_PORT=${env.IROHA_REDIS_PORT}"
+ " --network=${env.IROHA_NETWORK}"
+ " -v /var/jenkins/ccache:${CCACHE_DIR}") {

Expand Down Expand Up @@ -218,8 +210,8 @@ pipeline {
always {
script {
sh """
docker stop $IROHA_POSTGRES_HOST $IROHA_REDIS_HOST
docker rm $IROHA_POSTGRES_HOST $IROHA_REDIS_HOST
docker stop $IROHA_POSTGRES_HOST
docker rm $IROHA_POSTGRES_HOST
docker network rm $IROHA_NETWORK
"""
}
Expand Down
1 change: 0 additions & 1 deletion deploy/ansible/roles/iroha-node/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
postgresName: iroha_postgres
postgresUser: psql
postgresPassword: psql
redisName: iroha_redis
peers:
- 209.250.248.121:10001
- 209.250.248.225:10001
Expand Down
14 changes: 1 addition & 13 deletions deploy/ansible/roles/iroha-node/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
networks:
- name: iroha_network

- name: Run redis in docker
docker_container:
name: "{{ redisName }}"
image: redis:3.2.8
state: started
recreate: yes
restart: yes
networks:
- name: iroha_network

- name: Make conf dir
file:
path: '/opt/docker/iroha/conf'
Expand Down Expand Up @@ -81,6 +71,4 @@
POSTGRES_PORT: 5432
POSTGRES_USER: "{{ postgresUser }}"
POSTGRES_PASSWORD: "{{ postgresPassword }}"
REDIS_HOST: "{{ redisName }}"
REDIS_PORT: 6379
KEY: node{{ key }}
KEY: node{{ key }}
2 changes: 0 additions & 2 deletions deploy/ansible/roles/iroha-node/templates/config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"torii_port" : 50051,
"internal_port" : 10001,
"pg_opt" : "host={{ postgresName }} port=5432 user={{ postgresUser }} password='{{ postgresPassword }}'",
"redis_host" : "{{ redisName }}",
"redis_port" : 6379,
"max_proposal_size" : 10,
"proposal_delay" : 5000,
"vote_delay" : 5000,
Expand Down
8 changes: 0 additions & 8 deletions docker/develop/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ RUN git clone https://github.com/jtv/libpqxx /tmp/libpqxx; \
make -C /tmp/libpqxx install; \
rm -rf /tmp/libpqxx

# install cpp_redis 4.3.0
RUN git clone https://github.com/Cylix/cpp_redis /tmp/cpp_redis; \
(cd /tmp/cpp_redis ; git checkout f390eef447a62dcb6da288fb1e91f25f8a9b838c); \
(cd /tmp/cpp_redis ; git submodule update --init --recursive); \
cmake -H/tmp/cpp_redis -B/tmp/cpp_redis/build; \
cmake --build /tmp/cpp_redis/build --target install -- -j${PARALLELISM}; \
rm -rf /tmp/cpp_redis

# install tbb
RUN git clone https://github.com/01org/tbb /tmp/tbb; \
(cd /tmp/tbb ; git checkout eb6336ad29450f2a64af5123ca1b9429ff6bc11d); \
Expand Down
4 changes: 0 additions & 4 deletions docker/docker-compose-swarm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ services:
ports:
- "50051:50051"
depends_on:
- redis
- postgres
tty: true

redis:
image: redis:3.2.8

postgres:
image: postgres:9.5
environment:
Expand Down
5 changes: 0 additions & 5 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ services:
- IROHA_POSTGRES_PORT=5432
- IROHA_POSTGRES_USER=iroha
- IROHA_POSTGRES_PASSWORD=helloworld
- IROHA_REDIS_HOST=${COMPOSE_PROJECT_NAME}_redis_1
- IROHA_REDIS_PORT=6379
- CCACHE_DIR=/tmp/ccache
# export G_ID=$(id -g $(whoami))
# export U_ID=$(id -g $(whoami))
user: ${U_ID:-0}:${G_ID:-0}
depends_on:
- redis
- postgres
tty: true
volumes:
Expand All @@ -27,8 +24,6 @@ services:
working_dir: /opt/iroha
cap_add:
- SYS_PTRACE
redis:
image: redis:3.2.8

postgres:
image: postgres:9.5
Expand Down
36 changes: 8 additions & 28 deletions docs/source/deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,25 @@ Running single instance
Generally, people want to run Iroha locally in order to try out the API and explore the capabilities. This can be done in local or container environment (Docker). We will explore both possible cases, but in order to simplify peer components deployment, *it is advised to have Docker installed on your machine*.

Local environment
----------------
-----------------

By local environment, it is meant to have daemon process and the components (Redis and Postgres) deployed without any containers. This might be helpful in cases when messing up with Docker is not preferred — generally a quick exploration of the features.
By local environment, it is meant to have daemon process and Postgres deployed without any containers. This might be helpful in cases when messing up with Docker is not preferred — generally a quick exploration of the features.

Run postgres server
"""""""""""""""""""

In order to run postgres server locally, you should check postgres `website <https://www.postgresql.org/docs/current/static/server-start.html>`__ and follow their description. Generally, postgres server runs automatically when the system starts, but this should be checked in the configuration of the system.

Run redis server
""""""""""""""""

Redis is known for a simple run process. When it is installed in the system, it is enough to execute `redis-server` binary without arguments. Just in case, check their `website <https://redis.io/topics/quickstart>`__.

Run iroha daemon (irohad)
"""""""""""""""""""""""""

There is a list of preconditions which you should meet before proceeding:

* Postgres server is up and running
* Redis server is up and running
* `irohad` Iroha daemon binary is built and accessible in your system
* The genesis block and configuration files were created
* Config file uses valid postgres and redis connection settings
* Config file uses valid postgres connection settings
* A keypair for the peer is generated
* This is the first time you run the Iroha on this peer and you want to create new chain

Expand All @@ -43,8 +38,8 @@ In case of valid assumptions, the only thing that remains is to launch the daemo
+---------------+-----------------------------------------------------------------+
| Parameter | Meaning |
+---------------+-----------------------------------------------------------------+
| config | configuration file, containing postgres, and redis connection, |
| | and values to tune the system |
| config | configuration file, containing postgres connection and values |
| | to tune the system |
+---------------+-----------------------------------------------------------------+
| genesis_block | initial block in the ledger |
+---------------+-----------------------------------------------------------------+
Expand Down Expand Up @@ -77,23 +72,11 @@ Then, you have to create an enviroment for the image to run without problems:
Create docker network
"""""""""""""""""""""

Containers for Redis, Postgres, and Iroha should run in the same virtual network, in order to be available to each other. Create a network, by typing following command (you can use any name for the network, but in the example, we use *iroha-network* name):
Containers for Postgres and Iroha should run in the same virtual network, in order to be available to each other. Create a network, by typing following command (you can use any name for the network, but in the example, we use *iroha-network* name):

.. code-block:: shell
docker network create iroha-network
Run Redis in a container
""""""""""""""""""""""""

Run redis server, attaching it to the network you have created before, and exposing ports for communication:

.. code-block:: shell
docker run --name some-redis \
-p 6379:6379 \
--network=iroha-network \
-d redis:3.2.8
Run Postgresql in a container
"""""""""""""""""""""""""""""
Expand Down Expand Up @@ -122,7 +105,7 @@ Running iroha daemon in docker container
""""""""""""""""""""""""""""""""""""""""

There is a list of assumptions which you should review before proceeding:
* Postgres and redis servers are running on the same docker network
* Postgres server is running on the same docker network
* There is a folder, containing config file and keypair for a single node
* This is the first time you run the Iroha on this peer and you want to create new chain

Expand All @@ -142,9 +125,6 @@ If they are met, you can move forward with the following command:
-e POSTGRES_PORT='5432' \
-e POSTGRES_PASSWORD='mysecretpassword' \
-e POSTGRES_USER='postgres' \
# Redis settings
-e REDIS_HOST='some-redis' \
-e REDIS_PORT='6379' \
# Node keypair name
-e KEY='node0' \
# Docker network name
Expand Down Expand Up @@ -207,7 +187,7 @@ Step-by-step guide
9. Wait until playbook finishes and then Iroha network is ready and up.

Checking Iroha peer status
""""""""""""""""""""
""""""""""""""""""""""""""

1. SSH into any of your machines

Expand Down
1 change: 0 additions & 1 deletion irohad/ametsuchi/impl/postgres_block_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ namespace iroha {
}

for (const auto &block_id : block_ids) {
// create key for querying redis
execute_(
"SELECT DISTINCT index FROM index_by_id_height_asset WHERE id = "
+ transaction_.quote(account_id)
Expand Down
4 changes: 2 additions & 2 deletions irohad/ametsuchi/impl/postgres_block_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace iroha {
class FlatFile;

/**
* Class which implements BlockQuery with a Redis backend.
* Class which implements BlockQuery with a Postgres backend.
*/
class PostgresBlockQuery : public BlockQuery {
public:
Expand Down Expand Up @@ -81,7 +81,7 @@ namespace iroha {
const std::string &hash);

/**
* creates callback to lrange query to redis to supply result to
* creates callback to lrange query to Postgres to supply result to
* subscriber s
* @param s
* @param block_id
Expand Down
17 changes: 4 additions & 13 deletions scripts/local-develop.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

#
# This simple script starts redis and postgres docker containers,
# and installs environment variables of the caller. Can be safely
# This simple script starts postgres docker container and
# installs environment variables of the caller. Can be safely
# executed as many times as needed (it performs autocleaning).
#
# Usage:
Expand All @@ -22,27 +22,22 @@ dependency grep || exit 1
dependency sed || exit 1

pgname=postgrestestimage
rdname=redistestimage

# cleanup
docker rm -f $pgname $rdname 2>/dev/null 1>&2
docker rm -f $pgname 2>/dev/null 1>&2

# vars
user=postgres
password=mysecretpassword
pgport=5432
rdport=6379

# run postgres and redis
# run postgres
pghost=127.0.0.1
rdhost=127.0.0.1

pgid=$(docker run -p $pghost:$pgport:$pgport --rm --name $pgname -e POSTGRES_USER=$user -e POSTGRES_PASSSWORD=$password -d postgres:9.5)
rdid=$(docker run -p $rdhost:$rdport:$rdport --rm --name $rdname -d redis:3.2.8)

# stderr
>&2 echo "postgres: 127.0.0.1:$pgport {login: $user, pwd: $password}"
>&2 echo "redis: 127.0.0.1:$rdport"

# print variables (stdout)
cat << EOF
Expand All @@ -51,8 +46,6 @@ export IROHA_POSTGRES_PORT=$pgport
export IROHA_POSTGRES_USER=$user
export IROHA_POSTGRES_DATABASE=$user
export IROHA_POSTGRES_PASSWORD=$password
export IROHA_REDIS_HOST=$rdhost
export IROHA_REDIS_PORT=$rdport
EOF

# apply variables
Expand All @@ -61,5 +54,3 @@ export IROHA_POSTGRES_PORT=$pgport
export IROHA_POSTGRES_USER=$user
export IROHA_POSTGRES_DATABASE=$user
export IROHA_POSTGRES_PASSWORD=$password
export IROHA_REDIS_HOST=$rdhost
export IROHA_REDIS_PORT=$rdport
16 changes: 1 addition & 15 deletions scripts/swarm-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,12 @@ do
sleep 0.1;
done

# wait for redis start
until [ "$(docker inspect -f {{.State.Running}} ${COMPOSE_PROJECT_NAME}_redis_1)" == "true" ]
do
sleep 0.1;
done

# wait for redis accepting connections
until docker exec ${COMPOSE_PROJECT_NAME}_redis_1 redis-cli ping
do
sleep 0.1;
done

# generate config
# TODO 22/08/17 Lebedev: replace with environment variables IR-502
echo "{
\"block_store_path\" : \"/tmp/block_store/\",
\"torii_port\" : 50051,
\"pg_opt\" : \"host=${COMPOSE_PROJECT_NAME}_postgres_1 port=5432 user=iroha password=helloworld\",
\"redis_host\" : \"${COMPOSE_PROJECT_NAME}_redis_1\",
\"redis_port\" : 6379
\"pg_opt\" : \"host=${COMPOSE_PROJECT_NAME}_postgres_1 port=5432 user=iroha password=helloworld\"
}" > ${IROHA_HOME}/iroha.conf

# copy list of peers
Expand Down

0 comments on commit 432276b

Please sign in to comment.