Skip to content

Commit

Permalink
fix: fix test failing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
miladibra10 committed Jun 14, 2023
1 parent f69593a commit 424a52e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions controllers/externalservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"reflect"
"time"

Expand Down Expand Up @@ -103,9 +104,10 @@ func (r *ExternalServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ
} else {
// TODO: DeepEqual function does not operate good for this part because kubernetes adds values to fields after creation
// we can check for more field differences here.
if !reflect.DeepEqual(&desiredService.Spec.Type, &currentService.Spec.Type) ||
!reflect.DeepEqual(&desiredService.Labels, &currentService.Labels) ||
!reflect.DeepEqual(&desiredService.Spec.Ports, &currentService.Spec.Ports) {
isTypeEqual := reflect.DeepEqual(&desiredService.Spec.Type, &currentService.Spec.Type)
areLabelsEqual := reflect.DeepEqual(&desiredService.Labels, &currentService.Labels)
arePortsEqual := reflect.DeepEqual(&desiredService.Spec.Ports, &currentService.Spec.Ports)
if !isTypeEqual || !areLabelsEqual || !arePortsEqual {
err = r.Update(ctx, &desiredService)
if err != nil {
logger.Error(err, "could not update service object")
Expand Down Expand Up @@ -171,6 +173,7 @@ func (r *ExternalServiceReconciler) getDesiredService(externalService networking
Protocol: port.Protocol,
AppProtocol: port.AppProtocol,
Port: port.Port,
TargetPort: intstr.FromInt(int(port.Port)),
})
}
svc := corev1.Service{
Expand Down

0 comments on commit 424a52e

Please sign in to comment.