Skip to content
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

MF-655 Proper usage of docker volumes #657

Merged
merged 2 commits into from
Apr 18, 2019
Merged

Conversation

chombium
Copy link
Collaborator

@chombium chombium commented Mar 18, 2019

What does this do?

  • adds names for the persistent volumes that we already use them
  • adds filters for the cleanghost to filter out only the containers which we have created
  • adds a switch which when is present the persistent volumes will not be deleted. The default behavior or volume deletion is not changed.

Which issue(s) does this PR fix/relate to?

Resolves #655

List any changes that modify/break current functionality

none

Have you included tests for your changes?

no

Did you document any new/modified functionality?

added description about the changes in the dev guide

Notes

See the issue for more details

@chombium
Copy link
Collaborator Author

I'm still working on this. I've opened the pull request to get feedback.

The current state is:

$ docker volume ls
DRIVER              VOLUME NAME
local               cassandra-writer_mainflux-cassandra-volume
local               docker_mainflux-redis-volume
local               docker_mainflux-things-db-volume
local               docker_mainflux-things-redis-volume
local               docker_mainflux-users-db-volume
local               influxdb-writer_mainflux-grafana-volume
local               influxdb-writer_mainflux-influxdb-volume
local               mongodb-writer_mainflux-mongodb-configdb-volume
local               mongodb-writer_mainflux-mongodb-db-volume

the make cleanghost make task works only with "mainflux artifacts" and the delete switch works.
I still need to do more testing and eventually adjust the commands in cleandocker and cleanghost make tasks

@codecov-io
Copy link

codecov-io commented Mar 18, 2019

Codecov Report

Merging #657 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #657   +/-   ##
=======================================
  Coverage   85.58%   85.58%           
=======================================
  Files          64       64           
  Lines        4011     4011           
=======================================
  Hits         3433     3433           
  Misses        395      395           
  Partials      183      183

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update baebe8a...15be7d7. Read the comment docs.

@chombium chombium changed the title Mf 655 MF-655 Proper usage of docker volumes Mar 18, 2019
@chombium
Copy link
Collaborator Author

The fixes which this PR brings are:

  • no more "ghost volumes"
  • better filtering for the docker containers, images and volumes, so that we are sure that we are only working with the artifacts that we created
  • optional data preservation (the persistent volumes are not deleted) when executing make cleandocker. The default behavior stays the same; no parameter, everything is deleted

The summary of the changes:

  • added persistent volumes in the docker-compose.yml files for all of the components (we were already using persistent volumes anyways)
  • removed the make cleanghost target as there are no more ghost volumes
  • added switch to the make cleandocker so that the persistent volumes are not deleted. The command is make spv=true cleandocker.
  • added documentation of the switch in the dev guide
  • added filtering for all of the docker commands, so that we work only with our containers, images and volumes

@nmarcetic
Copy link
Collaborator

@chombium Can you pls checkout conflicts and update branch. Thanks!

@chombium
Copy link
Collaborator Author

@nmarcetic done ;)

Copy link
Contributor

@anovakovic01 anovakovic01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just fix these two typos. Great job @chombium!

__Note:__ Please store your customizations to some folder outside the Mainflux's source folder and maybe add them to some other git repository. You can always apply your customizations by pointing to the right file using `docker-compose -f ...`.


### Cleaning up your dockerized Mainlfux setup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainflux



### Cleaning up your dockerized Mainlfux setup
If you want to clean your whole dockerized Mainlfux installation you can use the `make cleandocker` command. Please note that __by default the `make cleandocker` command will stop and delete all of the containers, images and persistent volumes__. If you want to keep gathered data in the system (the persistent volumes) please use the following command `make spv=true cleandocker` (spv = skip persistent volumes). This form of the command will stop and delete the containers and images, but won't delete the persistent volumes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainflux

@@ -65,7 +65,7 @@ make docker_http

> N.B. Mainflux creates `FROM scratch` docker containers which are compact and small in size.

> N.B. The `things-db` and `users-db` containers are built from a vanilla PostgreSQL docker image downloaded from docker hub which does not persist the data when these containers are rebuilt. Thus, __rebuilding of all docker containers with `make dockers` or rebuilding the `things-db` and `users-db` containers separately with `make docker_things-db` and `make docker_users-db` respectively, will cause data loss. All your users, things, channels and connections between them will be lost!__ As we use this setup only for development, we don't guarantee any permanent data persistence. If you need to retain the data between the container rebuilds you can attach volume to the `things-db` and `users-db` containers. Check the official docs on how to use volumes [here](https://docs.docker.com/storage/volumes/) and [here](https://docs.docker.com/compose/compose-file/#volumes). For examples on how to add persistent volumes check the [Overriding the default docker-compose configuration](#overriding-the-default-docker-compose-configuration) section.
> N.B. The `things-db` and `users-db` containers are built from a vanilla PostgreSQL docker image downloaded from docker hub which does not persist the data when these containers are rebuilt. Thus, __rebuilding of all docker containers with `make dockers` or rebuilding the `things-db` and `users-db` containers separately with `make docker_things-db` and `make docker_users-db` respectively, will cause data loss. All your users, things, channels and connections between them will be lost!__ As we use this setup only for development, we don't guarantee any permanent data persistence. If you want to update your Mainflux dockerized installation and want to keep your data, use `make spv=true cleandocker` to clean the containers and images and keep the data and then `make run` to update the images and the containers. Check the [Cleaning up your dockerized Mainlfux setup](#cleaning-up-your-dockerized-mainlfux-setup) section for details. Please note that this kind of updating might not work if there are database changes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainflux

