Skip to content

Commit 8ced579

Browse files
committed
rebase
Signed-off-by: You-Cheng Lin (Owen) <[email protected]>
1 parent d59cbd8 commit 8ced579

File tree

3 files changed

+5
-48
lines changed

3 files changed

+5
-48
lines changed

ray-operator/controllers/ray/utils/dashboard_httpclient.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ func ConvertRayJobToReq(rayJob *rayv1.RayJob) (*utiltypes.RayJobRequest, error)
319319
Metadata: rayJob.Spec.Metadata,
320320
}
321321
if len(rayJob.Spec.RuntimeEnvYAML) != 0 {
322-
runtimeEnv, err := UnmarshalRuntimeEnvYAML(rayJob.Spec.RuntimeEnvYAML)
322+
runtimeEnv := utiltypes.RuntimeEnvType{}
323+
err := yaml.Unmarshal([]byte(rayJob.Spec.RuntimeEnvYAML), &runtimeEnv)
323324
if err != nil {
324325
return nil, err
325326
}
@@ -334,11 +335,3 @@ func ConvertRayJobToReq(rayJob *rayv1.RayJob) (*utiltypes.RayJobRequest, error)
334335
}
335336
return req, nil
336337
}
337-
338-
func UnmarshalRuntimeEnvYAML(runtimeEnvYAML string) (utiltypes.RuntimeEnvType, error) {
339-
var runtimeEnv utiltypes.RuntimeEnvType
340-
if err := yaml.Unmarshal([]byte(runtimeEnvYAML), &runtimeEnv); err != nil {
341-
return nil, fmt.Errorf("failed to unmarshal RuntimeEnvYAML: %v: %w", runtimeEnvYAML, err)
342-
}
343-
return runtimeEnv, nil
344-
}

ray-operator/controllers/ray/utils/util_test.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -794,44 +794,6 @@ func TestCalculateDesiredReplicas(t *testing.T) {
794794
}
795795
}
796796

797-
func TestUnmarshalRuntimeEnv(t *testing.T) {
798-
tests := []struct {
799-
name string
800-
runtimeEnvYAML string
801-
isErrorNil bool
802-
}{
803-
{
804-
name: "Empty runtimeEnvYAML",
805-
runtimeEnvYAML: "",
806-
isErrorNil: true,
807-
},
808-
{
809-
name: "Valid runtimeEnvYAML",
810-
runtimeEnvYAML: `
811-
env_vars:
812-
counter_name: test_counter
813-
`,
814-
isErrorNil: true,
815-
},
816-
{
817-
name: "Invalid runtimeEnvYAML",
818-
runtimeEnvYAML: `invalid_yaml_str`,
819-
isErrorNil: false,
820-
},
821-
}
822-
823-
for _, tc := range tests {
824-
t.Run(tc.name, func(t *testing.T) {
825-
_, err := UnmarshalRuntimeEnvYAML(tc.runtimeEnvYAML)
826-
if tc.isErrorNil {
827-
require.NoError(t, err)
828-
} else {
829-
require.Error(t, err)
830-
}
831-
})
832-
}
833-
}
834-
835797
func TestFindHeadPodReadyCondition(t *testing.T) {
836798
tests := []struct {
837799
name string

ray-operator/controllers/ray/utils/validation.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
"k8s.io/apimachinery/pkg/api/meta"
99
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1010
"k8s.io/apimachinery/pkg/util/validation"
11+
"sigs.k8s.io/yaml"
1112

1213
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
14+
utiltypes "github.com/ray-project/kuberay/ray-operator/controllers/ray/utils/types"
1315
"github.com/ray-project/kuberay/ray-operator/pkg/features"
1416
)
1517

@@ -204,7 +206,7 @@ func ValidateRayJobSpec(rayJob *rayv1.RayJob) error {
204206

205207
// Validate whether RuntimeEnvYAML is a valid YAML string. Note that this only checks its validity
206208
// as a YAML string, not its adherence to the runtime environment schema.
207-
if _, err := UnmarshalRuntimeEnvYAML(rayJob.Spec.RuntimeEnvYAML); err != nil {
209+
if err := yaml.Unmarshal([]byte(rayJob.Spec.RuntimeEnvYAML), &utiltypes.RuntimeEnvType{}); err != nil {
208210
return err
209211
}
210212
if rayJob.Spec.ActiveDeadlineSeconds != nil && *rayJob.Spec.ActiveDeadlineSeconds <= 0 {

0 commit comments

Comments
 (0)