Skip to content

Commit

Permalink
Simplify the code and add a comment.
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
eapolinario committed Mar 7, 2024
1 parent 0e08fb6 commit 2c8ab7a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions flyteadmin/pkg/manager/impl/validation/task_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,13 @@ func isWholeNumber(quantity resource.Quantity) bool {
func resourceListToQuantity(resources corev1.ResourceList) map[core.Resources_ResourceName]resource.Quantity {
var requestedToQuantity = make(map[core.Resources_ResourceName]resource.Quantity)
for name, quantity := range resources {
var resourceName = core.Resources_UNKNOWN
// The name to refer to ephemeral storage defined in k8s (https://github.com/kubernetes/api/blob/05aa4bceed70af2652698a28fb144ee22b2dd2ba/core/v1/types.go#L5988)
// is different from the name defined in Flyte's proto (https://github.com/flyteorg/flyte/blob/fd42f65660069d9c164cda2de579d3a89cac5b0f/flyteidl/protos/flyteidl/core/tasks.proto#L25).
// This is a workaround to handle the conversion.
if name == "ephemeral-storage" {
resourceName = core.Resources_ResourceName(core.Resources_ResourceName_value["EPHEMERAL_STORAGE"])
} else {
resourceName = core.Resources_ResourceName(core.Resources_ResourceName_value[strings.ToUpper(name.String())])
name = "EPHEMERAL_STORAGE"
}
resourceName := core.Resources_ResourceName(core.Resources_ResourceName_value[strings.ToUpper(name.String())])
requestedToQuantity[resourceName] = quantity
}
return requestedToQuantity
Expand Down

0 comments on commit 2c8ab7a

Please sign in to comment.