mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(emr): keep a primary node running on an emr-6.x image (#7800)
Once a cluster's HDFS was up, the primary node's script ran wait -n to end the container when a daemon exited. The bash of an emr-6.x image, 4.2, does not have wait -n, so the call failed at once and the node exited as soon as it was ready: every step of an emr-6.x cluster failed with "The HDFS of EMR cluster ... stopped before it was ready". The script now watches the count of daemons it started, as it already does while they start.
This commit is contained in:
1 parent
3c398103ed
commit
943efbbcc4
2 files changed
+20
-15
No files matched your search
@@ -129,16 +129,16 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
"exec setpriv --reuid=hadoop --regid=hadoop --clear-groups bash -c '"
|
||||
+ "[ -d /mnt/namenode/current ] || hdfs namenode -format -nonInteractive || exit; "
|
||||
+ "cid=$(sed -n \"s/^clusterID=//p\" /mnt/namenode/current/VERSION); "
|
||||
+ "hdfs namenode & hdfs datanode & "
|
||||
+ "hdfs namenode & hdfs datanode & n=2; "
|
||||
+ "until curl -sf -m 5 \"" + NAMENODE_JMX + "NameNodeInfo\""
|
||||
+ " | grep -q \"\\\"ClusterId\\\" : \\\"$cid\\\"\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = 2 ] || exit 1; sleep 0.2; done; "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ "until curl -sf -m 5 \"" + NAMENODE_JMX + "FSNamesystemState\""
|
||||
+ " | grep -q \"\\\"NumLiveDataNodes\\\" : 1,\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = 2 ] || exit 1; sleep 0.2; done; "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ "until curl -sf -m 5 \"" + NAMENODE_JMX + "NameNodeInfo\""
|
||||
+ " | grep -q \"\\\"Safemode\\\" : \\\"\\\"\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = 2 ] || exit 1; sleep 0.2; done; "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ "hdfs dfs -mkdir -p /tmp /user/hadoop || exit 1; "
|
||||
+ "if [ -n \"$" + HIVE_METASTORE_VARIABLE + "\" ]; then "
|
||||
+ "hdfs dfs -mkdir -p /user/hive/warehouse " + HIVE_JARS + " || exit 1; "
|
||||
@@ -156,12 +156,14 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
+ " --hiveconf datanucleus.schema.autoCreateAll=true"
|
||||
+ " --hiveconf hive.metastore.schema.verification=false"
|
||||
+ " --hiveconf hive.metastore.warehouse.dir=hdfs://$FLOCI_HDFS_HOST:8020/user/hive/warehouse"
|
||||
+ " \"${site[@]}\" & "
|
||||
+ " \"${site[@]}\" & n=$((n + 1)); "
|
||||
+ "until (exec 3<>/dev/tcp/127.0.0.1/" + HIVE_METASTORE_PORT + ") 2>/dev/null; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = 3 ] || exit 1; sleep 0.2; done; "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ "fi; "
|
||||
+ "touch " + HDFS_READY + "; "
|
||||
+ "wait -n; rm -f " + HDFS_READY + "; kill $(jobs -rp) 2>/dev/null; exit 1'");
|
||||
// Not wait -n: an emr-6.x image's bash, 4.2, does not have it.
|
||||
+ "while [ \"$(jobs -rp | wc -l)\" = $n ]; do sleep 1; done; rm -f " + HDFS_READY
|
||||
+ "; kill $(jobs -rp) 2>/dev/null; exit 1'");
|
||||
|
||||
// One start at a time in a namespace the steps share, whatever the cluster, as it holds one HDFS.
|
||||
private final Object sharedNamespaceStarts = new Object();
|
||||
|
||||
@@ -164,10 +164,11 @@ class EmrClusterStorageTest {
|
||||
// The NameNode answering on its port is its own, the one its format gave the ClusterId, not another
|
||||
// cluster's sharing its namespace.
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(String.join(" ",
|
||||
"cid=$(sed -n \"s/^clusterID=//p\" /mnt/namenode/current/VERSION); hdfs namenode & hdfs datanode &",
|
||||
"cid=$(sed -n \"s/^clusterID=//p\" /mnt/namenode/current/VERSION);"
|
||||
+ " hdfs namenode & hdfs datanode & n=2;",
|
||||
"until curl -sf -m 5 \"http://127.0.0.1:9870/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo\"",
|
||||
"| grep -q \"\\\"ClusterId\\\" : \\\"$cid\\\"\"; do",
|
||||
"[ \"$(jobs -rp | wc -l)\" = 2 ] || exit 1; sleep 0.2; done;"))));
|
||||
"[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done;"))));
|
||||
// The image is there before the start's deadline.
|
||||
verify(lifecycle).resolveImageForLaunch(IMAGE, ImagePullBehavior.PREFER_CACHED, null);
|
||||
// Ready once the DataNode has joined and the NameNode has left safe mode, as its JMX says; a daemon that
|
||||
@@ -175,13 +176,15 @@ class EmrClusterStorageTest {
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(String.join(" ",
|
||||
"until curl -sf -m 5 \"http://127.0.0.1:9870/jmx?qry=Hadoop:service=NameNode,name=FSNamesystemState\"",
|
||||
"| grep -q \"\\\"NumLiveDataNodes\\\" : 1,\"; do",
|
||||
"[ \"$(jobs -rp | wc -l)\" = 2 ] || exit 1; sleep 0.2; done;",
|
||||
"[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done;",
|
||||
"until curl -sf -m 5 \"http://127.0.0.1:9870/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo\"",
|
||||
"| grep -q \"\\\"Safemode\\\" : \\\"\\\"\"; do",
|
||||
"[ \"$(jobs -rp | wc -l)\" = 2 ] || exit 1; sleep 0.2; done;",
|
||||
"[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done;",
|
||||
"hdfs dfs -mkdir -p /tmp /user/hadoop || exit 1;"))
|
||||
&& entrypoint.get(2).contains(String.join(" ", "fi;", "touch /tmp/floci-hdfs-ready;",
|
||||
"wait -n; rm -f /tmp/floci-hdfs-ready; kill $(jobs -rp) 2>/dev/null; exit 1'"))));
|
||||
// Not wait -n, which an emr-6.x image's bash, 4.2, does not have.
|
||||
"while [ \"$(jobs -rp | wc -l)\" = $n ]; do sleep 1; done;",
|
||||
"rm -f /tmp/floci-hdfs-ready; kill $(jobs -rp) 2>/dev/null; exit 1'"))));
|
||||
// A cluster without Hive runs no metastore service, and its primary node does not talk to Floci.
|
||||
verify(spec, never()).withEnv(eq("FLOCI_HIVE_METASTORE"), anyString());
|
||||
verify(spec, never()).withJavaTrustStore();
|
||||
@@ -295,9 +298,9 @@ class EmrClusterStorageTest {
|
||||
+ "databaseName=/mnt/var/lib/hive/metastore_db;create=true\"")
|
||||
&& entrypoint.get(2).contains(
|
||||
"hive.metastore.warehouse.dir=hdfs://$FLOCI_HDFS_HOST:8020/user/hive/warehouse"
|
||||
+ " \"${site[@]}\" &")
|
||||
+ " \"${site[@]}\" & n=$((n + 1));")
|
||||
&& entrypoint.get(2).contains("until (exec 3<>/dev/tcp/127.0.0.1/9083) 2>/dev/null; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = 3 ] || exit 1; sleep 0.2; done; "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ "fi; touch /tmp/floci-hdfs-ready")));
|
||||
|
||||
// The session goes with the container.
|
||||
@@ -593,7 +596,7 @@ class EmrClusterStorageTest {
|
||||
"[ -z \"$FLOCI_HIVE_METASTORE_SITE\" ] || mapfile -t site <<< \"$FLOCI_HIVE_METASTORE_SITE\"; cd /tmp;")
|
||||
&& entrypoint.get(2).contains(
|
||||
"hive.metastore.warehouse.dir=hdfs://$FLOCI_HDFS_HOST:8020/user/hive/warehouse"
|
||||
+ " \"${site[@]}\" &")));
|
||||
+ " \"${site[@]}\" & n=$((n + 1));")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user