Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deploy] fix deploy update with wrong image #194

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
SeanHH86 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading