Skip to content

Commit dc4f8d3

Browse files
author
Arthur Rand
authored
[SPARK-612] Change user back to root, but test with nobody (apache#256)
* smoke test * use nobody in tests * update docs a little
1 parent 1a3509f commit dc4f8d3

File tree

4 files changed

+39
-21
lines changed

4 files changed

+39
-21
lines changed

docs/limitations.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,31 @@ featureMaturity:
88

99
---
1010

11-
* Mesosphere does not provide support for Spark app development, such as writing a Python app to process data from Kafka or writing Scala code to process data from HDFS.
11+
* Mesosphere does not provide support for Spark app development, such as writing a Python app to process data from
12+
Kafka or writing Scala code to process data from HDFS.
1213

13-
* Spark jobs run in Docker containers. The first time you run a Spark job on a node, it might take longer than you expect because of the `docker pull`.
14+
* Spark jobs run in Docker containers. The first time you run a Spark job on a node, it might take longer than you
15+
expect because of the `docker pull`.
1416

15-
* DC/OS Apache Spark only supports running the Spark shell from within a DC/OS cluster. See the Spark Shell section for more information. For interactive analytics, we recommend Zeppelin, which supports visualizations and dynamic dependency management.
17+
* DC/OS Apache Spark only supports running the Spark shell from within a DC/OS cluster. See the Spark Shell section
18+
for more information. For interactive analytics, we recommend Zeppelin, which supports visualizations and dynamic
19+
dependency management.
1620

17-
* With Spark SSL/TLS enabled,
18-
if you specify environment-based secrets with `spark.mesos.[driver|executor].secret.envkeys`,
19-
the keystore and truststore secrets will also show up as environment-based secrets,
20-
due to the way secrets are implemented. You can ignore these extra environment variables.
21+
* With Spark SSL/TLS enabled, if you specify environment-based secrets with
22+
`spark.mesos.[driver|executor].secret.envkeys, the keystore and truststore secrets will also show up as
23+
environment-based secrets, due to the way secrets are implemented. You can ignore these extra environment variables.
2124

22-
* When using Kerberos and HDFS, the Spark Driver generates delegation tokens and distributes them to it's Executors via RPC. Authentication of the Executors with the Driver is done with a [shared secret][https://spark.apache.org/docs/latest/security.html#spark-security]. Without authentication, it is possible for executor containers to register with the Driver and retrieve the delegation tokens. Currently, for Spark on Mesos this requires manually setting up the default configuration in Spark to use authentication and setting the secret. Mesosphere is actively working to make this an automated and secure process in future releases.
25+
* When using Kerberos and HDFS, the Spark Driver generates delegation tokens and distributes them to it's Executors
26+
via RPC. Authentication of the Executors with the Driver is done with a [shared
27+
secret][https://spark.apache.org/docs/latest/security.html#spark-security]. Without authentication, it is possible
28+
for executor containers to register with the Driver and retrieve the delegation tokens. To secure delegation token
29+
distribution, use the `--executor-auth-secret` option.
2330

24-
* Spark runs all of its components in Docker containers. Since the Docker image contains a full Linux userspace with its own `/etc/users` file, it is possible for the default service user `nobody` to have a different UID inside the container than on the host system. Although user `nobody` has UID 65534 by convention on many systems, this is not always the case. As Mesos does not perform UID mapping between Linux user namespaces, specifying a service user of `nobody` in this case will cause access failures when the container user attempts to open or execute a filesystem resource owned by a user with a different UID, preventing the service from launching. If the hosts in your cluster have a UID for `nobody` other than 65534, you will need to specify a service user of root to run DC/OS Spark successfully.
31+
* Spark runs all of its components in Docker containers. Since the Docker image contains a full Linux userspace with
32+
its own `/etc/users` file, it is possible for the user `nobody` to have a different UID inside the
33+
container than on the host system. Although user `nobody` has UID 65534 by convention on many systems, this is not
34+
always the case. As Mesos does not perform UID mapping between Linux user namespaces, specifying a service user of
35+
`nobody` in this case will cause access failures when the container user attempts to open or execute a filesystem
36+
resource owned by a user with a different UID, preventing the service from launching. If the hosts in your cluster
37+
have a UID for `nobody` other than 65534, you will need to maintain the default use (`root`) to run DC/OS Spark
38+
successfully.

tests/test_spark.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,9 @@ def make_credential_secret(envvar, secret_path):
236236
@pytest.mark.smoke
237237
def test_marathon_group():
238238
app_id = utils.FOLDERED_SPARK_APP_NAME
239-
options = {"service": {"name": app_id}}
240-
utils.require_spark(options=options, service_name=app_id)
239+
utils.require_spark(service_name=app_id, marathon_group=app_id)
241240
test_sparkPi(app_name=app_id)
242241
LOGGER.info("Uninstalling app_id={}".format(app_id))
243-
#shakedown.uninstall_package_and_wait(SPARK_PACKAGE_NAME, app_id)
244-
245242

246243

247244
@pytest.mark.sanity

tests/utils.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ def streaming_job_running(job_name):
6262
return len([x for x in f.dict()["tasks"] if x["state"] == "TASK_RUNNING"]) > 0
6363

6464

65-
def require_spark(options=None, service_name=None, use_hdfs=False, use_history=False):
65+
def require_spark(service_name=None, use_hdfs=False, use_history=False, marathon_group=None,
66+
strict_mode=is_strict(), user="nobody"):
6667
LOGGER.info("Ensuring Spark is installed.")
67-
68-
_require_package(SPARK_PACKAGE_NAME, service_name, _get_spark_options(options, use_hdfs, use_history))
68+
_require_package(
69+
SPARK_PACKAGE_NAME,
70+
service_name,
71+
_get_spark_options(use_hdfs, use_history, marathon_group, strict_mode, user))
6972
_wait_for_spark(service_name)
7073
_require_spark_cli()
7174

@@ -132,9 +135,13 @@ def no_spark_jobs(service_name):
132135
return len(driver_ips) == 0
133136

134137

135-
def _get_spark_options(options, use_hdfs, use_history):
136-
if options is None:
137-
options = {}
138+
def _get_spark_options(use_hdfs, use_history, marathon_group, strict_mode, user):
139+
options = {}
140+
options["service"] = options.get("service", {})
141+
options["service"]["user"] = user
142+
143+
if marathon_group is not None:
144+
options["service"]["name"] = marathon_group
138145

139146
if use_hdfs:
140147
options["hdfs"] = options.get("hdfs", {})
@@ -149,7 +156,7 @@ def _get_spark_options(options, use_hdfs, use_history):
149156
options["service"] = options.get("service", {})
150157
options["service"]["spark-history-server-url"] = history_url
151158

152-
if is_strict():
159+
if strict_mode:
153160
options["service"] = options.get("service", {})
154161
options["service"]["service_account"] = SPARK_SERVICE_ACCOUNT
155162
options["service"]["service_account_secret"] = SPARK_SERVICE_ACCOUNT_SECRET

universe/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"user": {
4141
"description": "Executors will run as this user.",
4242
"type": "string",
43-
"default": "nobody"
43+
"default": "root"
4444
},
4545
"docker-image": {
4646
"type": "string",

0 commit comments

Comments
 (0)