Skip to content

Commit 3c75022

Browse files
committed
More emphasis on local user; improved error reporting
1 parent 23e7b60 commit 3c75022

File tree

6 files changed

+27
-17
lines changed

6 files changed

+27
-17
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,11 @@ COPY --from=builder /code/build/third-party/* /usr/lib/
3838
COPY --from=builder /code/build/scripts/* /usr/bin/
3939
COPY --from=builder /code/build/libs/* /usr/lib/
4040

41+
RUN mkdir /output \
42+
&& chown 101:101 /output
43+
44+
VOLUME ["/output"]
45+
46+
USER 101:101
47+
4148
ENTRYPOINT ["radar-output-restructure"]

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ It supports data written by [RADAR HDFS sink connector](https://github.com/RADAR
77

88
## Upgrade instructions
99

10+
When upgrading to version 1.2.0, please follow the following instructions:
11+
12+
- When using local target storage, ensure that:
13+
1. it is writable by the user 101, or change the runtime user using the docker command-line flag `--user` to a user that can write to the target storage and
14+
2. local storage properties `userId` and `groupId` are set to values that can write to the target storage.
15+
1016
When upgrading to version 1.0.0 or later from version 0.6.0 please follow the following instructions:
1117

1218
- This package now relies on Redis for locking and offset management. Please install Redis or use
@@ -36,9 +42,11 @@ When upgrading to version 1.0.0 or later from version 0.6.0 please follow the fo
3642
target:
3743
type: local
3844
local:
39-
# User ID to write data as
45+
# User ID to write data as. This only works when explicitly setting
46+
# the runtime user to root.
4047
userId: 123
41-
# Group ID to write data as
48+
# Group ID to write data as. This only works when explicitly setting
49+
# the runtime user to root.
4250
groupId: 123
4351
```
4452

@@ -65,11 +73,6 @@ This package is available as docker image [`radarbase/radar-output-restructure`]
6573
docker run --rm -t --network hadoop -v "$PWD/output:/output" radarbase/radar-output-restructure:1.1.5 -n hdfs-namenode -o /output /myTopic
6674
```
6775

68-
if your docker cluster is running in the `hadoop` network and your output directory should be `./output`. Note that to run this in production this should be run as a non-root user. If local output is used, specify the user that the data should be written as both in the local storage configuration `target: {local: {userId: <MyUid>, groupId: <MyGroupId>}}` and also in the docker command line or docker-compose configuration:
69-
```shell
70-
docker run --rm -t --network hadoop -v "$PWD/output:/output" --user <MyUserId> --group-add <MyGroupId> radarbase/radar-output-restructure:1.1.5 -n hdfs-namenode -o /output /myTopic
71-
```
72-
7376
## Command line usage
7477

7578
When the application is installed, it can be used as follows:

restructure.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ target:
5858
container: MyTargetContainer
5959
# only actually needed if target type is local
6060
local:
61-
userId: 1000 # write as regular user, use -1 to use current user (default).
62-
groupId: 100 # write as regular group, use -1 to use current user (default).
61+
userId: 1000 # write as user ID 1000, use -1 to use current user (default).
62+
groupId: 100 # write as group ID 100, use -1 to use current user (default).
6363

6464
# Redis configuration
6565
# @since: 0.7.0

src/main/java/org/radarbase/output/Application.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Application(
198198
logger.error("Failed to initialize plugins", ex)
199199
exitProcess(1)
200200
} catch (e: IllegalStateException) {
201-
logger.error("Cannot process configuration", e)
201+
logger.error("Invalid configuration: {}", e.message)
202202
exitProcess(1)
203203
}
204204

src/main/java/org/radarbase/output/config/RestructureConfig.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ data class RestructureConfig(
3131
/** Topic exceptional handling. */
3232
val topics: Map<String, TopicConfig> = emptyMap(),
3333
/** Source data resource configuration. */
34-
val source: ResourceConfig = ResourceConfig("hdfs", hdfs = HdfsConfig()),
34+
val source: ResourceConfig = ResourceConfig("s3"),
3535
/** Target data resource configration. */
3636
val target: ResourceConfig = ResourceConfig("local", local = LocalConfig()),
3737
/** Redis configuration for synchronization and storing offsets. */
@@ -284,10 +284,10 @@ data class ResourceConfig(
284284
sourceType = type.toResourceType()
285285

286286
when(sourceType) {
287-
ResourceType.S3 -> checkNotNull(s3)
288-
ResourceType.HDFS -> checkNotNull(hdfs).also { it.validate() }
289-
ResourceType.LOCAL -> checkNotNull(local)
290-
ResourceType.AZURE -> checkNotNull(azure)
287+
ResourceType.S3 -> checkNotNull(s3) { "No S3 configuration provided." }
288+
ResourceType.HDFS -> checkNotNull(hdfs) { "No HDFS configuration provided." }.also { it.validate() }
289+
ResourceType.LOCAL -> checkNotNull(local) { "No local configuration provided." }
290+
ResourceType.AZURE -> checkNotNull(azure) { "No Azure configuration provided." }
291291
}
292292
}
293293
}
@@ -301,7 +301,7 @@ fun String.toResourceType() = when(toLowerCase()) {
301301
"hdfs" -> ResourceType.HDFS
302302
"local" -> ResourceType.LOCAL
303303
"azure" -> ResourceType.AZURE
304-
else -> throw IllegalArgumentException("Unknown resource type $this, choose s3, hdfs or local")
304+
else -> throw IllegalStateException("Unknown resource type $this, choose s3, hdfs or local")
305305
}
306306

307307
data class LocalConfig(

src/main/java/org/radarbase/output/target/TargetStorageFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class TargetStorageFactory(private val config: ResourceConfig) {
88
ResourceType.S3 -> S3TargetStorage(config.s3!!)
99
ResourceType.LOCAL -> LocalTargetStorage(config.local!!)
1010
ResourceType.AZURE -> AzureTargetStorage(config.azure!!)
11-
else -> throw IllegalArgumentException("Cannot create storage driver for ${config.sourceType}")
11+
else -> throw IllegalStateException("Cannot create storage driver for ${config.sourceType}")
1212
}
1313
}

0 commit comments

Comments
 (0)