@@ -528,23 +528,31 @@ func (r *CLBBindingReconciler[T]) ensureBackendStatusAnnotation(ctx context.Cont
528528 return errors .WithStack (err )
529529 }
530530
531- if err := patchResult (ctx , r .Client , backend .GetObject (), string (val )); err != nil {
531+ if err := patchResult (ctx , r .Client , backend .GetObject (), string (val ), false ); err != nil {
532532 return errors .WithStack (err )
533533 }
534534 return nil
535535}
536536
537- func patchResult (ctx context.Context , c client.Client , obj client.Object , result string ) error {
537+ func patchResult (ctx context.Context , c client.Client , obj client.Object , result string , hostPort bool ) error {
538538 annotations := obj .GetAnnotations ()
539539 if annotations == nil {
540540 annotations = map [string ]string {}
541541 }
542+ var resultKey , statusKey string
543+ if hostPort {
544+ resultKey = constant .CLBHostPortMappingResultKey
545+ statusKey = constant .CLBHostPortMappingStatuslKey
546+ } else {
547+ resultKey = constant .CLBPortMappingResultKey
548+ statusKey = constant .CLBPortMappingStatuslKey
549+ }
542550 if annotations [constant .CLBPortMappingResultKey ] != string (result ) {
543551 patchMap := map [string ]any {
544552 "metadata" : map [string ]any {
545553 "annotations" : map [string ]string {
546- constant . CLBPortMappingResultKey : string (result ),
547- constant . CLBPortMappingStatuslKey : "Ready" ,
554+ resultKey : string (result ),
555+ statusKey : "Ready" ,
548556 },
549557 },
550558 }
@@ -571,11 +579,11 @@ func patchResult(ctx context.Context, c client.Client, obj client.Object, result
571579 }
572580 // 存在对应的 gameserver,patch result 注解
573581 gsAnnotations := gs .GetAnnotations ()
574- if gsAnnotations == nil || gsAnnotations [constant . CLBPortMappingResultKey ] != string (result ) {
582+ if gsAnnotations == nil || gsAnnotations [resultKey ] != string (result ) {
575583 patchMap := map [string ]any {
576584 "metadata" : map [string ]any {
577585 "annotations" : map [string ]string {
578- constant . CLBPortMappingResultKey : string (result ),
586+ resultKey : string (result ),
579587 },
580588 },
581589 }
0 commit comments