You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
4.9 KiB

3 years ago
  1. # IPO Outline
  2. This document outlines the basic Input-Process-Output flow of the volume plugin.
  3. ## Environment
  4. The LizardFS Docker plugin implements the [Docker Plugin API](https://docs.docker.com/engine/extend/plugin_api/). The Inputs to the program are requests made by the Docker daemon to the plugin. Request such as `Plugin.Activate`, and `VolumeDriver.Create`, will be sent by the Docker daemon to the the unix socket, `/run/docker/plugins/lizardfs.sock`, and the LizardFS Docker plugin will process the request, take the required actions, and respond with an appropriate response.
  5. ## Requests
  6. These are the requests that Docker will make to the plugin over the Unix socket. All requests will be HTTP POST requests and may contain a JSON payload. The plugin's response to the request should also be a JSON payload if applicable. Details about these requests can be found in the Docker documentation for the [Plugins API](https://docs.docker.com/engine/extend/plugin_api/) and the [Volume Plugin API](https://docs.docker.com/engine/extend/plugins_volume/#volumedrivercapabilities).
  7. ### /Plugin.Activate
  8. #### Input
  9. Empty payload.
  10. #### Process
  11. * Mount a subpath of the LizardFS filesystem specified by the `REMOTE_PATH` environment variable ( `/docker/volumes` by default) to `/mnt/lizardfs`. This is where the docker volumes will be stored. The `/mnt/lizardfs` directory will be referred to as the "volume root" throughout this document.
  12. #### Output
  13. ```json
  14. {
  15. "Implements": ["VolumeDriver"]
  16. }
  17. ```
  18. ### /VolumeDriver.Create
  19. #### Input
  20. ```json
  21. {
  22. "Name": "volume_name",
  23. "Opts": {
  24. "ReplicationGoal": "replication_goal_number_or_name"
  25. }
  26. }
  27. ```
  28. #### Process
  29. * Create sub-directory of volume root with the given `Name`. For example, `/mnt/lizardfs/volume_name`.
  30. * Use `lizardfs setgoal` to set the replication goal for that Docker Volume to the value specified in the `Opts` ( if specified ).
  31. #### Output
  32. Error message ( if one occurred ).
  33. ```json
  34. {
  35. "Err": ""
  36. }
  37. ```
  38. ### /VolumeDriver.Remove
  39. #### Input
  40. ```json
  41. {
  42. "Name": "volume_name"
  43. }
  44. ```
  45. #### Process
  46. * Delete the directory in the volume root with the given `Name`. For example, `/mnt/lizardfs/volume_name`.
  47. #### Output
  48. Error message ( if one occurred ).
  49. ```json
  50. {
  51. "Err": ""
  52. }
  53. ```
  54. ### /VolumeDriver.Mount
  55. #### Input
  56. ```json
  57. {
  58. "Name": "volume_name",
  59. "ID": "b87d7442095999a92b65b3d9691e697b61713829cc0ffd1bb72e4ccd51aa4d6c"
  60. }
  61. ```
  62. #### Process
  63. * Create a directory outside of the LizardFS root mountpoint using the given `Name`, such as `/mnt/docker-volumes/volume_name`.
  64. * Mount the subpath of the LizardFS filesystem ( for example, `/docker/volumes/volume_name` ) to the newly created mountpoint.
  65. * Add the `ID` to the list of containers that have mounted `Name` in the `mounted_volumes` Javascript object. This variable is used to keep track of which containers have mounted the volume.
  66. #### Output
  67. We need to tell Docker where we mounted the volume or give an error message if there was a problem.
  68. ```json
  69. {
  70. "Mountpoint": "/mnt/docker-volumes/volume_name",
  71. "Err": ""
  72. }
  73. ```
  74. ### /VolumeDriver.Path
  75. #### Input
  76. ```json
  77. {
  78. "Name": "volume_name"
  79. }
  80. ```
  81. #### Process
  82. * Determine the path at which the volume is mounted based on the `Name`.
  83. #### Output
  84. Error message ( if one occurred ).
  85. ```json
  86. {
  87. "Mountpoint": "/mnt/docker-volumes/volume_name",
  88. "Err": ""
  89. }
  90. ```
  91. ### /VolumeDriver.Unmount
  92. #### Input
  93. ```json
  94. {
  95. "Name": "volume_name",
  96. "ID": "b87d7442095999a92b65b3d9691e697b61713829cc0ffd1bb72e4ccd51aa4d6c"
  97. }
  98. ```
  99. #### Process
  100. * Remove the `ID` from the list of containers that have mounted `Name` in `mounted_volumes` Javascript variable.
  101. * If there are no containers in the list anymore, unmount the `/mnt/docker-volumes/volume_name` because it no longer needs to be mounted.
  102. #### Output
  103. Error message ( if one occurred ).
  104. ```json
  105. {
  106. "Err": ""
  107. }
  108. ```
  109. ### /VolumeDriver.Get
  110. #### Input
  111. ```json
  112. {
  113. "Name": "volume_name"
  114. }
  115. ```
  116. #### Process
  117. * Make sure the volume exists: check that the directory of the name `volume_name` exists and that the process has read-write access.
  118. * If the volume is mounted, return the mountpoint as well as the name.
  119. #### Output
  120. Return the volume name
  121. ```json
  122. {
  123. "Volume": {
  124. "Name": "volume_name",
  125. "Mountpoint": "/mnt/docker-volumes/volume_name",
  126. },
  127. "Err": "Error if directory doesn't exist or we don't have read-write access to it."
  128. }
  129. ```
  130. ### /VolumeDriver.List
  131. #### Input
  132. ```json
  133. {}
  134. ```
  135. #### Process
  136. * Get a list of the directories in the volume root: `/mnt/lizardfs/`.
  137. * If the volume is mounted on the host, provide the `Mountpoint`.
  138. #### Output
  139. Error message ( if one occurred ).
  140. ```json
  141. {
  142. "Volumes": [
  143. {
  144. "Name": "volume_name",
  145. "Mountpoint": "/mnt/docker-volumes/volume_name"
  146. }
  147. ],
  148. "Err": ""
  149. }
  150. ```
  151. ### /VolumeDriver.Capabilities
  152. #### Input
  153. ```json
  154. {}
  155. ```
  156. #### Process
  157. Not applicable.
  158. #### Output
  159. ```json
  160. {
  161. "Capabilities": {
  162. "Scope": "global"
  163. }
  164. }
  165. ```