Skip to content

Commit ee6b0b7

Browse files
committed
chore: replace TRS with local package
Replace the github.com/Cray-HPE/hms-trs-app-api/ package with a local copy that lacks the Kafka implementation. Removes serialization code that's not necessary for locally-issued HTTP requests. Removes workarounds for bugs in older Go versions. Removes unused logger cruft. Signed-off-by: Travis Raines <571832+rainest@users.noreply.github.com>
1 parent e8e86ae commit ee6b0b7

14 files changed

Lines changed: 1339 additions & 295 deletions

cmd/power-control/service.go

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
base "github.com/Cray-HPE/hms-base/v2"
1414
"github.com/Cray-HPE/hms-certs/pkg/hms_certs"
15-
trsapi "github.com/Cray-HPE/hms-trs-app-api/v3/pkg/trs_http_api"
1615
"github.com/sirupsen/logrus"
1716
"golang.org/x/oauth2"
1817
"golang.org/x/oauth2/clientcredentials"
@@ -23,6 +22,7 @@ import (
2322
"github.com/OpenCHAMI/power-control/v2/internal/hsm"
2423
"github.com/OpenCHAMI/power-control/v2/internal/logger"
2524
"github.com/OpenCHAMI/power-control/v2/internal/storage"
25+
"github.com/OpenCHAMI/power-control/v2/internal/taskrun"
2626
)
2727

2828
// Default Port to use
@@ -59,7 +59,7 @@ var (
5959
restSrv *http.Server = nil
6060
waitGroup sync.WaitGroup
6161
rfClient, svcClient *hms_certs.HTTPClientPair
62-
TLOC_rf, TLOC_svc trsapi.TrsAPI
62+
TLOC_rf, TLOC_svc taskrun.TrsAPI
6363
caURI string
6464
rfClientLock *sync.RWMutex = &sync.RWMutex{}
6565
serviceName string
@@ -148,7 +148,7 @@ func runPCS(pcs *pcsConfig, etcd *etcdConfig, postgres *storage.PostgresConfig,
148148
}
149149
}
150150

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

174-
envstr = os.Getenv("TRS_IMPLEMENTATION")
175-
176-
if envstr == "REMOTE" {
177-
workerSec := &trsapi.TRSHTTPRemote{}
178-
workerSec.Logger = trsLogger
179-
workerInsec := &trsapi.TRSHTTPRemote{}
180-
workerInsec.Logger = trsLogger
181-
TLOC_rf = workerSec
182-
TLOC_svc = workerInsec
183-
logger.Log.Infof("Using TRS_IMPLEMENTATION: REMOTE")
184-
} else {
185-
workerSec := &trsapi.TRSHTTPLocal{}
186-
workerSec.Logger = trsLogger
187-
workerInsec := &trsapi.TRSHTTPLocal{}
188-
workerInsec.Logger = trsLogger
189-
TLOC_rf = workerSec
190-
TLOC_svc = workerInsec
191-
logger.Log.Infof("Using TRS_IMPLEMENTATION: LOCAL")
192-
}
174+
workerSec := &taskrun.TRSHTTPLocal{}
175+
workerSec.Logger = trsLogger
176+
workerInsec := &taskrun.TRSHTTPLocal{}
177+
workerInsec.Logger = trsLogger
178+
TLOC_rf = workerSec
179+
TLOC_svc = workerInsec
193180

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

@@ -448,7 +435,7 @@ func runPCS(pcs *pcsConfig, etcd *etcdConfig, postgres *storage.PostgresConfig,
448435
logger.Log.Infof("Locking RF operations...")
449436
rfClientLock.Lock() //waits for all RW locks to release
450437
tchain := hms_certs.NewlineToTuple(caChain)
451-
secInfo := trsapi.TRSHTTPLocalSecurity{CACertBundleData: tchain}
438+
secInfo := taskrun.TRSHTTPLocalSecurity{CACertBundleData: tchain}
452439
err = TLOC_rf.SetSecurity(secInfo)
453440
if err != nil {
454441
logger.Log.Errorf("Error setting TLOC security info: %v, retrying...",

go.mod

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ require (
1010
github.com/Cray-HPE/hms-compcredentials v1.15.0
1111
github.com/Cray-HPE/hms-hmetcd v1.13.0
1212
github.com/Cray-HPE/hms-securestorage v1.17.0
13-
github.com/Cray-HPE/hms-trs-app-api/v3 v3.0.5
1413
github.com/Cray-HPE/hms-xname v1.4.0
1514
github.com/OpenCHAMI/jwtauth/v5 v5.0.0-20240321222802-e6cb468a2a18
1615
github.com/OpenCHAMI/smd/v2 v2.19.1
1716
github.com/go-chi/chi/v5 v5.2.1
1817
github.com/golang-migrate/migrate/v4 v4.18.3
1918
github.com/google/go-cmp v0.7.0
2019
github.com/google/uuid v1.6.0
20+
github.com/hashicorp/go-retryablehttp v0.7.7
2121
github.com/jmoiron/sqlx v1.4.0
2222
github.com/lestrrat-go/jwx v1.2.30
2323
github.com/lib/pq v1.10.9
@@ -38,10 +38,8 @@ require (
3838
require (
3939
dario.cat/mergo v1.0.1 // indirect
4040
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
41-
github.com/Cray-HPE/hms-trs-kafkalib/v2 v2.0.2 // indirect
4241
github.com/Microsoft/go-winio v0.6.2 // indirect
4342
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
44-
github.com/confluentinc/confluent-kafka-go/v2 v2.10.0 // indirect
4543
github.com/containerd/log v0.1.0 // indirect
4644
github.com/containerd/platforms v0.2.1 // indirect
4745
github.com/coreos/go-semver v0.3.1 // indirect
@@ -66,7 +64,6 @@ require (
6664
github.com/hashicorp/errwrap v1.1.0 // indirect
6765
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
6866
github.com/hashicorp/go-multierror v1.1.1 // indirect
69-
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
7067
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
7168
github.com/hashicorp/go-secure-stdlib/parseutil v0.2.0 // indirect
7269
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
@@ -112,14 +109,15 @@ require (
112109
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
113110
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
114111
go.opentelemetry.io/otel v1.35.0 // indirect
112+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect
115113
go.opentelemetry.io/otel/metric v1.35.0 // indirect
116114
go.opentelemetry.io/otel/trace v1.35.0 // indirect
117115
go.uber.org/atomic v1.11.0 // indirect
118116
go.uber.org/multierr v1.11.0 // indirect
119117
go.uber.org/zap v1.27.0 // indirect
120118
golang.org/x/crypto v0.37.0 // indirect
121119
golang.org/x/net v0.39.0 // indirect
122-
golang.org/x/sys v0.32.0 // indirect
120+
golang.org/x/sys v0.33.0 // indirect
123121
golang.org/x/text v0.24.0 // indirect
124122
golang.org/x/time v0.11.0 // indirect
125123
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e // indirect

0 commit comments

Comments
 (0)