remove pkg/env from pkg/monitor

This commit is contained in:
Jim Minter 2020-09-25 15:54:23 -05:00
Родитель ce01e2107b
Коммит 2503d1f09c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 0730CBDA10D1A2D3
5 изменённых файлов: 19 добавлений и 13 удалений

Просмотреть файл

@ -19,6 +19,7 @@ import (
"github.com/Azure/ARO-RP/pkg/metrics/statsd/azure"
"github.com/Azure/ARO-RP/pkg/metrics/statsd/k8s"
pkgmonitor "github.com/Azure/ARO-RP/pkg/monitor"
"github.com/Azure/ARO-RP/pkg/proxy"
"github.com/Azure/ARO-RP/pkg/util/deployment"
"github.com/Azure/ARO-RP/pkg/util/encryption"
)
@ -27,7 +28,7 @@ func monitor(ctx context.Context, log *logrus.Entry) error {
uuid := uuid.NewV4().String()
log.Printf("uuid %s", uuid)
_env, err := env.NewEnv(ctx, log)
_env, err := env.NewCore(ctx, log)
if err != nil {
return err
}
@ -68,7 +69,12 @@ func monitor(ctx context.Context, log *logrus.Entry) error {
return err
}
mon := pkgmonitor.NewMonitor(log.WithField("component", "monitor"), _env, db, m, clusterm)
dialer, err := proxy.NewDialer(_env.DeploymentMode())
if err != nil {
return err
}
mon := pkgmonitor.NewMonitor(log.WithField("component", "monitor"), dialer, db, m, clusterm)
return mon.Run(ctx)
}

Просмотреть файл

@ -18,14 +18,14 @@ import (
"k8s.io/client-go/kubernetes"
"github.com/Azure/ARO-RP/pkg/api"
"github.com/Azure/ARO-RP/pkg/env"
"github.com/Azure/ARO-RP/pkg/metrics"
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned/typed/aro.openshift.io/v1alpha1"
"github.com/Azure/ARO-RP/pkg/proxy"
"github.com/Azure/ARO-RP/pkg/util/restconfig"
)
type Monitor struct {
env env.Interface
dialer proxy.Dialer
log *logrus.Entry
hourlyRun bool
@ -46,7 +46,7 @@ type Monitor struct {
}
}
func NewMonitor(ctx context.Context, env env.Interface, log *logrus.Entry, oc *api.OpenShiftCluster, m metrics.Interface, hourlyRun bool) (*Monitor, error) {
func NewMonitor(ctx context.Context, dialer proxy.Dialer, log *logrus.Entry, oc *api.OpenShiftCluster, m metrics.Interface, hourlyRun bool) (*Monitor, error) {
r, err := azure.ParseResourceID(oc.ID)
if err != nil {
return nil, err
@ -59,7 +59,7 @@ func NewMonitor(ctx context.Context, env env.Interface, log *logrus.Entry, oc *a
"resourceName": r.ResourceName,
}
restConfig, err := restconfig.RestConfig(env, oc)
restConfig, err := restconfig.RestConfig(dialer, oc)
if err != nil {
return nil, err
}
@ -93,7 +93,7 @@ func NewMonitor(ctx context.Context, env env.Interface, log *logrus.Entry, oc *a
}
return &Monitor{
env: env,
dialer: dialer,
log: log,
hourlyRun: hourlyRun,

Просмотреть файл

@ -30,7 +30,7 @@ func (mon *Monitor) emitPrometheusAlerts(ctx context.Context) error {
return nil, err
}
return portforward.DialContext(ctx, mon.log, mon.env, mon.oc, "openshift-monitoring", fmt.Sprintf("alertmanager-main-%d", i), port)
return portforward.DialContext(ctx, mon.log, mon.dialer, mon.oc, "openshift-monitoring", fmt.Sprintf("alertmanager-main-%d", i), port)
},
},
}

Просмотреть файл

@ -15,15 +15,15 @@ import (
"github.com/Azure/ARO-RP/pkg/api"
"github.com/Azure/ARO-RP/pkg/database"
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
"github.com/Azure/ARO-RP/pkg/env"
"github.com/Azure/ARO-RP/pkg/metrics"
"github.com/Azure/ARO-RP/pkg/proxy"
"github.com/Azure/ARO-RP/pkg/util/bucket"
"github.com/Azure/ARO-RP/pkg/util/heartbeat"
)
type monitor struct {
baseLog *logrus.Entry
env env.Interface
dialer proxy.Dialer
db *database.Database
m metrics.Interface
clusterm metrics.Interface
@ -44,10 +44,10 @@ type Runnable interface {
Run(context.Context) error
}
func NewMonitor(log *logrus.Entry, env env.Interface, db *database.Database, m, clusterm metrics.Interface) Runnable {
func NewMonitor(log *logrus.Entry, dialer proxy.Dialer, db *database.Database, m, clusterm metrics.Interface) Runnable {
return &monitor{
baseLog: log,
env: env,
dialer: dialer,
db: db,
m: m,
clusterm: clusterm,

Просмотреть файл

@ -191,7 +191,7 @@ func (mon *monitor) workOne(ctx context.Context, log *logrus.Entry, doc *api.Ope
ctx, cancel := context.WithTimeout(ctx, 50*time.Second)
defer cancel()
c, err := cluster.NewMonitor(ctx, mon.env, log, doc.OpenShiftCluster, mon.clusterm, hourlyRun)
c, err := cluster.NewMonitor(ctx, mon.dialer, log, doc.OpenShiftCluster, mon.clusterm, hourlyRun)
if err != nil {
log.Error(err)
return