Skip to content

Commit e219987

Browse files
committed
Eliminate unused returned error in submitSparkApplication
Signed-off-by: Shingo Omura <[email protected]>
1 parent 602be42 commit e219987

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

internal/controller/sparkapplication/controller.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func (r *Reconciler) reconcileNewSparkApplication(ctx context.Context, req ctrl.
297297
}
298298
app := old.DeepCopy()
299299

300-
_ = r.submitSparkApplication(ctx, app)
300+
r.submitSparkApplication(ctx, app)
301301
if err := r.updateSparkApplicationStatus(ctx, app); err != nil {
302302
return err
303303
}
@@ -414,7 +414,7 @@ func (r *Reconciler) reconcileFailedSubmissionSparkApplication(ctx context.Conte
414414
}
415415
if timeUntilNextRetryDue <= 0 {
416416
if r.validateSparkResourceDeletion(ctx, app) {
417-
_ = r.submitSparkApplication(ctx, app)
417+
r.submitSparkApplication(ctx, app)
418418
} else {
419419
if err := r.deleteSparkResources(ctx, app); err != nil {
420420
logger.Error(err, "failed to delete resources associated with SparkApplication")
@@ -497,7 +497,7 @@ func (r *Reconciler) reconcilePendingRerunSparkApplication(ctx context.Context,
497497
logger.Info("Successfully deleted resources associated with SparkApplication", "state", app.Status.AppState.State)
498498
r.recordSparkApplicationEvent(app)
499499
r.resetSparkApplicationStatus(app)
500-
_ = r.submitSparkApplication(ctx, app)
500+
r.submitSparkApplication(ctx, app)
501501
}
502502
if err := r.updateSparkApplicationStatus(ctx, app); err != nil {
503503
return err
@@ -823,7 +823,7 @@ func (r *Reconciler) reconcileResumingSparkApplication(ctx context.Context, req
823823

824824
r.recordSparkApplicationEvent(app)
825825

826-
_ = r.submitSparkApplication(ctx, app)
826+
r.submitSparkApplication(ctx, app)
827827
if err := r.updateSparkApplicationStatus(ctx, app); err != nil {
828828
return err
829829
}
@@ -874,7 +874,8 @@ func (r *Reconciler) getSparkApplication(ctx context.Context, key types.Namespac
874874
}
875875

876876
// submitSparkApplication creates a new submission for the given SparkApplication and submits it using spark-submit.
877-
func (r *Reconciler) submitSparkApplication(ctx context.Context, app *v1beta2.SparkApplication) (submitErr error) {
877+
// The submission result are recorded in app.Status.{AppState,ExecutionAttempts}.
878+
func (r *Reconciler) submitSparkApplication(ctx context.Context, app *v1beta2.SparkApplication) {
878879
logger := log.FromContext(ctx)
879880
logger.Info("Submitting SparkApplication", "state", app.Status.AppState.State)
880881

@@ -884,6 +885,7 @@ func (r *Reconciler) submitSparkApplication(ctx context.Context, app *v1beta2.Sp
884885
app.Status.LastSubmissionAttemptTime = metav1.Now()
885886
app.Status.SubmissionAttempts = app.Status.SubmissionAttempts + 1
886887

888+
var submitErr error
887889
defer func() {
888890
if submitErr == nil {
889891
app.Status.AppState = v1beta2.ApplicationState{
@@ -901,21 +903,24 @@ func (r *Reconciler) submitSparkApplication(ctx context.Context, app *v1beta2.Sp
901903
}()
902904

903905
if err := r.configWebUI(ctx, app); err != nil {
904-
return fmt.Errorf("failed to configure web UI: %v", err)
906+
submitErr = fmt.Errorf("failed to configure web UI: %v", err)
907+
return
905908
}
906909

907910
if util.PrometheusMonitoringEnabled(app) {
908911
logger.Info("Configure Prometheus monitoring for SparkApplication")
909912
if err := configPrometheusMonitoring(ctx, app, r.client); err != nil {
910-
return fmt.Errorf("failed to configure Prometheus monitoring: %v", err)
913+
submitErr = fmt.Errorf("failed to configure Prometheus monitoring: %v", err)
914+
return
911915
}
912916
}
913917

914918
// Use batch scheduler to perform scheduling task before submitting (before build command arguments).
915919
if needScheduling, scheduler := r.shouldDoBatchScheduling(ctx, app); needScheduling {
916920
logger.Info("Do batch scheduling for SparkApplication")
917921
if err := scheduler.Schedule(app); err != nil {
918-
return fmt.Errorf("failed to process batch scheduler: %v", err)
922+
submitErr = fmt.Errorf("failed to process batch scheduler: %v", err)
923+
return
919924
}
920925
}
921926

@@ -927,10 +932,9 @@ func (r *Reconciler) submitSparkApplication(ctx context.Context, app *v1beta2.Sp
927932

928933
if err := r.submitter.Submit(ctx, app); err != nil {
929934
r.recordSparkApplicationEvent(app)
930-
return fmt.Errorf("failed to submit spark application: %v", err)
935+
submitErr = fmt.Errorf("failed to submit spark application: %v", err)
936+
return
931937
}
932-
933-
return nil
934938
}
935939

936940
// updateDriverState finds the driver pod of the application

0 commit comments

Comments
 (0)