Skip to content

Commit 2c3129e

Browse files
committed
一些优化
1 parent f988e12 commit 2c3129e

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

api/v1alpha1/dedicatedclbservice_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ type AllocatableCLBInfo struct {
8686
LbId string `json:"lbId"`
8787
// CLB 当前已被分配的端口。
8888
// +optional
89-
CurrentPort int64 `json:"maxPort"`
89+
CurrentPort int64 `json:"currentPort"`
9090
// 是否是自动创建的 CLB。如果是,删除 DedicatedCLBService 时,CLB 也会被清理。
9191
AutoCreate bool `json:"autoCreate"`
9292
}

charts/tke-extend-network-controller/templates/networking.cloud.tencent.com_dedicatedclbservices.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ spec:
112112
autoCreate:
113113
description: 是否是自动创建的 CLB。如果是,删除 DedicatedCLBService 时,CLB 也会被清理。
114114
type: boolean
115-
lbId:
116-
description: CLB 实例的 ID。
117-
type: string
118-
maxPort:
115+
currentPort:
119116
description: CLB 当前已被分配的端口。
120117
format: int64
121118
type: integer
119+
lbId:
120+
description: CLB 实例的 ID。
121+
type: string
122122
required:
123123
- autoCreate
124124
- lbId

config/crd/bases/networking.cloud.tencent.com_dedicatedclbservices.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ spec:
113113
autoCreate:
114114
description: 是否是自动创建的 CLB。如果是,删除 DedicatedCLBService 时,CLB 也会被清理。
115115
type: boolean
116-
lbId:
117-
description: CLB 实例的 ID。
118-
type: string
119-
maxPort:
116+
currentPort:
120117
description: CLB 当前已被分配的端口。
121118
format: int64
122119
type: integer
120+
lbId:
121+
description: CLB 实例的 ID。
122+
type: string
123123
required:
124124
- autoCreate
125125
- lbId

internal/controller/dedicatedclbservice_controller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type DedicatedCLBServiceReconciler struct {
6767
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
6868
func (r *DedicatedCLBServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
6969
ds := &networkingv1alpha1.DedicatedCLBService{}
70-
if err := r.Get(ctx, req.NamespacedName, ds); err != nil {
70+
if err := r.APIReader.Get(ctx, req.NamespacedName, ds); err != nil { // 避免从缓存中读取(status可能更新不及时导致状态不一致,造成clb多创等问题)
7171
return ctrl.Result{}, client.IgnoreNotFound(err)
7272
}
7373
return util.RequeueIfConflict(r.reconcile(ctx, ds))
@@ -234,7 +234,7 @@ func (r *DedicatedCLBServiceReconciler) allocateNewCLB(ctx context.Context, ds *
234234
if err != nil {
235235
return err
236236
}
237-
log.FromContext(ctx).Info("successfully created clb instance", "lbIds", ids)
237+
r.Recorder.Event(ds, corev1.EventTypeNormal, "CreateCLB", fmt.Sprintf("clb successfully created: %v", ids))
238238
return kube.UpdateStatus(ctx, ds, func() {
239239
for _, lbId := range ids {
240240
ds.Status.AllocatableLb = append(ds.Status.AllocatableLb, networkingv1alpha1.AllocatableCLBInfo{

0 commit comments

Comments
 (0)