Skip to content

Commit

Permalink
added debug log for discovery
Browse files Browse the repository at this point in the history
Signed-off-by: kumarabd <[email protected]>
  • Loading branch information
kumarabd committed May 10, 2021
1 parent 7f99472 commit f1dc850
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controllers/broker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (r *BrokerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
}

// Get broker endpoint
err = brokerpackage.GetEndpoint(ctx, baseResource, r.Clientset, r.KubeConfig.Host)
err = brokerpackage.GetEndpoint(ctx, log, baseResource, r.Clientset, r.KubeConfig.Host)
if err != nil {
return ctrl.Result{}, ErrGetEndpoint(err)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/meshsync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (r *MeshSyncReconciler) reconcileBrokerConfig(ctx context.Context, baseReso
if baseResource.Spec.Broker.Native != nullNativeResource {
brokerresource.ObjectMeta.Namespace = baseResource.Spec.Broker.Native.Namespace
brokerresource.ObjectMeta.Name = baseResource.Spec.Broker.Native.Name
err := brokerpackage.GetEndpoint(ctx, brokerresource, r.Clientset, r.KubeConfig.Host)
err := brokerpackage.GetEndpoint(ctx, r.Log, brokerresource, r.Clientset, r.KubeConfig.Host)
if err != nil {
return ErrGetEndpoint(err)
}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func main() {

ctrl.SetLogger(log.ControllerLogger())

opId := uuid.NewUUID()
opID := uuid.NewUUID()
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
LeaderElection: enableLeaderElection,
LeaderElectionID: fmt.Sprintf("operator-%s.meshery.layer5.io", opId),
LeaderElectionID: fmt.Sprintf("operator-%s.meshery.layer5.io", opID),
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down
6 changes: 5 additions & 1 deletion pkg/broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/go-logr/logr"
mesheryv1alpha1 "github.com/layer5io/meshery-operator/api/v1alpha1"
mesherykube "github.com/layer5io/meshkit/utils/kubernetes"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -78,7 +79,7 @@ func CheckHealth(ctx context.Context, m *mesheryv1alpha1.Broker, client *kuberne
return nil
}

func GetEndpoint(ctx context.Context, m *mesheryv1alpha1.Broker, client *kubernetes.Clientset, url string) error {
func GetEndpoint(ctx context.Context, log logr.Logger, m *mesheryv1alpha1.Broker, client *kubernetes.Clientset, url string) error {
endpoint, err := mesherykube.GetServiceEndpoint(context.TODO(), client, &mesherykube.ServiceOptions{
Name: m.ObjectMeta.Name,
Namespace: m.ObjectMeta.Namespace,
Expand All @@ -89,6 +90,9 @@ func GetEndpoint(ctx context.Context, m *mesheryv1alpha1.Broker, client *kuberne
return ErrGettingEndpoint(err)
}

log.Info("Discovered external endpoint: ", endpoint.External.Address, ":", endpoint.External.Port)
log.Info("Discovered internal endpoint: ", endpoint.Internal.Address, ":", endpoint.Internal.Port)

m.Status.Endpoint.External = fmt.Sprintf("%s:%d", endpoint.External.Address, endpoint.External.Port)
m.Status.Endpoint.Internal = fmt.Sprintf("%s:%d", endpoint.Internal.Address, endpoint.Internal.Port)
return nil
Expand Down

0 comments on commit f1dc850

Please sign in to comment.