Skip to content

Commit ebf39ae

Browse files
robkooperlmarini
andauthored
storage fixes (#243)
* storage fixes If storage was enabled in .env it was not reflected correctly in the docker-compose file add storage information to api/status * only return detailed info if superadmin Co-authored-by: Luigi Marini <[email protected]>
1 parent 61da3d8 commit ebf39ae

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
### Fixed
1010
- When uploading a file, it would ignore any extractors marked disabled at the space level. [#246](https://github.com/clowder-framework/clowder/issues/246)
1111
- Added index for comments, will speed up index creation
12+
- If using S3 storage in docker, it was not reflected correctly in the docker-compose file
13+
14+
### Added
15+
- Status endpoint will now show what storage is used
1216

1317
### Fixed
1418
- Docker image for mongo-init now based on python:3.7-slim reduces size

app/api/Status.scala

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package api
22

33
import javax.inject.Inject
4-
5-
import play.api.Logger
4+
import play.api.{Logger, Play}
65
import models.User
76
import play.api.Play._
87
import play.api.libs.json.{JsValue, Json}
98
import services._
109
import services.mongodb.MongoSalatPlugin
10+
import services.s3.S3ByteStorageService
1111

1212
import scala.collection.mutable
1313

@@ -35,6 +35,7 @@ class Status @Inject()(spaces: SpaceService,
3535
"version" -> getVersionInfo,
3636
"counts" -> getCounts(request.user),
3737
"plugins" -> getPlugins(request.user),
38+
"storage" -> getStorage(request.user),
3839
"extractors" -> Json.toJson(extractors.getExtractorNames(List.empty))))
3940
}
4041

@@ -138,6 +139,35 @@ class Status @Inject()(spaces: SpaceService,
138139
Json.toJson(result.toMap[String, JsValue])
139140
}
140141

142+
def getStorage(user: Option[User]): JsValue = {
143+
val config = Play.current.configuration
144+
val result = new mutable.HashMap[String, String]()
145+
146+
ByteStorageService.storage.getClass.getName match {
147+
case "services.mongodb.MongoDBByteStorage" => {
148+
result.put("location", "mongo")
149+
}
150+
case "services.filesystem.DiskByteStorageService" => {
151+
result.put("location", "disk")
152+
if (Permission.checkServerAdmin(user)) {
153+
result.put("path", config.getString("clowder.diskStorage.path").getOrElse[String]("unknown"))
154+
}
155+
}
156+
case "services.s3.S3ByteStorageService" => {
157+
result.put("location", "s3")
158+
if (Permission.checkServerAdmin(user)) {
159+
result.put("endpoint", config.getString(S3ByteStorageService.ServiceEndpoint).getOrElse[String]("unknown"))
160+
result.put("region", config.getString(S3ByteStorageService.Region).getOrElse[String]("unknown"))
161+
result.put("bucket", config.getString(S3ByteStorageService.BucketName).getOrElse[String]("unknown"))
162+
}
163+
}
164+
case name => {
165+
result.put("location", name)
166+
}
167+
}
168+
Json.toJson(result.toMap[String, String])
169+
}
170+
141171
def getCounts(user: Option[User]): JsValue = {
142172
val counts = appConfig.getIndexCounts()
143173
// TODO: Revisit this check as it is currently too slow

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ services:
6767
- RABBITMQ_CLOWDERURL=${RABBITMQ_CLOWDERURL:-http://clowder:9000}
6868
- SMTP_MOCK=${SMTP_MOCK:-true}
6969
- SMTP_SERVER=${SMTP_SERVER:-smtp}
70+
- CLOWDER_STORAGE=${CLOWDER_STORAGE:-services.filesystem.DiskByteStorageService}
71+
- CLOWDER_DISKPATH=${CLOWDER_DISKPATH:-/home/clowder/data}
72+
- S3_ENDPOINT=${S3_ENDPOINT:-http://minio:9000}
73+
- S3_BUCKET=${S3_BUCKET:-clowder}
74+
- S3_ACCESS_KEY=${S3_ACCESS_KEY:-clowder}
75+
- S3_SECRET_KEY=${S3_SECRET_KEY:-catsarecute}
7076
labels:
7177
- "traefik.enable=true"
7278
- "traefik.backend=clowder"

0 commit comments

Comments
 (0)