Skip to content

Commit c67a18b

Browse files
authored
fix can't update service yaml when update from import to deploy (#4369)
Signed-off-by: Patrick Zhao <[email protected]>
1 parent 4ed80c5 commit c67a18b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

pkg/microservice/aslan/core/common/service/kube/apply.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ type ResourceApplyParam struct {
6464
UpdateResourceYaml string
6565

6666
// used for helm services
67-
Images []string // all images need to be updated, used for helm services
68-
VariableYaml string // variables
69-
Timeout int // timeout for helm services
70-
UpdateServiceRevision bool
67+
Images []string // all images need to be updated, used for helm services
68+
VariableYaml string // variables
69+
Timeout int // timeout for helm services
70+
IsFromImportToDeploy bool
7171

7272
Informer informers.SharedInformerFactory
7373
KubeClient client.Client
@@ -661,7 +661,7 @@ func CreateOrPatchResource(applyParam *ResourceApplyParam, log *zap.SugaredLogge
661661
if !ok {
662662
removeRes = append(removeRes, cr.unstructured)
663663
} else {
664-
if r.mainfest == cr.mainfest {
664+
if r.mainfest == cr.mainfest && !applyParam.IsFromImportToDeploy {
665665
unchangedResources = append(unchangedResources, cr.unstructured)
666666
delete(updateResourceMap, GVKN)
667667
}

pkg/microservice/aslan/core/environment/service/environment.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,8 @@ func updateProductImpl(updateRevisionSvcs []string, deployStrategy map[string]st
803803
return
804804
}
805805

806+
service.DeployStrategy = commonutil.GetServiceDeployStrategy(service.ServiceName, deployStrategy)
807+
curEnv.GetServiceMap()[service.ServiceName].DeployStrategy = commonutil.GetServiceDeployStrategy(service.ServiceName, curEnv.ServiceDeployStrategy)
806808
items, errUpsertService := upsertService(
807809
updateProd,
808810
service,
@@ -2780,6 +2782,11 @@ func upsertService(env *commonmodels.Product, newService *commonmodels.ProductSe
27802782
}
27812783
}
27822784

2785+
isFromImportToDeploy := false
2786+
if prevSvc.DeployStrategy == setting.ServiceDeployStrategyImport && newService.DeployStrategy == setting.ServiceDeployStrategyDeploy {
2787+
isFromImportToDeploy = true
2788+
}
2789+
27832790
resourceApplyParam := &kube.ResourceApplyParam{
27842791
ProductInfo: env,
27852792
ServiceName: newService.ServiceName,
@@ -2793,6 +2800,7 @@ func upsertService(env *commonmodels.Product, newService *commonmodels.ProductSe
27932800
AddZadigLabel: addLabel,
27942801
SharedEnvHandler: EnsureUpdateZadigService,
27952802
IstioGrayscaleEnvHandler: kube.EnsureUpdateGrayscaleService,
2803+
IsFromImportToDeploy: isFromImportToDeploy,
27962804
}
27972805

27982806
return kube.CreateOrPatchResource(resourceApplyParam, log)

0 commit comments

Comments
 (0)