Skip to content

Commit

Permalink
Revert resource requests change (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
regadas authored Dec 2, 2022
1 parent 4252ffd commit 28f6be2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions pkg/flink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestLoadConfig(t *testing.T) {
defaultCluster := flinkConfig.DefaultFlinkCluster.Spec
jm := defaultCluster.JobManager
tm := defaultCluster.TaskManager
assert.Equal(t, tm.Resources.Requests[corev1.ResourceCPU], resource.MustParse("4"))
assert.Equal(t, tm.Resources.Limits[corev1.ResourceCPU], resource.MustParse("4"))
assert.Equal(t, jm.Resources.Limits[corev1.ResourceMemory], resource.MustParse("4Gi"))
assert.Equal(t, tm.Resources.Limits[corev1.ResourceMemory], resource.MustParse("4Gi"))
})
Expand All @@ -43,7 +43,7 @@ func TestLoadConfig(t *testing.T) {
jm := defaultCluster.JobManager
tm := defaultCluster.TaskManager
assert.Equal(t, *tm.Replicas, int32(4))
assert.Equal(t, jm.Resources.Requests[corev1.ResourceCPU], resource.MustParse("3.5"))
assert.Equal(t, jm.Resources.Limits[corev1.ResourceCPU], resource.MustParse("3.5"))
assert.Equal(t, *flinkConfig.DefaultFlinkCluster.Spec.ServiceAccountName, "flink-service-account")
assert.Equal(t, *flinkConfig.GeneratedNameMaxLength, 50)
})
Expand Down
34 changes: 18 additions & 16 deletions pkg/flink/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,30 @@ const (
)

var (
regexpFlinkClusterName = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
generatedNameMaxLength = 50
nonRetryableExitCodes = []int32{}
defaultServiceAccount = "default"
defaultResourceRequirements = corev1.ResourceRequirements{
Limits: map[corev1.ResourceName]resource.Quantity{
corev1.ResourceMemory: resource.MustParse("4Gi"),
},
Requests: map[corev1.ResourceName]resource.Quantity{
corev1.ResourceCPU: resource.MustParse("4"),
},
}
defaultConfig = Config{
regexpFlinkClusterName = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
generatedNameMaxLength = 50
nonRetryableExitCodes = []int32{}
defaultServiceAccount = "default"
defaultConfig = Config{
DefaultFlinkCluster: flinkOp.FlinkCluster{
Spec: flinkOp.FlinkClusterSpec{
ServiceAccountName: &defaultServiceAccount,
JobManager: &flinkOp.JobManagerSpec{
Resources: defaultResourceRequirements,
Resources: corev1.ResourceRequirements{
Limits: map[corev1.ResourceName]resource.Quantity{
corev1.ResourceCPU: resource.MustParse("4"),
corev1.ResourceMemory: resource.MustParse("4Gi"),
},
},
},
TaskManager: &flinkOp.TaskManagerSpec{
Replicas: pointer.Int32(1),
Resources: defaultResourceRequirements,
Replicas: pointer.Int32(1),
Resources: corev1.ResourceRequirements{
Limits: map[corev1.ResourceName]resource.Quantity{
corev1.ResourceCPU: resource.MustParse("4"),
corev1.ResourceMemory: resource.MustParse("4Gi"),
},
},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/flink/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (fc *FlinkCluster) updateJobManagerSpec(taskCtx FlinkTaskContext) {

if cpu := jm.GetResource().GetCpu(); cpu != nil {
if quantity := resource.MustParse(cpu.GetString_()); !quantity.IsZero() {
out.Resources.Requests[corev1.ResourceCPU] = quantity
out.Resources.Limits[corev1.ResourceCPU] = quantity
}
}

Expand Down Expand Up @@ -188,7 +188,7 @@ func (fc *FlinkCluster) updateTaskManagerSpec(taskCtx FlinkTaskContext) {

if cpu := tm.GetResource().GetCpu(); cpu != nil {
if quantity := resource.MustParse(cpu.GetString_()); !quantity.IsZero() {
out.Resources.Requests[corev1.ResourceCPU] = quantity
out.Resources.Limits[corev1.ResourceCPU] = quantity
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/flink/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ plugins:
gsutil -m cp {{join .Artifacts " "}} lib &&
zip -r job.jar .
resources:
requests:
limits:
cpu: "2"
memory: "1Gi"
jobManager:
accessScope: External
ingress:
useTls: true
resources:
requests:
limits:
cpu: "3.5"
memory: "4Gi"
volumes:
Expand Down

0 comments on commit 28f6be2

Please sign in to comment.