@chombium
Copy link
Collaborator Author

@anovakovic01 really good catch. LOLed to myself. The same type in two consecutive sentences :)

@@ -65,7 +65,7 @@ make docker_http

> N.B. Mainflux creates `FROM scratch` docker containers which are compact and small in size.

> N.B. The `things-db` and `users-db` containers are built from a vanilla PostgreSQL docker image downloaded from docker hub which does not persist the data when these containers are rebuilt. Thus, __rebuilding of all docker containers with `make dockers` or rebuilding the `things-db` and `users-db` containers separately with `make docker_things-db` and `make docker_users-db` respectively, will cause data loss. All your users, things, channels and connections between them will be lost!__ As we use this setup only for development, we don't guarantee any permanent data persistence. If you need to retain the data between the container rebuilds you can attach volume to the `things-db` and `users-db` containers. Check the official docs on how to use volumes [here](https://docs.docker.com/storage/volumes/) and [here](https://docs.docker.com/compose/compose-file/#volumes). For examples on how to add persistent volumes check the [Overriding the default docker-compose configuration](#overriding-the-default-docker-compose-configuration) section.
> N.B. The `things-db` and `users-db` containers are built from a vanilla PostgreSQL docker image downloaded from docker hub which does not persist the data when these containers are rebuilt. Thus, __rebuilding of all docker containers with `make dockers` or rebuilding the `things-db` and `users-db` containers separately with `make docker_things-db` and `make docker_users-db` respectively, will cause data loss. All your users, things, channels and connections between them will be lost!__ As we use this setup only for development, we don't guarantee any permanent data persistence. If you want to update your Mainflux dockerized installation and want to keep your data, use `make spv=true cleandocker` to clean the containers and images and keep the data and then `make run` to update the images and the containers. Check the [Cleaning up your dockerized Mainflux setup](#cleaning-up-your-dockerized-mainlfux-setup) section for details. Please note that this kind of updating might not work if there are database changes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just update the link #cleaning-up-your-dockerized-mainflux-setup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks once again. I've missed that one :( it is fixed now

anovakovic01
anovakovic01 previously approved these changes Apr 18, 2019
Copy link
Contributor

@anovakovic01 anovakovic01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chombium Don't worry, it happens. At least you were consistent. 😄 LGTM!

manuio
manuio previously approved these changes Apr 18, 2019
Copy link
Contributor

@anovakovic01 anovakovic01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chombium please rebase

Signed-off-by: Jovan Kostovski <chombium@gmail.com>
Signed-off-by: Jovan Kostovski <chombium@gmail.com>
@chombium
Copy link
Collaborator Author

@anovakovic01 done

Copy link
Contributor

@anovakovic01 anovakovic01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@anovakovic01 anovakovic01 merged commit a30666d into absmach:master Apr 18, 2019


### Cleaning up your dockerized Mainflux setup
If you want to clean your whole dockerized Mainflux installation you can use the `make cleandocker` command. Please note that __by default the `make cleandocker` command will stop and delete all of the containers, images and persistent volumes__. If you want to keep gathered data in the system (the persistent volumes) please use the following command `make spv=true cleandocker` (spv = skip persistent volumes). This form of the command will stop and delete the containers and images, but won't delete the persistent volumes.
Copy link
Contributor

@drasko drasko Apr 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to skip persistent volume by default, but add explicitly extra parameter if you want to delete it also - like pv=true.

I think this can help avoinding errors and making idiot-proof solution. I see more a situations where I cleaned dockers, but I fortgot vlumes - so I run the command again with correct param, no big deal. However, the other way around, if I cleaned everything because I forgot a param - it is too late :).

I let you decide on this, but I would personaly do it like this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drasko I completely agree with you from data persistence view point. My idea was to to leave the current make cleandocker behavior as it is and offer an option to skip the deletetion of the persistent volumes.

On the second thought, taking in account all the complaints about data loss, I would by default skip the volume deletion.

I hope the possible running of the same command twice by the @mainflux/contributors won't be a problem.

I will prepare a new pr

@chombium chombium deleted the MF-655 branch April 20, 2019 11:37
davide83 pushed a commit to davide83/mainflux that referenced this pull request May 13, 2019
* added filter and a switch for volume deletion

Signed-off-by: Jovan Kostovski <chombium@gmail.com>

* added persistent volume configuration

Signed-off-by: Jovan Kostovski <chombium@gmail.com>
rugwirobaker pushed a commit to rugwirobaker/mainflux that referenced this pull request Jun 26, 2019
* added filter and a switch for volume deletion

Signed-off-by: Jovan Kostovski <chombium@gmail.com>

* added persistent volume configuration

Signed-off-by: Jovan Kostovski <chombium@gmail.com>
manuio pushed a commit that referenced this pull request Oct 12, 2020
* added filter and a switch for volume deletion

Signed-off-by: Jovan Kostovski <chombium@gmail.com>

* added persistent volume configuration

Signed-off-by: Jovan Kostovski <chombium@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Correct usage of docker persistent volumes
6 participants