Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
chore: Fix scale up or down retry, too many event (#186)
Browse files Browse the repository at this point in the history
Signed-off-by: xieydd <xieydd@gmail.com>
  • Loading branch information
xieydd authored Oct 9, 2023
1 parent 25ca8e4 commit 05da1cb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ swag: swag-install
swag init -g ./cmd/agent/main.go --parseDependency --output ./pkg/docs

build-image: build-local
docker build -t ${BASE_REGISTRY}/${BASE_REGISTRY_USER}/modelz-agent:dev -f Dockerfile ./bin
docker push ${BASE_REGISTRY}/${BASE_REGISTRY_USER}/modelz-agent:dev
docker build -t ${BASE_REGISTRY}/${BASE_REGISTRY_USER}/openmodelz-agent:dev -f Dockerfile ./bin
docker push ${BASE_REGISTRY}/${BASE_REGISTRY_USER}/openmodelz-agent:dev

release:
@if [ ! -f ".release-env" ]; then \
Expand Down
1 change: 1 addition & 0 deletions agent/api/types/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type ScaleServiceRequest struct {
ServiceName string `json:"serviceName"`
Replicas uint64 `json:"replicas"`
EventMessage string `json:"eventMessage"`
Attempt int `json:"attempt"`
}

// DeleteFunctionRequest delete a deployed function
Expand Down
9 changes: 6 additions & 3 deletions agent/pkg/runtime/inference_replicas.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ func (r generalRuntime) InferenceScale(ctx context.Context, namespace string,
}

if r.eventEnabled {
err = r.eventRecorder.CreateDeploymentEvent(namespace, deployment.Name, event, req.EventMessage)
if err != nil {
return err
// Only create event when the first time scale up/down
if req.Attempt == 0 {
err = r.eventRecorder.CreateDeploymentEvent(namespace, deployment.Name, event, req.EventMessage)
if err != nil {
return err
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion agent/pkg/scaling/function_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ func (s *InferenceScaler) Scale(ctx context.Context,
if err := s.runtime.InferenceScale(ctx, namespace, types.ScaleServiceRequest{
ServiceName: inferenceName,
Replicas: minReplicas,
EventMessage: fmt.Sprintf("scale up to minimum replicas %d", minReplicas),
EventMessage: fmt.Sprintf("scale up to replicas %d", minReplicas),
Attempt: attempt,
}, inf); err != nil {
return err
}
Expand Down

0 comments on commit 05da1cb

Please sign in to comment.