From 7ba214fc70fcecfa9d025020356cb097ad37528d Mon Sep 17 00:00:00 2001 From: Jim Minter Date: Tue, 17 Nov 2020 16:26:26 -0600 Subject: [PATCH] remove removeOldMetricAlerts --- pkg/deploy/deploy.go | 33 ------------------- .../azureclient/mgmt/insights/metricalerts.go | 33 ------------------- 2 files changed, 66 deletions(-) delete mode 100644 pkg/util/azureclient/mgmt/insights/metricalerts.go diff --git a/pkg/deploy/deploy.go b/pkg/deploy/deploy.go index 6a1d7506f..59bfae740 100644 --- a/pkg/deploy/deploy.go +++ b/pkg/deploy/deploy.go @@ -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. diff --git a/pkg/util/azureclient/mgmt/insights/metricalerts.go b/pkg/util/azureclient/mgmt/insights/metricalerts.go deleted file mode 100644 index cea1ca7c7..000000000 --- a/pkg/util/azureclient/mgmt/insights/metricalerts.go +++ /dev/null @@ -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, - } -}