Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions cmd/power-control/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

base "github.com/Cray-HPE/hms-base/v2"
"github.com/Cray-HPE/hms-certs/pkg/hms_certs"
trsapi "github.com/Cray-HPE/hms-trs-app-api/v3/pkg/trs_http_api"
"github.com/sirupsen/logrus"
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"
Expand All @@ -23,6 +22,7 @@ import (
"github.com/OpenCHAMI/power-control/v2/internal/hsm"
"github.com/OpenCHAMI/power-control/v2/internal/logger"
"github.com/OpenCHAMI/power-control/v2/internal/storage"
"github.com/OpenCHAMI/power-control/v2/internal/taskrun"
)

// Default Port to use
Expand Down Expand Up @@ -59,7 +59,7 @@ var (
restSrv *http.Server = nil
waitGroup sync.WaitGroup
rfClient, svcClient *hms_certs.HTTPClientPair
TLOC_rf, TLOC_svc trsapi.TrsAPI
TLOC_rf, TLOC_svc taskrun.TrsAPI
caURI string
rfClientLock *sync.RWMutex = &sync.RWMutex{}
serviceName string
Expand Down Expand Up @@ -148,7 +148,7 @@ func runPCS(pcs *pcsConfig, etcd *etcdConfig, postgres *storage.PostgresConfig,
}
}

var BaseTRSTask trsapi.HttpTask
var BaseTRSTask taskrun.HttpTask
BaseTRSTask.ServiceName = serviceName
BaseTRSTask.Timeout = time.Duration(baseTrsTaskTimeout) * time.Second
BaseTRSTask.Request, _ = http.NewRequest("GET", "", nil)
Expand All @@ -171,25 +171,12 @@ func runPCS(pcs *pcsConfig, etcd *etcdConfig, postgres *storage.PostgresConfig,
trsLogger.SetLevel(logger.Log.GetLevel())
trsLogger.SetReportCaller(true)

envstr = os.Getenv("TRS_IMPLEMENTATION")

if envstr == "REMOTE" {
workerSec := &trsapi.TRSHTTPRemote{}
workerSec.Logger = trsLogger
workerInsec := &trsapi.TRSHTTPRemote{}
workerInsec.Logger = trsLogger
TLOC_rf = workerSec
TLOC_svc = workerInsec
logger.Log.Infof("Using TRS_IMPLEMENTATION: REMOTE")
} else {
workerSec := &trsapi.TRSHTTPLocal{}
workerSec.Logger = trsLogger
workerInsec := &trsapi.TRSHTTPLocal{}
workerInsec.Logger = trsLogger
TLOC_rf = workerSec
TLOC_svc = workerInsec
logger.Log.Infof("Using TRS_IMPLEMENTATION: LOCAL")
}
workerSec := &taskrun.TRSHTTPLocal{}
workerSec.Logger = trsLogger
workerInsec := &taskrun.TRSHTTPLocal{}
workerInsec.Logger = trsLogger
TLOC_rf = workerSec
TLOC_svc = workerInsec

//Set up TRS TLOCs and HTTP clients, all insecure to start with

Expand Down Expand Up @@ -448,7 +435,7 @@ func runPCS(pcs *pcsConfig, etcd *etcdConfig, postgres *storage.PostgresConfig,
logger.Log.Infof("Locking RF operations...")
rfClientLock.Lock() //waits for all RW locks to release
tchain := hms_certs.NewlineToTuple(caChain)
secInfo := trsapi.TRSHTTPLocalSecurity{CACertBundleData: tchain}
secInfo := taskrun.TRSHTTPLocalSecurity{CACertBundleData: tchain}
err = TLOC_rf.SetSecurity(secInfo)
if err != nil {
logger.Log.Errorf("Error setting TLOC security info: %v, retrying...",
Expand Down
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ require (
github.com/Cray-HPE/hms-compcredentials v1.15.0
github.com/Cray-HPE/hms-hmetcd v1.13.0
github.com/Cray-HPE/hms-securestorage v1.17.0
github.com/Cray-HPE/hms-trs-app-api/v3 v3.0.5
github.com/Cray-HPE/hms-xname v1.4.0
github.com/OpenCHAMI/jwtauth/v5 v5.0.0-20240321222802-e6cb468a2a18
github.com/OpenCHAMI/smd/v2 v2.19.1
github.com/go-chi/chi/v5 v5.2.1
github.com/golang-migrate/migrate/v4 v4.18.3
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.0
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/jmoiron/sqlx v1.4.0
github.com/lestrrat-go/jwx v1.2.30
github.com/lib/pq v1.10.9
Expand All @@ -38,10 +38,8 @@ require (
require (
dario.cat/mergo v1.0.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Cray-HPE/hms-trs-kafkalib/v2 v2.0.2 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/confluentinc/confluent-kafka-go/v2 v2.10.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
Expand All @@ -66,7 +64,6 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.2.0 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
Expand Down Expand Up @@ -112,14 +109,15 @@ require (
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.35.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.35.0 // indirect
go.opentelemetry.io/otel/trace v1.35.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.37.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/time v0.11.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e // indirect
Expand Down
Loading
Loading