Skip to content

Commit

Permalink
Fix livenessrobe compare
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng committed Sep 14, 2024
1 parent 72ba863 commit df798d3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
13 changes: 8 additions & 5 deletions controllers/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,15 @@ func (r *FunctionReconciler) checkIfStatefulSetNeedUpdate(ctx context.Context, s
if err != nil {
return false, err
}
diff, err := spec.CreateDiff(statefulSet, desiredStatefulSet)
if err != nil {
return false, err
needUpdate := !spec.CheckIfStatefulSetSpecIsEqual(&statefulSet.Spec, &desiredStatefulSet.Spec)
if needUpdate {
diff, err := spec.CreateDiff(statefulSet, desiredStatefulSet)
if err != nil {
return needUpdate, err
}
function.Status.PendingChange = diff
}
function.Status.PendingChange = diff
return !spec.CheckIfStatefulSetSpecIsEqual(&statefulSet.Spec, &desiredStatefulSet.Spec), nil
return needUpdate, nil
}

func (r *FunctionReconciler) checkIfHPANeedUpdate(hpa *autov2.HorizontalPodAutoscaler,
Expand Down
13 changes: 8 additions & 5 deletions controllers/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,15 @@ func (r *SinkReconciler) checkIfStatefulSetNeedUpdate(ctx context.Context, state
if err != nil {
return false, err
}
diff, err := spec.CreateDiff(statefulSet, desiredStatefulSet)
if err != nil {
return false, err
needUpdate := !spec.CheckIfStatefulSetSpecIsEqual(&statefulSet.Spec, &desiredStatefulSet.Spec)
if needUpdate {
diff, err := spec.CreateDiff(statefulSet, desiredStatefulSet)
if err != nil {
return needUpdate, err
}
sink.Status.PendingChange = diff
}
sink.Status.PendingChange = diff
return !spec.CheckIfStatefulSetSpecIsEqual(&statefulSet.Spec, &desiredStatefulSet.Spec), nil
return needUpdate, nil
}

func (r *SinkReconciler) checkIfHPANeedUpdate(hpa *autov2.HorizontalPodAutoscaler, sink *v1alpha1.Sink) bool {
Expand Down
13 changes: 8 additions & 5 deletions controllers/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,15 @@ func (r *SourceReconciler) checkIfStatefulSetNeedUpdate(ctx context.Context, sta
if err != nil {
return false, err
}
diff, err := spec.CreateDiff(statefulSet, desiredStatefulSet)
if err != nil {
return false, err
needUpdate := !spec.CheckIfStatefulSetSpecIsEqual(&statefulSet.Spec, &desiredStatefulSet.Spec)
if needUpdate {
diff, err := spec.CreateDiff(statefulSet, desiredStatefulSet)
if err != nil {
return needUpdate, err
}
source.Status.PendingChange = diff
}
source.Status.PendingChange = diff
return !spec.CheckIfStatefulSetSpecIsEqual(&statefulSet.Spec, &desiredStatefulSet.Spec), nil
return needUpdate, nil
}

func (r *SourceReconciler) checkIfHPANeedUpdate(hpa *autov2.HorizontalPodAutoscaler, source *v1alpha1.Source) bool {
Expand Down
7 changes: 4 additions & 3 deletions controllers/spec/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,9 @@ func MakeLivenessProbe(liveness *v1alpha1.Liveness) *corev1.Probe {
return &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt32(MetricsPort.ContainerPort),
Path: "/",
Port: intstr.FromInt32(MetricsPort.ContainerPort),
Scheme: corev1.URISchemeHTTP,
},
},
InitialDelaySeconds: initialDelay,
Expand Down Expand Up @@ -2087,7 +2088,7 @@ func CheckIfStatefulSetSpecIsEqual(spec *appsv1.StatefulSetSpec, desiredSpec *ap
if !reflect.DeepEqual(container.Command, desiredContainer.Command) ||
container.Image != desiredContainer.Image ||
container.ImagePullPolicy != desiredContainer.ImagePullPolicy ||
container.LivenessProbe != desiredContainer.LivenessProbe ||
!reflect.DeepEqual(container.LivenessProbe, desiredContainer.LivenessProbe) ||
!reflect.DeepEqual(ports, desiredPorts) ||
!reflect.DeepEqual(containerEnvFrom, desiredContainerEnvFrom) ||
!reflect.DeepEqual(container.Resources, desiredContainer.Resources) {
Expand Down

0 comments on commit df798d3

Please sign in to comment.