This commit is contained in:
Jim Minter 2020-11-17 16:26:26 -06:00
Родитель 611ef65c28
Коммит 7ba214fc70
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 0730CBDA10D1A2D3
2 изменённых файлов: 0 добавлений и 66 удалений

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

@ -22,7 +22,6 @@ import (
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/compute"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/dns"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/features"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/insights"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/msi"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/network"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/storage"
@ -46,7 +45,6 @@ type deployer struct {
globalaccounts storage.AccountsClient
deployments features.DeploymentsClient
groups features.ResourceGroupsClient
metricalerts insights.MetricAlertsClient
userassignedidentities msi.UserAssignedIdentitiesClient
publicipaddresses network.PublicIPAddressesClient
vmss compute.VirtualMachineScaleSetsClient
@ -85,7 +83,6 @@ func New(ctx context.Context, log *logrus.Entry, config *RPConfig, version strin
globalaccounts: storage.NewAccountsClient(*config.Configuration.GlobalSubscriptionID, authorizer),
deployments: features.NewDeploymentsClient(config.SubscriptionID, authorizer),
groups: features.NewResourceGroupsClient(config.SubscriptionID, authorizer),
metricalerts: insights.NewMetricAlertsClient(config.SubscriptionID, authorizer),
userassignedidentities: msi.NewUserAssignedIdentitiesClient(config.SubscriptionID, authorizer),
publicipaddresses: network.NewPublicIPAddressesClient(config.SubscriptionID, authorizer),
vmss: compute.NewVirtualMachineScaleSetsClient(config.SubscriptionID, authorizer),
@ -171,11 +168,6 @@ func (d *deployer) Deploy(ctx context.Context) error {
if err != nil {
return err
}
err = d.removeOldMetricAlerts(ctx)
if err != nil {
return err
}
}
return nil
@ -222,31 +214,6 @@ func (d *deployer) configureDNS(ctx context.Context) error {
return err
}
// removeOldMetricAlerts removes alert rules without the location in the name
func (d *deployer) removeOldMetricAlerts(ctx context.Context) error {
d.log.Print("removing old alerts")
metricAlerts, err := d.metricalerts.ListByResourceGroup(ctx, d.config.ResourceGroupName)
if err != nil {
return err
}
if metricAlerts.Value == nil {
return nil
}
for _, metricAlert := range *metricAlerts.Value {
switch *metricAlert.Name {
case "rp-availability-alert", "rp-degraded-alert", "rp-vnet-alert":
_, err = d.metricalerts.Delete(ctx, d.config.ResourceGroupName, *metricAlert.Name)
if err != nil {
return err
}
}
}
return nil
}
// getParameters returns an *arm.Parameters populated with parameter names and
// values. The names are taken from the ps argument and the values are taken
// from d.config.Configuration.

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

@ -1,33 +0,0 @@
package insights
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
import (
"context"
mgmtinsights "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
"github.com/Azure/go-autorest/autorest"
)
// MetricAlertsClient is a minimal interface for azure MetricAlertsClient
type MetricAlertsClient interface {
Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error)
ListByResourceGroup(ctx context.Context, resourceGroupName string) (result mgmtinsights.MetricAlertResourceCollection, err error)
}
type metricAlertsClient struct {
mgmtinsights.MetricAlertsClient
}
var _ MetricAlertsClient = &metricAlertsClient{}
// NewMetricAlertsClient creates a new MetricAlertsClient
func NewMetricAlertsClient(subscriptionID string, authorizer autorest.Authorizer) MetricAlertsClient {
client := mgmtinsights.NewMetricAlertsClient(subscriptionID)
client.Authorizer = authorizer
return &metricAlertsClient{
MetricAlertsClient: client,
}
}