Skip to content

Commit 628e380

Browse files
committed
fix: faultinjection ui
1 parent a58a624 commit 628e380

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

pkg/manager/controllers/circuitbreaker/event_handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package circuitbreaker
1818

1919
import (
2020
"context"
21+
"reflect"
2122

2223
v1 "k8s.io/api/core/v1"
2324
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -126,7 +127,9 @@ func matchChangedBreakers(c client.Reader, old, new *v1.Pod) ([]*ctrlmeshv1alpha
126127
}
127128
oldMatch := selector.Matches(labels.Set(old.Labels))
128129
newMatch := selector.Matches(labels.Set(new.Labels))
129-
if oldMatch != newMatch {
130+
oldStatus := old.Status
131+
newStatus := new.Status
132+
if oldMatch != newMatch || !reflect.DeepEqual(oldStatus, newStatus) {
130133
res = append(res, &breakers.Items[i])
131134
}
132135
}

pkg/manager/controllers/faultinjection/event_handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package faultinjection
1818

1919
import (
2020
"context"
21+
"reflect"
2122

2223
v1 "k8s.io/api/core/v1"
2324
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -127,7 +128,9 @@ func matchChangedFaults(c client.Reader, old, new *v1.Pod) ([]*ctrlmeshv1alpha1.
127128
}
128129
oldMatch := selector.Matches(labels.Set(old.Labels))
129130
newMatch := selector.Matches(labels.Set(new.Labels))
130-
if oldMatch != newMatch {
131+
oldStatus := old.Status
132+
newStatus := new.Status
133+
if oldMatch != newMatch || !reflect.DeepEqual(oldStatus, newStatus) {
131134
res = append(res, &faults.Items[i])
132135
}
133136
}

pkg/manager/controllers/faultinjection/faultinject_controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"github.com/KusionStack/controller-mesh/pkg/apis/ctrlmesh/proto/protoconnect"
4545
"github.com/KusionStack/controller-mesh/pkg/apis/ctrlmesh/utils/conv"
4646
ctrlmeshv1alpha1 "github.com/KusionStack/controller-mesh/pkg/apis/ctrlmesh/v1alpha1"
47+
"github.com/KusionStack/controller-mesh/pkg/proxy/grpcserver"
4748
"github.com/KusionStack/controller-mesh/pkg/utils"
4849
)
4950

@@ -161,7 +162,7 @@ func (r *FaultInjectionReconciler) Reconcile(ctx context.Context, req ctrl.Reque
161162
}
162163
fi.Status = *status
163164
if err := r.Status().Update(ctx, fi); err != nil {
164-
klog.Errorf("fail to update circuit breaker %s status", utils.KeyFunc(fi))
165+
klog.Errorf("fail to update fault injection %s status", utils.KeyFunc(fi))
165166
reconcileErr = errors.Join(reconcileErr, err)
166167
}
167168
return ctrl.Result{}, reconcileErr
@@ -279,7 +280,7 @@ func protoClient(podIp string) protoconnect.FaultInjectClient {
279280
}
280281

281282
func podAddr(podIp string) string {
282-
return fmt.Sprintf("https://%s:%d", podIp, constants.ProxyGRPCServerPort)
283+
return fmt.Sprintf("https://%s:%d", podIp, grpcserver.GrpcServerPort)
283284
}
284285

285286
// isProxyAvailable check whether the proxy container is available

pkg/manager/controllers/faultinjection/faultinjection_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var faultInjection = &ctrlmeshv1alpha1.FaultInjection{
7979
{
8080
Delay: &ctrlmeshv1alpha1.HTTPFaultInjectionDelay{
8181
Percent: "100",
82-
FixedDelay: "20s",
82+
FixedDelay: "20ms",
8383
},
8484
Match: &ctrlmeshv1alpha1.Match{
8585
Resources: []*ctrlmeshv1alpha1.ResourceMatch{

0 commit comments

Comments
 (0)