Commit 1b1ced8
committed
[SPARK-59296][CORE][FOLLOWUP] Address round-2 review: hoist UserCredentialManager lifecycle into SupportsDelegationToken and tighten local-mode wiring
Addresses the second round of review on PR #58737:
- Hoist the UserCredentialManager lifecycle (field + setup/stopUserCredentialManager) into
SupportsDelegationToken, next to the sibling HadoopDelegationTokenManager, so both
CoarseGrainedSchedulerBackend and LocalSchedulerBackend share one implementation. The two
backends now differ only via a `propagateUserCredentials(version, credentials)` hook: CGSB
updates the driver store then broadcasts via its DriverEndpoint; LocalSchedulerBackend (no remote
executors) updates the shared store directly. The trait gains an abstract `scheduler` accessor
(both backends already hold `scheduler`).
- Bind the manager to `scheduler.sc.conf` (the live SparkConf) rather than the constructor `conf`.
LocalSchedulerBackend receives `sc.getConf`, a clone; the resolution-time fallback in
UserCredentialManager.start() (which applies provider-declared spark.* keys for schemes the
selection phase could not) wrote into that clone and never reached sc.conf, so it silently did
nothing in local mode while working in cluster mode. Using scheduler.sc.conf restores parity.
- Use `scheduler.sc.env.userCredentials` (this backend's own env store) instead of the global
SparkEnv.get, so a renewal that outlives this SparkContext cannot write into a different
SparkContext's store created later in the same JVM.
- Drop the now-redundant separate initial synchronous store: start() invokes the callback
synchronously, and for both backends the callback updates the store, so foreach(_.start()) is
enough (CGSB's callback still updates the store synchronously before the async broadcast, keeping
the no-null-window guarantee).
- LocalSchedulerBackend.stop(): guard localEndpoint (ask() only throws synchronously when
localEndpoint is still null, i.e. a launcher stop before start()) and stop the managers in a
finally, matching CGSB. Add a `stopped` flag checked in start() so a stop(KILLED) arriving before
start() does not bring up the renewal thread (network I/O) on an already-killed app.
- Tests/docs: strengthen the selection/resolution ordering test to assert init count 0 after
selection and 1 only after start() (proving loader reuse, not just loader idempotency), using the
test-only 4-arg constructor and a mock ingestor (no token file) with loader.closeAll() in finally;
build JWTs with jjwt and use withTempDir in LocalSchedulerBackendSuite; drop a duplicate
applyProviderProperties test; and note LocalSchedulerBackend in the UserCredentialManager class
scaladoc.1 parent e07a9b2 commit 1b1ced8
6 files changed
Lines changed: 166 additions & 198 deletions
File tree
- core/src
- main/scala/org/apache/spark
- deploy/security
- scheduler
- cluster
- local
- test/scala/org/apache/spark
- deploy/security
- scheduler/local
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
Lines changed: 46 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
33 | 47 | | |
34 | 48 | | |
35 | 49 | | |
| |||
42 | 56 | | |
43 | 57 | | |
44 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
45 | 68 | | |
46 | 69 | | |
47 | 70 | | |
| |||
75 | 98 | | |
76 | 99 | | |
77 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
78 | 123 | | |
Lines changed: 14 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
57 | | - | |
| 56 | + | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
| |||
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | 146 | | |
151 | 147 | | |
152 | 148 | | |
| |||
1252 | 1248 | | |
1253 | 1249 | | |
1254 | 1250 | | |
1255 | | - | |
| 1251 | + | |
1256 | 1252 | | |
1257 | 1253 | | |
1258 | 1254 | | |
1259 | 1255 | | |
1260 | 1256 | | |
1261 | 1257 | | |
1262 | | - | |
1263 | | - | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
1264 | 1266 | | |
1265 | | - | |
1266 | | - | |
1267 | | - | |
1268 | | - | |
1269 | | - | |
1270 | | - | |
1271 | | - | |
1272 | | - | |
1273 | | - | |
1274 | | - | |
1275 | | - | |
1276 | | - | |
1277 | | - | |
1278 | | - | |
1279 | | - | |
1280 | | - | |
1281 | | - | |
1282 | | - | |
1283 | | - | |
1284 | | - | |
1285 | | - | |
1286 | | - | |
1287 | | - | |
1288 | | - | |
1289 | | - | |
1290 | | - | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
1291 | 1271 | | |
1292 | 1272 | | |
1293 | 1273 | | |
| |||
Lines changed: 40 additions & 52 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
121 | 126 | | |
122 | 127 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | 128 | | |
130 | 129 | | |
131 | 130 | | |
| |||
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
147 | | - | |
148 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
149 | 151 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
156 | 158 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
186 | 162 | | |
187 | 163 | | |
188 | 164 | | |
| |||
198 | 174 | | |
199 | 175 | | |
200 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
201 | 183 | | |
202 | 184 | | |
203 | 185 | | |
| |||
246 | 228 | | |
247 | 229 | | |
248 | 230 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
256 | 244 | | |
257 | 245 | | |
258 | 246 | | |
| |||
0 commit comments