@@ -528,23 +528,31 @@ func (r *CLBBindingReconciler[T]) ensureBackendStatusAnnotation(ctx context.Cont
528
528
return errors .WithStack (err )
529
529
}
530
530
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 {
532
532
return errors .WithStack (err )
533
533
}
534
534
return nil
535
535
}
536
536
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 {
538
538
annotations := obj .GetAnnotations ()
539
539
if annotations == nil {
540
540
annotations = map [string ]string {}
541
541
}
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
+ }
542
550
if annotations [constant .CLBPortMappingResultKey ] != string (result ) {
543
551
patchMap := map [string ]any {
544
552
"metadata" : map [string ]any {
545
553
"annotations" : map [string ]string {
546
- constant . CLBPortMappingResultKey : string (result ),
547
- constant . CLBPortMappingStatuslKey : "Ready" ,
554
+ resultKey : string (result ),
555
+ statusKey : "Ready" ,
548
556
},
549
557
},
550
558
}
@@ -571,11 +579,11 @@ func patchResult(ctx context.Context, c client.Client, obj client.Object, result
571
579
}
572
580
// 存在对应的 gameserver,patch result 注解
573
581
gsAnnotations := gs .GetAnnotations ()
574
- if gsAnnotations == nil || gsAnnotations [constant . CLBPortMappingResultKey ] != string (result ) {
582
+ if gsAnnotations == nil || gsAnnotations [resultKey ] != string (result ) {
575
583
patchMap := map [string ]any {
576
584
"metadata" : map [string ]any {
577
585
"annotations" : map [string ]string {
578
- constant . CLBPortMappingResultKey : string (result ),
586
+ resultKey : string (result ),
579
587
},
580
588
},
581
589
}
0 commit comments