diff --git a/config/manager/config.toml b/config/manager/config.toml index f6191f0..4566edc 100644 --- a/config/manager/config.toml +++ b/config/manager/config.toml @@ -6,7 +6,7 @@ urls = ["mqtt://mqtt:1883"] [ocpi] addr = ":9411" -external_url = "http://host.docker.internal:9411" +external_url = "http://lb:9411" country_code = "GB" party_id = "TWK" diff --git a/manager/ocpi/register.go b/manager/ocpi/register.go index a2ea83c..fbdc27b 100644 --- a/manager/ocpi/register.go +++ b/manager/ocpi/register.go @@ -10,6 +10,7 @@ import ( "errors" "fmt" "github.com/thoughtworks/maeve-csms/manager/store" + "golang.org/x/exp/slog" "io" "math/big" "net/http" @@ -17,10 +18,12 @@ import ( func (o *OCPI) RegisterNewParty(ctx context.Context, url, token string) error { reg, err := o.store.GetRegistrationDetails(ctx, token) + slog.Info("registering", "reg", reg) if err != nil { return err } if reg != nil && reg.Status == store.OcpiRegistrationStatusRegistered { + slog.Error("already registered", "token", token) return errors.New("already registered") } diff --git a/manager/ocpi/server.go b/manager/ocpi/server.go index dedbb34..1c550e5 100644 --- a/manager/ocpi/server.go +++ b/manager/ocpi/server.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "github.com/go-chi/render" + "golang.org/x/exp/slog" "k8s.io/utils/clock" "net/http" "time" @@ -79,6 +80,7 @@ func (s *Server) PostCredentials(w http.ResponseWriter, r *http.Request, params err := s.ocpi.SetCredentials(r.Context(), matches[1], *creds) if err != nil { + slog.Error("Error setting credentials", "err", err) _ = render.Render(w, r, ErrInternalError(err)) return } diff --git a/manager/store/firestore/ocpi.go b/manager/store/firestore/ocpi.go index db78ba4..07d8fd6 100644 --- a/manager/store/firestore/ocpi.go +++ b/manager/store/firestore/ocpi.go @@ -6,12 +6,14 @@ import ( "context" "fmt" "github.com/thoughtworks/maeve-csms/manager/store" + "golang.org/x/exp/slog" "google.golang.org/api/iterator" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) func (s *Store) SetRegistrationDetails(ctx context.Context, token string, registration *store.OcpiRegistration) error { + slog.Info("setting registration", "token", token, "status", registration.Status) regRef := s.client.Doc(fmt.Sprintf("OcpiRegistration/%s", token)) _, err := regRef.Set(ctx, registration) if err != nil { @@ -21,6 +23,7 @@ func (s *Store) SetRegistrationDetails(ctx context.Context, token string, regist } func (s *Store) GetRegistrationDetails(ctx context.Context, token string) (*store.OcpiRegistration, error) { + slog.Info("checking registration", "token", token) regRef := s.client.Doc(fmt.Sprintf("OcpiRegistration/%s", token)) snap, err := regRef.Get(ctx) if err != nil { @@ -31,6 +34,7 @@ func (s *Store) GetRegistrationDetails(ctx context.Context, token string) (*stor } var registration store.OcpiRegistration err = snap.DataTo(®istration) + slog.Info("found registration", "status", registration.Status) if err != nil { return nil, fmt.Errorf("map registration %s: %w", token, err) }