Skip to content

Commit

Permalink
fix: replce comma with underline in woker's model label
Browse files Browse the repository at this point in the history
Signed-off-by: bjwswang <[email protected]>
  • Loading branch information
bjwswang committed Jan 22, 2024
1 parent 2b71f00 commit bec4bc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apiserver/pkg/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"strconv"
"strings"

"github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -130,7 +131,7 @@ func Worker2model(ctx context.Context, c dynamic.Interface, obj *unstructured.Un
API: new(string),
}
if r := worker.Labels[v1alpha1.WorkerModelTypesLabel]; r != "" {
w.ModelTypes = r
w.ModelTypes = strings.ReplaceAll(r,"_",",")
}

// read worker's models
Expand Down
6 changes: 4 additions & 2 deletions controllers/base/worker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"reflect"
"strings"

"github.com/go-logr/logr"
"github.com/pkg/errors"
Expand Down Expand Up @@ -161,8 +162,9 @@ func (r *WorkerReconciler) initialize(ctx context.Context, logger logr.Logger, i
if err := r.Client.Get(ctx, types.NamespacedName{Namespace: ns, Name: instance.Spec.Model.Name}, &m); err != nil {
return true, err
}
if types, ok := instance.Labels[arcadiav1alpha1.WorkerModelTypesLabel]; !ok || types != m.Spec.Types {
instance.Labels[arcadiav1alpha1.WorkerModelTypesLabel] = m.Spec.Types
if types, ok := instanceDeepCopy.Labels[arcadiav1alpha1.WorkerModelTypesLabel]; !ok || types != m.Spec.Types {
// lable do not accept `,`,so replace it with `_`

Check failure on line 166 in controllers/base/worker_controller.go

View workflow job for this annotation

GitHub Actions / misspellings

lable ==> label, ladle, labile, able
instanceDeepCopy.Labels[arcadiav1alpha1.WorkerModelTypesLabel] = strings.ReplaceAll(m.Spec.Types,",","_")
update = true
}
} else {
Expand Down

0 comments on commit bec4bc2

Please sign in to comment.