Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Fix deletion of elastic task resource requests #379

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions go/tasks/plugins/k8s/kfoperators/common/common_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,10 @@
if len(resources.Requests) >= 1 || len(resources.Limits) >= 1 {
resources, err := flytek8s.ToK8sResourceRequirements(resources)
if err != nil {
return flyteerr.Errorf(flyteerr.BadTaskSpecification, "invalid TaskSpecificat ion on Resources [%v], Err: [%v]", resources, err.Error())
return flyteerr.Errorf(flyteerr.BadTaskSpecification, "invalid TaskSpecification on Resources [%v], Err: [%v]", resources, err.Error())

Check warning on line 271 in go/tasks/plugins/k8s/kfoperators/common/common_operator.go

View check run for this annotation

Codecov / codecov/patch

go/tasks/plugins/k8s/kfoperators/common/common_operator.go#L271

Added line #L271 was not covered by tests
}
podSpec.Containers[idx].Resources = *resources
}
} else {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the problematic line.

podSpec.Containers[idx].Resources = v1.ResourceRequirements{}
}
if len(args) != 0 {
podSpec.Containers[idx].Args = args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,13 @@ func TestOverrideContainerSpecEmptyFields(t *testing.T) {

func TestOverrideContainerNilResources(t *testing.T) {
podSpec := dummyPodSpec()
podSpecCopy := podSpec.DeepCopy()

err := OverrideContainerSpec(&podSpec, "primary container", "", nil, []string{})
assert.NoError(t, err)
assert.Equal(t, 2, len(podSpec.Containers))
assert.Nil(t, podSpec.Containers[0].Resources.Limits)
assert.Nil(t, podSpec.Containers[0].Resources.Requests)
assert.Equal(t, podSpec.Containers[0].Resources.Limits, podSpecCopy.Containers[0].Resources.Limits)
assert.Equal(t, podSpec.Containers[0].Resources.Requests, podSpecCopy.Containers[0].Resources.Requests)
}

func dummyTaskContext() pluginsCore.TaskExecutionContext {
Expand Down
2 changes: 1 addition & 1 deletion go/tasks/plugins/k8s/kfoperators/pytorch/pytorch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ func TestBuildResourcePytorchV1WithZeroWorker(t *testing.T) {
assert.Error(t, err)
}

func TestParasElasticConfig(t *testing.T) {
func TestParseElasticConfig(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope creep: fix typo

elasticConfig := plugins.ElasticConfig{MinReplicas: 1, MaxReplicas: 2, NprocPerNode: 4, RdzvBackend: "c10d"}
elasticPolicy := ParseElasticConfig(&elasticConfig)
assert.Equal(t, int32(1), *elasticPolicy.MinReplicas)
Expand Down
Loading