Skip to content

Commit

Permalink
[Deploy] fix deploy update with wrong image (#194)
Browse files Browse the repository at this point in the history
Co-authored-by: Haihui.Wang <[email protected]>
  • Loading branch information
SeanHH86 and wanghh2000 authored Nov 27, 2024
1 parent b202a67 commit 7054b19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions builder/deploy/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ func (d *deployer) serverlessDeploy(ctx context.Context, dr types.DeployRepo) (*
deploy.SKU = dr.SKU
// dr.ImageID is not null for nginx space, otherwise it's ""
deploy.ImageID = dr.ImageID
slog.Info("do deployer.serverlessDeploy", slog.Any("dr", dr), slog.Any("deploy", deploy))
slog.Debug("do deployer.serverlessDeploy", slog.Any("dr", dr), slog.Any("deploy", deploy))
err = d.store.UpdateDeploy(ctx, deploy)
if err != nil {
return nil, fmt.Errorf("fail reset deploy image, %w", err)
}
slog.Info("return deployer.serverlessDeploy", slog.Any("dr", dr), slog.Any("deploy", deploy))
slog.Debug("return deployer.serverlessDeploy", slog.Any("dr", dr), slog.Any("deploy", deploy))
return deploy, nil
}

Expand Down Expand Up @@ -542,10 +542,17 @@ func (d *deployer) UpdateDeploy(ctx context.Context, dur *types.DeployUpdateReq,
if err != nil {
return fmt.Errorf("error finding space resource %d, %w", *dur.ResourceID, err)
}
var err = json.Unmarshal([]byte(resource.Resources), &hardware)
err = json.Unmarshal([]byte(resource.Resources), &hardware)
if err != nil {
return fmt.Errorf("invalid resource hardware setting, %w", err)
}
deploy.Hardware = resource.Resources
deploy.SKU = strconv.FormatInt(resource.ID, 10)
} else {
err = json.Unmarshal([]byte(deploy.Hardware), &hardware)
if err != nil {
return fmt.Errorf("invalid deploy hardware setting, %w", err)
}
}

if dur.DeployName != nil {
Expand All @@ -555,11 +562,6 @@ func (d *deployer) UpdateDeploy(ctx context.Context, dur *types.DeployUpdateReq,
deploy.Env = *dur.Env
}

if resource != nil {
deploy.Hardware = resource.Resources
deploy.SKU = strconv.FormatInt(resource.ID, 10)
}

if frame != nil {
// choose image
containerImg := frame.FrameCpuImage
Expand Down Expand Up @@ -670,7 +672,7 @@ func (d *deployer) startAccountingRequestMeter(resMap map[string]string, svcRes
}
resName, exists := resMap[svcRes.DeploySku]
if !exists {
slog.Warn("Did not find resource for metering", slog.Any("deploy_sku", svcRes.DeploySku))
slog.Warn("Did not find space resource by id for metering", slog.Any("id", svcRes.DeploySku), slog.Any("deploy_id", svcRes.DeployID), slog.Any("svc_name", svcRes.ServiceName))
return
}
slog.Debug("metering service", slog.Any("svcRes", svcRes))
Expand Down
2 changes: 1 addition & 1 deletion component/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,7 @@ func (c *repoComponentImpl) DeployUpdate(ctx context.Context, updateReq types.De
}
exist, err := c.deployer.Exist(ctx, deployRepo)
if err != nil {
return err
return fmt.Errorf("check deploy exists, err: %w", err)
}

if exist {
Expand Down

0 comments on commit 7054b19

Please sign in to comment.