Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
Signed-off-by: Min Min <[email protected]>
  • Loading branch information
jamsman94 committed Nov 29, 2024
1 parent baf1b4e commit ccad25c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/microservice/aslan/core/environment/service/sae_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,39 @@ func BindSAEAppToService(projectName, envName, appID, serviceName, serviceModule
return e.ErrScaleService.AddErr(err)
}

// if service name and service module is empty, we delete the service binding tag for this app.
if len(serviceName) == 0 && len(serviceModule) == 0 {
tagKeys := []string{setting.SAEZadigServiceTagKey, setting.SAEZadigServiceModuleTagKey}
tagKeyStr, err := json.Marshal(tagKeys)
if err != nil {
err = fmt.Errorf("failed to bind sae application %s to service: json marshal failed, err: %s", appID, err)
log.Error(err)
return e.ErrScaleService.AddErr(err)
}

saeRequest := &sae.UntagResourcesRequest{
DeleteAll: tea.Bool(false),
RegionId: tea.String(env.RegionID),
ResourceIds: tea.String(string(resourceIds)),
ResourceType: tea.String("application"),
TagKeys: tea.String(string(tagKeyStr)),
}

saeResp, err := saeClient.UntagResources(saeRequest)
if err != nil {
err = fmt.Errorf("failed to unbind application %s to service, err: %s", appID, err)
log.Error(err)
return e.ErrScaleService.AddErr(err)
}
if !tea.BoolValue(saeResp.Body.Success) {
err = fmt.Errorf("failed to unbind application %s to service, statusCode: %d, code: %s, errCode: %s, message: %s", appID, tea.Int32Value(saeResp.StatusCode), tea.ToString(saeResp.Body.Code), tea.ToString(saeResp.Body.ErrorCode), tea.ToString(saeResp.Body.Message))
log.Error(err)
return e.ErrScaleService.AddErr(err)
}

return nil
}

saeRequest := &sae.TagResourcesRequest{
RegionId: tea.String(env.RegionID),
ResourceType: tea.String("application"),
Expand Down

0 comments on commit ccad25c

Please sign in to comment.