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

Commit

Permalink
Merge branch 'master' into optimize_spring_service_finder
Browse files Browse the repository at this point in the history
# Conflicts:
#	samples/springboot-samples/pom.xml
  • Loading branch information
yuanyuan2021 committed Jan 22, 2024
2 parents 32cfe5c + 7e5c6f2 commit 553b72b
Show file tree
Hide file tree
Showing 18 changed files with 780 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -183,11 +182,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "0" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":1}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand All @@ -213,7 +212,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -229,11 +227,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "1" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":2}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand Down Expand Up @@ -353,7 +351,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -369,11 +366,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "0" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":1}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand All @@ -400,7 +397,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -416,11 +412,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "1" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":2}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand Down Expand Up @@ -496,7 +492,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -512,11 +507,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "0" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":1}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand Down Expand Up @@ -579,7 +574,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -595,11 +589,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "1" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":2}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -183,11 +182,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "0" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":1}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand Down Expand Up @@ -579,7 +578,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -595,11 +593,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "0" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":1}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand Down Expand Up @@ -738,7 +736,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -754,11 +751,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "0" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":1}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -183,11 +182,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "0" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":1}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand All @@ -213,7 +212,6 @@ jobs:
run: |
# 定义要等待的资源名称和字段值
moduledeploymentname=$(kubectl get moduledeployment -o name)
desired_field_value=true
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
Expand All @@ -229,11 +227,11 @@ jobs:
fi
# 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers)
field_value=$(kubectl get $moduledeploymentname -o custom-columns=CONFIRMBATCHNUM:.spec.confirmBatchNum --no-headers)
if [ "$field_value" == "$desired_field_value" ]; then
if [ "$field_value" == "1" ]; then
echo "字段值已满足条件,执行分组确认"
kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge
kubectl patch $moduledeploymentname -p '{"spec":{"confirmBatchNum":2}}' --type=merge
exit 0
else
echo "等待字段值满足条件..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ SOFAArk 的隔离方式和 OSGI 是一致的,但是在共享方面 OSGI 和 JP
![image.png](https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695175141130-d3b55e17-70c3-4e7c-aeef-2e071f89ada8.png#clientId=uaaa65411-0843-4&from=paste&height=316&id=u589ef06e&originHeight=632&originWidth=3642&originalType=binary&ratio=2&rotation=0&showTitle=false&size=139102&status=done&style=none&taskId=uf9f96d68-7456-4af5-951e-d9351092988&title=&width=1821)<br />图中的箭头是双向的,如果当前微服务拆分过多,也可以将多个微服务低成本改造成模块合并部署在一个 JVM 内。所以这里的本质是通过在单体架构和微服务架构之间增加一个可以双向过渡的模块化架构,降低改造成本的同时,也让开发者可以根据业务发展按需演进或回退。这样可以把微服务的这几个问题解决掉

### 模块化架构的优势
模块化架构的优势主要集中在这四点:快、省、灵活部署、可演进,<br />![image.png](https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695180240688-82520d0c-2304-47dc-a9f3-22af08424100.png#clientId=ueb39d37f-ca7b-4&from=paste&height=237&id=u4c60feb3&originHeight=688&originWidth=1504&originalType=binary&ratio=2&rotation=0&showTitle=false&size=437668&status=done&style=none&taskId=uf04ead3d-7cf7-41e7-bfff-81857bf5918&title=&width=518)
模块化架构的优势主要集中在这四点:快、省、灵活部署、可演进,<br />![image.png](https://github.com/sofastack/sofa-serverless/assets/3754074/11d1d662-d33b-482b-946b-bf600aeb34da)


与传统应用对比数据如下,可以看到在研发阶段、部署阶段、运行阶段都得到了10倍以上的提升效果。<br />![image.png](https://intranetproxy.alipay.com/skylark/lark/0/2023/png/149473/1695180250909-f5eca1b3-c416-4bac-9732-549a9bed8b87.png#clientId=ueb39d37f-ca7b-4&from=paste&height=261&id=u8907b613&originHeight=522&originWidth=2838&originalType=binary&ratio=2&rotation=0&showTitle=false&size=219589&status=done&style=none&taskId=ua4b2bd1b-a75f-4945-abce-68826a43377&title=&width=1419)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spring.application.name = ${替换为实际基座应用名}
#### 修改主 pom.xml
```xml
<properties>
<sofa.ark.verion>2.2.6</sofa.ark.verion>
<sofa.ark.verion>2.2.7</sofa.ark.verion>
<sofa.serverless.runtime.version>0.5.6</sofa.serverless.runtime.version>
</properties>
```
Expand Down
7 changes: 3 additions & 4 deletions module-controller/api/v1alpha1/moduledeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,9 @@ type ModuleDeploymentSpec struct {

ProgressDeadlineSeconds int32 `json:"progressDeadlineSeconds,omitempty"`

// Indicates that the moduleDeployment is paused and will not be processed by the
// moduleDeployment controller.
// +optional
Pause bool `json:"pause,omitempty"`
// +kubebuilder:default:=0
// +kubebuilder:validation:Minimum=0
ConfirmBatchNum int32 `json:"confirmBatchNum,omitempty"`

OperationStrategy ModuleOperationStrategy `json:"operationStrategy,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ spec:
Important: Run "make" to regenerate code after modifying this file'
minLength: 1
type: string
confirmBatchNum:
default: 0
format: int32
minimum: 0
type: integer
minReadySeconds:
format: int32
type: integer
Expand Down Expand Up @@ -75,10 +80,6 @@ spec:
useBeta:
type: boolean
type: object
pause:
description: Indicates that the moduleDeployment is paused and will
not be processed by the moduleDeployment controller.
type: boolean
progressDeadlineSeconds:
format: int32
type: integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ func (r *ModuleDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
event.PublishModuleDeploymentCreateEvent(r.Client, ctx, moduleDeployment)
}

if moduleDeployment.Spec.Pause {
if moduleDeployment.Status.ReleaseStatus != nil &&
moduleDeployment.Spec.ConfirmBatchNum < moduleDeployment.Status.ReleaseStatus.CurrentBatch &&
moduleDeployment.Status.ReleaseStatus.Progress == v1alpha1.ModuleDeploymentReleaseProgressPaused {

return ctrl.Result{}, nil
}

Expand Down Expand Up @@ -162,19 +165,26 @@ func (r *ModuleDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, err
}
}
case v1alpha1.ModuleDeploymentReleaseProgressWaitingForConfirmation:
moduleDeployment.Spec.Pause = true
if err := r.Update(ctx, moduleDeployment); err != nil {
return ctrl.Result{}, err

if moduleDeployment.Spec.ConfirmBatchNum > 0 {
moduleDeployment.Spec.ConfirmBatchNum = 0
if err := utils.UpdateResource(r.Client, ctx, moduleDeployment); err != nil {
return ctrl.Result{}, err
}
}

case v1alpha1.ModuleDeploymentReleaseProgressWaitingForConfirmation:

moduleDeployment.Status.ReleaseStatus.Progress = v1alpha1.ModuleDeploymentReleaseProgressPaused
log.Log.Info("update moduleDeployment releaseStatus progress to paused", "moduleDeploymentName", moduleDeployment.Name)
if err := utils.UpdateStatus(r.Client, ctx, moduleDeployment); err != nil {
return ctrl.Result{}, utils.Error(err, "update moduleDeployment releaseStatus progress to paused failed")
}
case v1alpha1.ModuleDeploymentReleaseProgressPaused:
if !moduleDeployment.Spec.Pause && time.Since(moduleDeployment.Status.ReleaseStatus.NextReconcileTime.Time) >= 0 {
if time.Since(moduleDeployment.Status.ReleaseStatus.NextReconcileTime.Time) >= 0 &&
moduleDeployment.Spec.ConfirmBatchNum == moduleDeployment.Status.ReleaseStatus.CurrentBatch {

moduleDeployment.Status.ReleaseStatus.CurrentBatch += 1
moduleDeployment.Status.ReleaseStatus.Progress = v1alpha1.ModuleDeploymentReleaseProgressExecuting
log.Log.Info("update moduleDeployment progress from paused to executing", "moduleDeploymentName", moduleDeployment.Name)
if err := utils.UpdateStatus(r.Client, ctx, moduleDeployment); err != nil {
Expand Down Expand Up @@ -465,7 +475,6 @@ func (r *ModuleDeploymentReconciler) updateModuleReplicaSet(ctx context.Context,
}
}
// TODO update current batch
moduleDeployment.Status.ReleaseStatus.CurrentBatch += 1
moduleDeployment.Status.ReleaseStatus.BatchProgress = v1alpha1.ModuleDeploymentReleaseProgressExecuting
log.Log.Info("update moduleDeployment batch progress to executing", "moduleDeploymentName", moduleDeployment.Name)
err = utils.UpdateStatus(r.Client, ctx, moduleDeployment)
Expand Down
Loading

0 comments on commit 553b72b

Please sign in to comment.