Skip to content

Commit 74bdad2

Browse files
committed
Remove deprecated flags
Signed-off-by: clyang82 <chuyang@redhat.com>
1 parent 36077c4 commit 74bdad2

35 files changed

+29
-1067
lines changed

CLAUDE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ make undeploy
108108
- **pkg/controllers/**: Event processing controllers and framework
109109
- **pkg/client/**: CloudEvents clients for MQTT and gRPC communication
110110
- **pkg/config/**: Configuration management for database, message brokers, and servers
111-
- **pkg/auth/**: Authentication and authorization middleware
112111

113112
### Key Concepts
114113
- **Resources**: Kubernetes manifests stored in the database and transported via CloudEvents

cmd/maestro/environments/e_development.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ func (e *devEnvImpl) VisitMessageBroker(c *MessageBroker) error {
2121
}
2222

2323
func (e *devEnvImpl) VisitConfig(c *ApplicationConfig) error {
24-
c.ApplicationConfig.HTTPServer.EnableJWT = false
25-
c.ApplicationConfig.HTTPServer.EnableHTTPS = false
2624
return nil
2725
}
2826

@@ -41,14 +39,10 @@ func (e *devEnvImpl) VisitClients(c *Clients) error {
4139
func (e *devEnvImpl) Flags() map[string]string {
4240
return map[string]string{
4341
"v": "10",
44-
"enable-authz": "false",
45-
"ocm-debug": "false",
46-
"enable-ocm-mock": "true",
4742
"enable-https": "false",
4843
"enable-metrics-https": "false",
4944
"server-hostname": "localhost",
5045
"http-server-bindport": "8000",
51-
"enable-sentry": "false",
5246
"source-id": "maestro",
5347
}
5448
}

cmd/maestro/environments/e_integration_testing.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,8 @@ func (e *testingEnvImpl) Flags() map[string]string {
4646
return map[string]string{
4747
"v": "0",
4848
"logtostderr": "true",
49-
"ocm-base-url": "https://api.integration.openshift.com",
5049
"enable-https": "false",
5150
"enable-metrics-https": "false",
52-
"enable-authz": "true",
53-
"ocm-debug": "false",
54-
"enable-ocm-mock": "true",
55-
"enable-sentry": "false",
5651
"source-id": "maestro",
5752
}
5853
}

cmd/maestro/environments/e_production.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ func (e *productionEnvImpl) VisitClients(c *Clients) error {
4040

4141
func (e *productionEnvImpl) Flags() map[string]string {
4242
return map[string]string{
43-
"v": "1",
44-
"ocm-debug": "false",
45-
"enable-ocm-mock": "true",
46-
"enable-sentry": "false",
47-
"source-id": "maestro",
43+
"v": "1",
44+
"source-id": "maestro",
4845
}
4946
}

cmd/maestro/environments/framework.go

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ package environments
33
import (
44
"fmt"
55
"log"
6-
"os"
76
"strings"
87

9-
"github.com/getsentry/sentry-go"
108
"github.com/spf13/pflag"
119
"k8s.io/client-go/kubernetes"
1210
"k8s.io/client-go/rest"
@@ -18,7 +16,6 @@ import (
1816
envtypes "github.com/openshift-online/maestro/cmd/maestro/environments/types"
1917
"github.com/openshift-online/maestro/pkg/client/cloudevents"
2018
"github.com/openshift-online/maestro/pkg/client/grpcauthorizer"
21-
"github.com/openshift-online/maestro/pkg/client/ocm"
2219
"github.com/openshift-online/maestro/pkg/config"
2320
"github.com/openshift-online/maestro/pkg/errors"
2421
)
@@ -84,8 +81,6 @@ func (e *Env) Initialize() error {
8481

8582
messages := environment.Config.ReadFiles()
8683
if len(messages) != 0 {
87-
err := fmt.Errorf("unable to read configuration files:\n%s", strings.Join(messages, "\n"))
88-
sentry.CaptureException(err)
8984
log.Fatalf("Unable to read configuration files:\n%s", strings.Join(messages, "\n"))
9085
}
9186

@@ -112,11 +107,6 @@ func (e *Env) Initialize() error {
112107
log.Fatalf("Failed to visit Clients: %s", err)
113108
}
114109

115-
err = e.InitializeSentry()
116-
if err != nil {
117-
return fmt.Errorf("failed to initialize sentry: %w", err)
118-
}
119-
120110
seedErr := e.Seed()
121111
if seedErr != nil {
122112
return seedErr
@@ -144,28 +134,6 @@ func (e *Env) LoadServices() {
144134
}
145135

146136
func (e *Env) LoadClients() error {
147-
var err error
148-
149-
ocmConfig := ocm.Config{
150-
BaseURL: e.Config.OCM.BaseURL,
151-
ClientID: e.Config.OCM.ClientID,
152-
ClientSecret: e.Config.OCM.ClientSecret,
153-
SelfToken: e.Config.OCM.SelfToken,
154-
TokenURL: e.Config.OCM.TokenURL,
155-
Debug: e.Config.OCM.Debug,
156-
}
157-
158-
// Create OCM Authz client
159-
if e.Config.OCM.EnableMock {
160-
klog.V(4).Info("Using Mock OCM Authz Client")
161-
e.Clients.OCM, err = ocm.NewClientMock(ocmConfig)
162-
} else {
163-
e.Clients.OCM, err = ocm.NewClient(ocmConfig)
164-
}
165-
if err != nil {
166-
return fmt.Errorf("Unable to create OCM Authz client: %v", err)
167-
}
168-
169137
// Create CloudEvents Source client
170138
if e.Config.MessageBroker.EnableMock {
171139
klog.V(4).Info("Using Mock CloudEvents Source Client")
@@ -218,54 +186,11 @@ func (e *Env) LoadClients() error {
218186
return nil
219187
}
220188

221-
func (e *Env) InitializeSentry() error {
222-
options := sentry.ClientOptions{}
223-
224-
if e.Config.Sentry.Enabled {
225-
key := e.Config.Sentry.Key
226-
url := e.Config.Sentry.URL
227-
project := e.Config.Sentry.Project
228-
klog.V(4).Infof("Sentry error reporting enabled to %s on project %s", url, project)
229-
options.Dsn = fmt.Sprintf("https://%s@%s/%s", key, url, project)
230-
} else {
231-
// Setting the DSN to an empty string effectively disables sentry
232-
// See https://godoc.org/github.com/getsentry/sentry-go#ClientOptions Dsn
233-
klog.V(4).Info("Disabling Sentry error reporting")
234-
options.Dsn = ""
235-
}
236-
237-
transport := sentry.NewHTTPTransport()
238-
transport.Timeout = e.Config.Sentry.Timeout
239-
// since sentry.HTTPTransport is asynchronous, Sentry needs a buffer to cache pending requests.
240-
// the BufferSize is the size of the buffer. Sentry drops requests when the buffer is full:
241-
// https://github.com/getsentry/sentry-go/blob/4f72d7725080f61e924409c8ddd008739fd4a837/transport.go#L312
242-
// errors in our system are relatively sparse, we don't need a large BufferSize.
243-
transport.BufferSize = 10
244-
options.Transport = transport
245-
options.Debug = e.Config.Sentry.Debug
246-
options.AttachStacktrace = true
247-
options.Environment = e.Name
248-
249-
hostname, err := os.Hostname()
250-
if err != nil && hostname != "" {
251-
options.ServerName = hostname
252-
}
253-
// TODO figure out some way to set options.Release and options.Dist
254-
255-
err = sentry.Init(options)
256-
if err != nil {
257-
return fmt.Errorf("Unable to initialize sentry integration: %s", err.Error())
258-
}
259-
260-
return nil
261-
}
262-
263189
func (e *Env) Teardown() {
264190
if e.Name != envtypes.TestingEnv {
265191
if err := e.Database.SessionFactory.Close(); err != nil {
266192
log.Fatalf("Unable to close db connection: %s", err.Error())
267193
}
268-
e.Clients.OCM.Close()
269194
}
270195
}
271196

cmd/maestro/environments/types.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ package environments
33
import (
44
"sync"
55

6-
"github.com/openshift-online/maestro/pkg/auth"
76
"github.com/openshift-online/maestro/pkg/client/cloudevents"
87
"github.com/openshift-online/maestro/pkg/client/grpcauthorizer"
9-
"github.com/openshift-online/maestro/pkg/client/ocm"
108
"github.com/openshift-online/maestro/pkg/config"
119
"github.com/openshift-online/maestro/pkg/db"
1210
)
@@ -36,7 +34,6 @@ type MessageBroker struct {
3634
}
3735

3836
type Handlers struct {
39-
AuthMiddleware auth.JWTMiddleware
4037
}
4138

4239
type Services struct {
@@ -48,7 +45,6 @@ type Services struct {
4845
}
4946

5047
type Clients struct {
51-
OCM *ocm.Client
5248
GRPCAuthorizer grpcauthorizer.GRPCAuthorizer
5349
CloudEventsSource cloudevents.SourceClient
5450
}
@@ -57,7 +53,6 @@ type ConfigDefaults struct {
5753
Server map[string]interface{}
5854
Metrics map[string]interface{}
5955
Database map[string]interface{}
60-
OCM map[string]interface{}
6156
Options map[string]interface{}
6257
}
6358

cmd/maestro/server/api_server.go

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ import (
77
"net/http"
88
"time"
99

10-
sentryhttp "github.com/getsentry/sentry-go/http"
1110
"github.com/ghodss/yaml"
12-
_ "github.com/golang-jwt/jwt/v4"
13-
"github.com/golang/glog"
1411
gorillahandlers "github.com/gorilla/handlers"
15-
sdk "github.com/openshift-online/ocm-sdk-go"
16-
"github.com/openshift-online/ocm-sdk-go/authentication"
1712
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
1813
"k8s.io/klog/v2"
1914

@@ -40,72 +35,11 @@ func NewAPIServer(ctx context.Context, eventBroadcaster *event.EventBroadcaster)
4035

4136
mainRouter := s.routes(ctx)
4237

43-
// Sentryhttp middleware performs two operations:
44-
// 1) Attaches an instance of *sentry.Hub to the request’s context. Accessit by using the sentry.GetHubFromContext() method on the request
45-
// NOTE this is the only way middleware, handlers, and services should be reporting to sentry, through the hub
46-
// 2) Reports panics to the configured sentry service
47-
if env().Config.Sentry.Enabled {
48-
sentryhttpOptions := sentryhttp.Options{
49-
Repanic: true,
50-
WaitForDelivery: false,
51-
Timeout: env().Config.Sentry.Timeout,
52-
}
53-
sentryMW := sentryhttp.New(sentryhttpOptions)
54-
mainRouter.Use(sentryMW.Handle)
55-
}
56-
5738
// referring to the router as type http.Handler allows us to add middleware via more handlers
5839
var mainHandler http.Handler = mainRouter
5940

60-
if env().Config.HTTPServer.EnableJWT {
61-
// Create the logger for the authentication handler:
62-
authnLogger, err := sdk.NewGlogLoggerBuilder().
63-
InfoV(glog.Level(1)).
64-
DebugV(glog.Level(5)).
65-
Build()
66-
check(ctx, err, "Unable to create authentication logger")
67-
68-
// Create the handler that verifies that tokens are valid:
69-
mainHandler, err = authentication.NewHandler().
70-
Logger(authnLogger).
71-
KeysFile(env().Config.HTTPServer.JwkCertFile).
72-
KeysURL(env().Config.HTTPServer.JwkCertURL).
73-
ACLFile(env().Config.HTTPServer.ACLFile).
74-
Public("^/api/maestro/?$").
75-
Public("^/api/maestro/v1/?$").
76-
Public("^/api/maestro/v1/openapi/?$").
77-
Public("^/api/maestro/v1/errors(/.*)?$").
78-
Next(mainHandler).
79-
Build()
80-
check(ctx, err, "Unable to create authentication handler")
81-
}
82-
83-
// TODO: remove all cloud.redhat.com once migration to console.redhat.com is complete
84-
// refer to: https://issues.redhat.com/browse/RHCLOUD-14695
8541
mainHandler = gorillahandlers.CORS(
86-
gorillahandlers.AllowedOrigins([]string{
87-
// OCM UI local development URLs
88-
"https://qa.foo.redhat.com:1337",
89-
"https://prod.foo.redhat.com:1337",
90-
"https://ci.foo.redhat.com:1337",
91-
"https://cloud.redhat.com", // TODO: remove
92-
"https://console.redhat.com", // Production / candidate
93-
// Staging and test environments
94-
"https://qaprodauth.cloud.redhat.com", // TODO: remove
95-
"https://qa.cloud.redhat.com", // TODO: remove
96-
"https://ci.cloud.redhat.com", // TODO: remove
97-
"https://qaprodauth.console.redhat.com",
98-
"https://qa.console.redhat.com",
99-
"https://ci.console.redhat.com",
100-
"https://console.stage.redhat.com",
101-
// API docs UI
102-
"https://api.stage.openshift.com",
103-
"https://api.openshift.com",
104-
// Customer portal
105-
"https://access.qa.redhat.com",
106-
"https://access.stage.redhat.com",
107-
"https://access.redhat.com",
108-
}),
42+
gorillahandlers.AllowedOrigins([]string{}),
10943
gorillahandlers.AllowedMethods([]string{
11044
http.MethodDelete,
11145
http.MethodGet,

cmd/maestro/server/routes.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/openshift-online/maestro/cmd/maestro/server/logging"
1111
"github.com/openshift-online/maestro/pkg/api"
12-
"github.com/openshift-online/maestro/pkg/auth"
1312
"github.com/openshift-online/maestro/pkg/db"
1413
"github.com/openshift-online/maestro/pkg/handlers"
1514
"github.com/openshift-online/maestro/pkg/logger"
@@ -27,9 +26,6 @@ func (s *apiServer) routes(ctx context.Context) *mux.Router {
2726
consumerHandler := handlers.NewConsumerHandler(services.Consumers(), services.Resources(), services.Generic())
2827
errorsHandler := handlers.NewErrorsHandler()
2928

30-
authMiddleware := &auth.AuthMiddlewareMock{}
31-
authzMiddleware := auth.NewAuthzMiddlewareMock()
32-
3329
// mainRouter is top level "/"
3430
mainRouter := mux.NewRouter()
3531
mainRouter.NotFoundHandler = http.HandlerFunc(api.SendNotFound)
@@ -63,8 +59,6 @@ func (s *apiServer) routes(ctx context.Context) *mux.Router {
6359
apiV1ResourceBundleRouter.HandleFunc("", resourceBundleHandler.List).Methods(http.MethodGet)
6460
apiV1ResourceBundleRouter.HandleFunc("/{id}", resourceBundleHandler.Get).Methods(http.MethodGet)
6561
apiV1ResourceBundleRouter.HandleFunc("/{id}", resourceBundleHandler.Delete).Methods(http.MethodDelete)
66-
apiV1ResourceBundleRouter.Use(authMiddleware.AuthenticateAccountJWT)
67-
apiV1ResourceBundleRouter.Use(authzMiddleware.AuthorizeApi)
6862

6963
// /api/maestro/v1/consumers
7064
apiV1ConsumersRouter := apiV1Router.PathPrefix("/consumers").Subrouter()
@@ -73,8 +67,6 @@ func (s *apiServer) routes(ctx context.Context) *mux.Router {
7367
apiV1ConsumersRouter.HandleFunc("", consumerHandler.Create).Methods(http.MethodPost)
7468
apiV1ConsumersRouter.HandleFunc("/{id}", consumerHandler.Patch).Methods(http.MethodPatch)
7569
apiV1ConsumersRouter.HandleFunc("/{id}", consumerHandler.Delete).Methods(http.MethodDelete)
76-
apiV1ConsumersRouter.Use(authMiddleware.AuthenticateAccountJWT)
77-
apiV1ConsumersRouter.Use(authzMiddleware.AuthorizeApi)
7870

7971
return mainRouter
8072
}

cmd/maestro/server/server.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import (
77
"os"
88
"strings"
99

10-
"github.com/getsentry/sentry-go"
1110
"k8s.io/klog/v2"
12-
13-
"github.com/openshift-online/maestro/cmd/maestro/environments"
1411
)
1512

1613
type Server interface {
@@ -32,8 +29,6 @@ func check(ctx context.Context, err error, msg string) {
3229
if err != nil && err != http.ErrServerClosed {
3330
logger := klog.FromContext(ctx)
3431
logger.Error(err, msg)
35-
sentry.CaptureException(err)
36-
sentry.Flush(environments.Environment().Config.Sentry.Timeout)
3732
os.Exit(1)
3833
}
3934
}

0 commit comments

Comments
 (0)