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 a2b4436
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,"_",",")

Check failure on line 134 in apiserver/pkg/worker/worker.go

View workflow job for this annotation

GitHub Actions / Lint Go code

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kubeagi/arcadia) -s blank -s dot --custom-order (gci)
}

// 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 {
// label do not accept `,`,so replace it with `_`
instanceDeepCopy.Labels[arcadiav1alpha1.WorkerModelTypesLabel] = strings.ReplaceAll(m.Spec.Types,",","_")

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

View workflow job for this annotation

GitHub Actions / Lint Go code

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kubeagi/arcadia) -s blank -s dot --custom-order (gci)
update = true
}
} else {
Expand Down

0 comments on commit a2b4436

Please sign in to comment.