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
25 changes: 20 additions & 5 deletions cmd/aro/mimoactuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ import (

"github.com/sirupsen/logrus"

kmetrics "k8s.io/client-go/tools/metrics"

"github.com/Azure/go-autorest/tracing"

"github.com/Azure/ARO-RP/pkg/database"
"github.com/Azure/ARO-RP/pkg/env"
"github.com/Azure/ARO-RP/pkg/metrics/statsd"
"github.com/Azure/ARO-RP/pkg/metrics/statsd/azure"
"github.com/Azure/ARO-RP/pkg/metrics/statsd/golang"
"github.com/Azure/ARO-RP/pkg/metrics/statsd/k8s"
"github.com/Azure/ARO-RP/pkg/mimo/actuator"
"github.com/Azure/ARO-RP/pkg/mimo/tasks"
"github.com/Azure/ARO-RP/pkg/proxy"
Expand Down Expand Up @@ -52,6 +58,12 @@ func mimoActuator(ctx context.Context, _log *logrus.Entry) error {
}
go g.Run()

tracing.Register(azure.New(m))
kmetrics.Register(kmetrics.RegisterOpts{
RequestResult: k8s.NewResult(m),
RequestLatency: k8s.NewLatency(m),
})

aead, err := encryption.NewAEADWithCore(ctx, _env, env.EncryptionSecretV2Name, env.EncryptionSecretName)
if err != nil {
return err
Expand All @@ -77,9 +89,15 @@ func mimoActuator(ctx context.Context, _log *logrus.Entry) error {
return err
}

poolWorkers, err := database.NewPoolWorkers(ctx, dbc, dbName)
if err != nil {
return err
}

dbg := database.NewDBGroup().
WithOpenShiftClusters(clusters).
WithMaintenanceManifests(manifests)
WithMaintenanceManifests(manifests).
WithPoolWorkers(poolWorkers)

go database.EmitMIMOMetrics(ctx, _env.LoggerForComponent("metrics"), manifests, m)

Expand All @@ -88,10 +106,7 @@ func mimoActuator(ctx context.Context, _log *logrus.Entry) error {
return err
}

buckets := actuator.DetermineBuckets(_env, os.Hostname)
log.Printf("serving %d buckets: %v", len(buckets), buckets)

a := actuator.NewService(_env, log, dialer, dbg, m, buckets)
a := actuator.NewService(_env, log, dialer, dbg, m)
a.SetMaintenanceTasks(tasks.DEFAULT_MAINTENANCE_TASKS)

sigterm := make(chan os.Signal, 1)
Expand Down
19 changes: 13 additions & 6 deletions cmd/aro/mimoscheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import (

"github.com/sirupsen/logrus"

"github.com/Azure/go-autorest/tracing"

"github.com/Azure/ARO-RP/pkg/database"
"github.com/Azure/ARO-RP/pkg/env"
"github.com/Azure/ARO-RP/pkg/metrics/statsd"
"github.com/Azure/ARO-RP/pkg/metrics/statsd/azure"
"github.com/Azure/ARO-RP/pkg/metrics/statsd/golang"
"github.com/Azure/ARO-RP/pkg/mimo/actuator"
"github.com/Azure/ARO-RP/pkg/mimo/scheduler"
"github.com/Azure/ARO-RP/pkg/mimo/tasks"
"github.com/Azure/ARO-RP/pkg/util/encryption"
Expand Down Expand Up @@ -52,6 +54,8 @@ func mimoScheduler(ctx context.Context, _log *logrus.Entry) error {
}
go g.Run()

tracing.Register(azure.New(m))

aead, err := encryption.NewAEADWithCore(ctx, _env, env.EncryptionSecretV2Name, env.EncryptionSecretName)
if err != nil {
return err
Expand Down Expand Up @@ -87,16 +91,19 @@ func mimoScheduler(ctx context.Context, _log *logrus.Entry) error {
return err
}

poolWorkers, err := database.NewPoolWorkers(ctx, dbc, dbName)
if err != nil {
return err
}

dbg := database.NewDBGroup().
WithOpenShiftClusters(clusters).
WithSubscriptions(subscriptions).
WithMaintenanceManifests(manifests).
WithMaintenanceSchedules(schedules)

buckets := actuator.DetermineBuckets(_env, os.Hostname)
log.Printf("serving %d buckets: %v", len(buckets), buckets)
WithMaintenanceSchedules(schedules).
WithPoolWorkers(poolWorkers)

a := scheduler.NewService(_env, log, dbg, m, buckets)
a := scheduler.NewService(_env, log, dbg, m)
a.SetMaintenanceTasks(tasks.DEFAULT_MAINTENANCE_TASKS)

sigterm := make(chan os.Signal, 1)
Expand Down
4 changes: 2 additions & 2 deletions cmd/aro/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func monitor(ctx context.Context, _log *logrus.Entry) error {
return err
}

dbMonitors, err := database.NewMonitors(ctx, dbc, dbName)
dbPoolWorkers, err := database.NewPoolWorkers(ctx, dbc, dbName)
if err != nil {
return err
}
Expand All @@ -92,7 +92,7 @@ func monitor(ctx context.Context, _log *logrus.Entry) error {

dbg := database.NewDBGroup().WithOpenShiftClusters(dbOpenShiftClusters).
WithSubscriptions(dbSubscriptions).
WithMonitors(dbMonitors)
WithPoolWorkers(dbPoolWorkers)

dialer, err := proxy.NewDialer(_env.IsLocalDevelopmentMode(), _env.LoggerForComponent("dialer"))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/mimodocument.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ func (c *MaintenanceScheduleDocument) GetKey() string {
}

func (c *MaintenanceScheduleDocument) GetBucket() int {
return 0
return -1
}
11 changes: 0 additions & 11 deletions pkg/api/monitor.go

This file was deleted.

20 changes: 20 additions & 0 deletions pkg/api/poolworker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package api

// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.

type PoolWorkerType string

const (
PoolWorkerTypeMonitor PoolWorkerType = "monitor"
PoolWorkerTypeMIMOActuator PoolWorkerType = "mimo-actuator"
PoolWorkerTypeMIMOScheduler PoolWorkerType = "mimo-scheduler"
)

// PoolWorker represents a worker in a pool that distributes work via owning
// different OpenShiftCluster buckets
type PoolWorker struct {
MissingFields

Buckets []string `json:"buckets,omitempty"`
}
19 changes: 10 additions & 9 deletions pkg/api/monitordocument.go → pkg/api/poolworkerdocument.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package api
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.

// MonitorDocuments represents monitor documents.
// PoolWorkerDocuments represents PoolWorker documents.
// pkg/database/cosmosdb requires its definition.
type MonitorDocuments struct {
Count int `json:"_count,omitempty"`
ResourceID string `json:"_rid,omitempty"`
MonitorDocuments []*MonitorDocument `json:"Documents,omitempty"`
type PoolWorkerDocuments struct {
Count int `json:"_count,omitempty"`
ResourceID string `json:"_rid,omitempty"`
PoolWorkerDocuments []*PoolWorkerDocument `json:"Documents,omitempty"`
}

// MonitorDocument represents a monitor document.
// PoolWorkerDocument represents a PoolWorker document.
// pkg/database/cosmosdb requires its definition.
type MonitorDocument struct {
type PoolWorkerDocument struct {
MissingFields

ID string `json:"id,omitempty"`
Expand All @@ -29,9 +29,10 @@ type MonitorDocument struct {
LeaseOwner string `json:"leaseOwner,omitempty"`
LeaseExpires int `json:"leaseExpires,omitempty"`

Monitor *Monitor `json:"monitor,omitempty"`
WorkerType PoolWorkerType `json:"workerType,omitempty"`
PoolWorker *PoolWorker `json:"poolWorker,omitempty"`
}

func (c *MonitorDocument) GetID() string {
func (c *PoolWorkerDocument) GetID() string {
return c.ID
}
2 changes: 1 addition & 1 deletion pkg/database/cosmosdb/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package cosmosdb
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.

//go:generate gencosmosdb github.com/Azure/ARO-RP/pkg/api,AsyncOperationDocument github.com/Azure/ARO-RP/pkg/api,BillingDocument github.com/Azure/ARO-RP/pkg/api,GatewayDocument github.com/Azure/ARO-RP/pkg/api,MonitorDocument github.com/Azure/ARO-RP/pkg/api,OpenShiftClusterDocument github.com/Azure/ARO-RP/pkg/api,SubscriptionDocument github.com/Azure/ARO-RP/pkg/api,OpenShiftVersionDocument github.com/Azure/ARO-RP/pkg/api,PlatformWorkloadIdentityRoleSetDocument github.com/Azure/ARO-RP/pkg/api,MaintenanceManifestDocument github.com/Azure/ARO-RP/pkg/api,MaintenanceScheduleDocument
//go:generate gencosmosdb github.com/Azure/ARO-RP/pkg/api,AsyncOperationDocument github.com/Azure/ARO-RP/pkg/api,BillingDocument github.com/Azure/ARO-RP/pkg/api,GatewayDocument github.com/Azure/ARO-RP/pkg/api,OpenShiftClusterDocument github.com/Azure/ARO-RP/pkg/api,SubscriptionDocument github.com/Azure/ARO-RP/pkg/api,OpenShiftVersionDocument github.com/Azure/ARO-RP/pkg/api,PlatformWorkloadIdentityRoleSetDocument github.com/Azure/ARO-RP/pkg/api,MaintenanceManifestDocument github.com/Azure/ARO-RP/pkg/api,MaintenanceScheduleDocument github.com/Azure/ARO-RP/pkg/api,PoolWorkerDocument
//go:generate mockgen -destination=../../util/mocks/$GOPACKAGE/$GOPACKAGE.go github.com/Azure/ARO-RP/pkg/database/$GOPACKAGE PermissionClient
Loading
Loading