TQJADE commented on code in PR #749:
URL:
https://github.com/apache/spark-kubernetes-operator/pull/749#discussion_r3547149716
##########
docs/config_properties.md:
##########
@@ -38,9 +38,11 @@
| spark.kubernetes.operator.periodicGC.intervalSeconds | Long | 1800 | true |
Interval (in seconds) between periodic System.gc() invocations. Set to 0 or a
negative value to disable. Note that System.gc() is a no-op if JVM is started
with -XX:+DisableExplicitGC. |
| spark.kubernetes.operator.reconciler.appStatusListenerClassNames | String |
| false | Comma-separated names of SparkAppStatusListener class
implementations |
| spark.kubernetes.operator.reconciler.clusterStatusListenerClassNames |
String | | false | Comma-separated names of SparkClusterStatusListener class
implementations |
+ | spark.kubernetes.operator.reconciler.defaultRequeueIntervalSeconds |
Integer | 15 | true | Default requeue interval (in seconds) used for
short-lived requeues while waiting for a transient condition to clear, e.g.,
for the pod informer cache to catch up during the missing-driver grace period.
Distinct from spark.kubernetes.operator.reconciler.intervalSeconds, which
controls the steady-state periodic reconcile cadence. |
Review Comment:
Changed to
`spark.kubernetes.operator.reconciler.missingDriverRequeueIntervalSeconds`
##########
spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppReconcileStep.java:
##########
@@ -65,30 +67,69 @@ protected ReconcileProgress observeDriver(
final SparkAppContext context,
final SparkAppStatusRecorder statusRecorder,
final List<BaseAppDriverObserver> observers) {
- Optional<Pod> driverPodOptional = context.getDriverPod();
SparkApplication app = context.getResource();
ApplicationStatus currentStatus = app.getStatus();
- if (driverPodOptional.isPresent()) {
- List<ApplicationState> stateUpdates =
- observers.stream()
- .map(o -> o.observe(driverPodOptional.get(), app.getSpec(),
app.getStatus()))
- .filter(Optional::isPresent)
- .map(Optional::get)
- .toList();
- if (stateUpdates.isEmpty()) {
- return proceed();
- } else {
- for (ApplicationState state : stateUpdates) {
- currentStatus = currentStatus.appendNewState(state);
+ Optional<Pod> driverPodOptional = context.getDriverPod();
+
+ if (driverPodOptional.isEmpty()) {
+ Duration verifyAfter =
+
Duration.ofSeconds(SparkOperatorConf.MISSING_DRIVER_GRACE_PERIOD_SECONDS.getValue());
+ ApplicationState observedState = currentStatus.getCurrentState();
+ Instant transitionedAt =
Instant.parse(observedState.getLastTransitionTime());
+ Duration stateAge = Duration.between(transitionedAt, Instant.now());
+
+ if (stateAge.compareTo(verifyAfter) < 0) {
+ log.debug(
+ "Driver pod missing from informer cache; state {} is only {}s old,
"
+ + "deferring verification.",
+ observedState.getCurrentStateSummary(), stateAge.toSeconds());
+ return ReconcileProgress.completeAndRequeueAfter(
+
Duration.ofSeconds(SparkOperatorConf.DEFAULT_REQUEUE_INTERVAL_SECONDS.getValue()));
+ }
+
+ try {
+ Optional<Pod> liveDriver = context.getDriverPodFromApi();
+ if (liveDriver.isPresent()) {
+ log.warn(
+ "Driver pod {} missing from informer cache after {}s in state {}
but "
+ + "present on apiserver; informer is likely stale. Using
live pod "
+ + "for this reconcile.",
+ liveDriver.get().getMetadata().getName(),
+ stateAge.toSeconds(),
+ observedState.getCurrentStateSummary());
+ driverPodOptional = liveDriver;
+ } else {
+ ApplicationStatus updatedStatus =
+ currentStatus.appendNewState(driverUnexpectedRemoved());
+ return attemptStatusUpdate(
+ context, statusRecorder, updatedStatus,
completeAndImmediateRequeue());
}
- return attemptStatusUpdate(
- context, statusRecorder, currentStatus,
completeAndImmediateRequeue());
+ } catch (RuntimeException e) {
+ log.error(
Review Comment:
updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]