Skip to content

Commit

Permalink
Fix parallelism inference (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
regadas authored May 13, 2021
1 parent 82250c6 commit cd796d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 12 additions & 7 deletions controllers/flinkcluster_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,17 +944,22 @@ func calJobParallelism(cluster *v1beta1.FlinkCluster) *int32 {
return cluster.Spec.Job.Parallelism
}

tmReplicas := cluster.Spec.TaskManager.Replicas
ts, ok := cluster.Spec.FlinkProperties["taskmanager.numberOfTaskSlots"]
if !ok {
return nil
var value *int
if ts, ok := cluster.Spec.FlinkProperties["taskmanager.numberOfTaskSlots"]; ok {
parsed, err := strconv.Atoi(ts)
if err != nil {
return nil
}
value = &parsed
} else {
value = calTaskManagerTaskSlots(cluster)
}
value, err := strconv.Atoi(ts)
if err != nil {

if value == nil {
return nil
}

parallelism := tmReplicas * int32(value)
parallelism := cluster.Spec.TaskManager.Replicas * int32(*value)
return &parallelism
}

Expand Down
3 changes: 1 addition & 2 deletions controllers/flinkcluster_converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ func TestGetDesiredClusterState(t *testing.T) {
},
SecurityContext: &securityContext,
},
FlinkProperties: map[string]string{"taskmanager.numberOfTaskSlots": "1"},
EnvVars: []corev1.EnvVar{{Name: "FOO", Value: "abc"}},
EnvVars: []corev1.EnvVar{{Name: "FOO", Value: "abc"}},
EnvFrom: []corev1.EnvFromSource{{ConfigMapRef: &corev1.ConfigMapEnvSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: "FOOMAP",
Expand Down

0 comments on commit cd796d4

Please sign in to comment.