From f784b4834c7c804be93f8b5fc230592d4a752450 Mon Sep 17 00:00:00 2001 From: Gorka Date: Tue, 25 Jun 2024 21:33:52 -0300 Subject: [PATCH] Debug --- .github/workflows/testnet_deploy_services.yml | 1 + pkg/jobcreator/controller.go | 4 ++++ pkg/jobcreator/onchain_jobcreator.go | 10 ++++++++- pkg/metricsDashboard/logger.go | 21 ++++++++++++++++++- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testnet_deploy_services.yml b/.github/workflows/testnet_deploy_services.yml index 10aceaea..7c273e41 100644 --- a/.github/workflows/testnet_deploy_services.yml +++ b/.github/workflows/testnet_deploy_services.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - gorka/debug-job-creator jobs: solver-build-deploy: diff --git a/pkg/jobcreator/controller.go b/pkg/jobcreator/controller.go index 6d9696f2..eda8e6d3 100644 --- a/pkg/jobcreator/controller.go +++ b/pkg/jobcreator/controller.go @@ -128,7 +128,11 @@ func (controller *JobCreatorController) subscribeToSolver() error { controller.log.Error("solver event", fmt.Errorf("RP received nil job offer")) return } + metricsDashboard.TrackJobOfferUpdate(*ev.JobOffer) for _, sub := range controller.jobOfferSubscriptions { + fmt.Println("===================") + fmt.Println("Calling the subscriptions") + fmt.Println("===================") go sub(*ev.JobOffer) } } diff --git a/pkg/jobcreator/onchain_jobcreator.go b/pkg/jobcreator/onchain_jobcreator.go index c06ce794..f1d7e12a 100644 --- a/pkg/jobcreator/onchain_jobcreator.go +++ b/pkg/jobcreator/onchain_jobcreator.go @@ -64,9 +64,17 @@ func (jobCreator *OnChainJobCreator) Start(ctx context.Context, cm *system.Clean return errorChan } - jobCreator.SubscribeToJobOfferUpdates(metricsDashboard.TrackJobOfferUpdate) + //jobCreator.SubscribeToJobOfferUpdates(metricsDashboard.TrackJobOfferUpdate) jobCreator.controller.SubscribeToJobOfferUpdates(func(evOffer data.JobOfferContainer) { + + fmt.Printf(" --------------------------------------\n") + fmt.Printf(" --------------------------------------\n") + spew.Dump(evOffer) + fmt.Printf(" --------------------------------------\n") + fmt.Printf(" --------------------------------------\n") + metricsDashboard.TrackJobOfferUpdate(evOffer) + if evOffer.State != data.GetAgreementStateIndex("ResultsAccepted") { return } diff --git a/pkg/metricsDashboard/logger.go b/pkg/metricsDashboard/logger.go index 8aef75fe..d44463b7 100644 --- a/pkg/metricsDashboard/logger.go +++ b/pkg/metricsDashboard/logger.go @@ -8,6 +8,7 @@ import ( "os" "time" + "github.com/davecgh/go-spew/spew" "github.com/lilypad-tech/lilypad/pkg/data" ) @@ -16,13 +17,24 @@ const nodeInfoEndpoint = "nodes" const nodeConnectionEndpoint = "uptimes" const dealsEndpoint = "deals" +var host = os.Getenv("API_HOST") + func trackEvent(path string, json string) { - var host = os.Getenv("API_HOST") + fmt.Println("===========<<") + fmt.Println() + fmt.Println(host, json) + fmt.Println() + fmt.Println("===========<<") if host == "" { return } + fmt.Println("===========>>") + fmt.Println() var url = host + "metrics-dashboard/" + path + fmt.Println() + fmt.Println("===========>>") + fmt.Println(url) data := []byte(json) @@ -39,6 +51,13 @@ func trackEvent(path string, json string) { } func TrackJobOfferUpdate(evOffer data.JobOfferContainer) { + fmt.Println("===========") + fmt.Println() + fmt.Println("TrackJobOfferUpdate") + fmt.Println(evOffer) + spew.Dump(evOffer) + fmt.Println() + fmt.Println("===========") var module = evOffer.JobOffer.Module.Name if module == "" { module = evOffer.JobOffer.Module.Repo + ":" + evOffer.JobOffer.Module.Hash