Skip to content

Commit

Permalink
refactor(event): generate url event in phase calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
tunahanertekin committed Mar 20, 2024
1 parent 730fe87 commit 0ac02de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/controllers/v1alpha2/toolkit/code_editor/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func (r *CodeEditorReconciler) reconcileCheckDeployment(ctx context.Context, ins

actualImage := deploymentQuery.Spec.Template.Spec.Containers[0].Image

imageSynced := reflect.DeepEqual(desiredImage, actualImage)

remoteConfigSynced := (instance.Spec.Remote && reflect.DeepEqual(deploymentQuery.Spec.Template.Spec.Hostname, instance.Name) && reflect.DeepEqual(deploymentQuery.Spec.Template.Spec.Subdomain, instance.Name)) ||
(!instance.Spec.Remote && reflect.DeepEqual(deploymentQuery.Spec.Template.Spec.Hostname, "") && reflect.DeepEqual(deploymentQuery.Spec.Template.Spec.Subdomain, ""))

Expand All @@ -105,7 +107,7 @@ func (r *CodeEditorReconciler) reconcileCheckDeployment(ctx context.Context, ins

portSynced := reflect.DeepEqual(desiredPort, actualPort)

if !reflect.DeepEqual(desiredImage, actualImage) ||
if !imageSynced ||
!remoteConfigSynced ||
!volumeMountsSynced ||
!portSynced ||
Expand Down Expand Up @@ -238,12 +240,6 @@ func (r *CodeEditorReconciler) reconcileCheckService(ctx context.Context, instan

}

if codeEditorURL, ok := urls[internal.CODE_EDITOR_PORT_NAME]; ok {
if lastCodeEditorURL, ok := instance.Status.ServiceStatus.URLs[internal.CODE_EDITOR_PORT_NAME]; (ok && !reflect.DeepEqual(lastCodeEditorURL, codeEditorURL)) || !ok {
r.Recorder.Event(instance, "Normal", "Ready", "CodeEditor is accessible over the URL '"+codeEditorURL+"'.")
}
}

instance.Status.ServiceStatus.URLs = urls
instance.Status.ServiceStatus.Resource.Created = true
reference.SetReference(&instance.Status.ServiceStatus.Resource.Reference, serviceQuery.TypeMeta, serviceQuery.ObjectMeta)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package code_editor
import (
"context"

"github.com/robolaunch/robot-operator/internal"
robotErr "github.com/robolaunch/robot-operator/internal/error"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -186,6 +187,9 @@ func (r *CodeEditorReconciler) reconcileCalculatePhase(ctx context.Context, inst
}

if containersReady && instance.Status.ServiceStatus.Resource.Created && (instance.Spec.Ingress == instance.Status.IngressStatus.Created) {
if codeEditorURL, ok := instance.Status.ServiceStatus.URLs[internal.CODE_EDITOR_PORT_NAME]; ok && instance.Status.Phase != robotv1alpha2.CodeEditorPhaseReady {
r.Recorder.Event(instance, "Normal", "Ready", "CodeEditor is accessible over the URL '"+codeEditorURL+"'.")
}
instance.Status.Phase = robotv1alpha2.CodeEditorPhaseReady
} else {
instance.Status.Phase = robotv1alpha2.CodeEditorPhaseConfiguringResources
Expand Down

0 comments on commit 0ac02de

Please sign in to comment.