Skip to content

Commit

Permalink
Fix: check if BatchScheduler is set (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
regadas authored Dec 14, 2021
1 parent c23950a commit 520f9e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 7 additions & 0 deletions api/v1beta1/flinkcluster_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ func _SetDefault(cluster *FlinkCluster) {
cluster.Spec.RecreateOnUpdate = new(bool)
*cluster.Spec.RecreateOnUpdate = true
}

if cluster.Spec.BatchSchedulerName != nil {
cluster.Spec.BatchScheduler = &BatchSchedulerSpec{
Name: *cluster.Spec.BatchSchedulerName,
}
}

_SetImageDefault(&cluster.Spec.Image)
flinkVersion, _ := version.NewVersion(cluster.Spec.FlinkVersion)
_SetJobManagerDefault(&cluster.Spec.JobManager, flinkVersion)
Expand Down
12 changes: 3 additions & 9 deletions controllers/flinkcluster_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,12 @@ func (reconciler *ClusterReconciler) reconcile() (ctrl.Result, error) {
}

func (reconciler *ClusterReconciler) reconcileBatchScheduler() error {
var batchSchedulerName string
if reconciler.observed.cluster.Spec.BatchSchedulerName != nil {
batchSchedulerName = *reconciler.observed.cluster.Spec.BatchSchedulerName
}
if reconciler.observed.cluster.Spec.BatchScheduler != nil {
batchSchedulerName = reconciler.observed.cluster.Spec.BatchScheduler.Name
}
if batchSchedulerName == "" {
if reconciler.observed.cluster.Spec.BatchScheduler == nil ||
reconciler.observed.cluster.Spec.BatchScheduler.Name == "" {
return nil
}

scheduler, err := batchscheduler.GetScheduler(batchSchedulerName)
scheduler, err := batchscheduler.GetScheduler(reconciler.observed.cluster.Spec.BatchScheduler.Name)
if err != nil {
return err
}
Expand Down

0 comments on commit 520f9e9

Please sign in to comment.