mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(kinesisanalytics): make the savepoints volume writable by the Flink user (#4490)
* fix(kinesisanalytics): make the savepoints volume writable by the Flink user Docker creates the savepoints named volume root:root, while the official apache/flink images run Flink as uid/gid 9999, so the JobManager could not create /opt/flink/savepoints and every CreateApplicationSnapshot ended FAILED. Initialise the volume root through ContainerLifecycleManager.ensureSharedVolume, chowning it to 9999:9999 before the JobManager starts. Closes #4443 * fix(core): reinitialise shared volume ownership when the volume is recreated ensureSharedVolume memoised the one-off chown per volume name for the whole process, so a volume removed and recreated under the same name (DeleteApplication in memory mode, or docker volume rm) came back root:root without being initialised again. Drop the memo whenever the volume has just been created.
This commit is contained in:
1 parent
4032efd9c7
commit
1b176bda0d
4 files changed
+101
-10
No files matched your search
+18
-7
@@ -468,13 +468,20 @@ public class ContainerLifecycleManager {
|
||||
* {@code --filter label=floci_emulator=floci-aws} (this emulator only) work.
|
||||
*/
|
||||
public void ensureVolume(String volumeName) {
|
||||
if (!volumeExists(volumeName)) {
|
||||
dockerClient.createVolumeCmd()
|
||||
.withName(volumeName)
|
||||
.withLabels(ContainerStorageHelper.defaultLabels(config))
|
||||
.exec();
|
||||
LOG.debugv("Created volume {0}", volumeName);
|
||||
createVolumeIfAbsent(volumeName);
|
||||
}
|
||||
|
||||
/** Creates the named volume when it is missing; returns whether it was created. */
|
||||
private boolean createVolumeIfAbsent(String volumeName) {
|
||||
if (volumeExists(volumeName)) {
|
||||
return false;
|
||||
}
|
||||
dockerClient.createVolumeCmd()
|
||||
.withName(volumeName)
|
||||
.withLabels(ContainerStorageHelper.defaultLabels(config))
|
||||
.exec();
|
||||
LOG.debugv("Created volume {0}", volumeName);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -511,7 +518,11 @@ public class ContainerLifecycleManager {
|
||||
*/
|
||||
public void ensureSharedVolume(String volumeName, OptionalInt ownerUid, OptionalInt ownerGid,
|
||||
Optional<String> rootPermissions, String initImage) {
|
||||
ensureVolume(volumeName);
|
||||
// A volume created now is root:root 0755 again, so a memo left by a volume of the same name
|
||||
// that was removed since (e.g. DeleteApplication, docker volume rm) is stale.
|
||||
if (createVolumeIfAbsent(volumeName)) {
|
||||
initializedSharedVolumes.remove(volumeName);
|
||||
}
|
||||
if (rootPermissions.isEmpty() && ownerUid.isEmpty() && ownerGid.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
+9
-2
@@ -40,6 +40,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -65,6 +66,8 @@ public class FlinkContainerManager {
|
||||
private static final Logger LOG = Logger.getLogger(FlinkContainerManager.class);
|
||||
private static final int JOBMANAGER_REST_PORT = 8081;
|
||||
private static final String SAVEPOINTS_MOUNT = "/opt/flink/savepoints";
|
||||
private static final int FLINK_UID = 9999;
|
||||
private static final int FLINK_GID = 9999;
|
||||
|
||||
private final ContainerBuilder containerBuilder;
|
||||
private final ContainerLifecycleManager lifecycleManager;
|
||||
@@ -178,8 +181,12 @@ public class FlinkContainerManager {
|
||||
// Stop/StartApplication cycle — stopCluster() removes the JobManager container, but this
|
||||
// volume is only removed on DeleteApplication (removeSavepointsVolume), mirroring how other
|
||||
// Docker-backed services keep persistent data outside the container lifecycle.
|
||||
ContainerStorageHelper.applyNamedVolume(jmSpec, lifecycleManager,
|
||||
resolveVolumeName(app), SAVEPOINTS_MOUNT);
|
||||
// Docker creates the volume root:root, but the official apache/flink images run Flink as
|
||||
// uid/gid 9999, so the volume root is chowned to that user before the JobManager starts.
|
||||
String savepointsVolume = resolveVolumeName(app);
|
||||
lifecycleManager.ensureSharedVolume(savepointsVolume, OptionalInt.of(FLINK_UID),
|
||||
OptionalInt.of(FLINK_GID), Optional.empty(), config.storage().efs().initImage());
|
||||
jmSpec.withNamedVolume(savepointsVolume, SAVEPOINTS_MOUNT);
|
||||
if (!containerDetector.isRunningInContainer()) {
|
||||
jmSpec.withDynamicPort(JOBMANAGER_REST_PORT);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user