This commit is contained in:
Nont 2023-10-19 14:59:44 -05:00 коммит произвёл Caden Marchese
Родитель 55ac567aee
Коммит effcd0beab
7 изменённых файлов: 15 добавлений и 11 удалений

2
go.mod
Просмотреть файл

@ -6,6 +6,7 @@ require (
github.com/Azure/azure-sdk-for-go v63.1.0+incompatible
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2 v2.2.1
github.com/Azure/go-autorest/autorest v0.11.29
github.com/Azure/go-autorest/autorest/adal v0.9.23
github.com/Azure/go-autorest/autorest/date v0.3.0
@ -91,7 +92,6 @@ require (
require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2 v2.2.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect

2
go.sum
Просмотреть файл

@ -19,8 +19,10 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 h1:LNHhpdK7hzUcx/k1LIcuh
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1/go.mod h1:uE9zaUfEQT/nbQjVi2IblCG9iaLtZsuYZ8ne+PuQ02M=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2 v2.2.1 h1:bWh0Z2rOEDfB/ywv/l0iHN1JgyazE6kW/aIA89+CEK0=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2 v2.2.1/go.mod h1:Bzf34hhAE9NSxailk8xVeLEZbUjOXcC+GnU1mMKdhLw=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs=

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

@ -6,6 +6,7 @@ package nsg
import (
"context"
"errors"
"fmt"
"net/http"
"net/netip"
"strings"
@ -164,12 +165,12 @@ func (n *NSGMonitor) Monitor(ctx context.Context) []error {
if r.isInvalidDenyRule() {
dims := map[string]string{
dimension.NSGResourceGroup: nsgResource.ResourceGroupName,
dimension.ResourceName: nsgResource.Name,
dimension.NSG: nsgResource.Name,
dimension.NSGRuleName: *rule.Name,
dimension.NSGRuleSources: strings.Join(r.sourceStrings, ","),
dimension.NSGRuleDestinations: strings.Join(r.destinationStrings, ","),
dimension.NSGRuleDirection: string(*rule.Properties.Direction),
dimension.NSGRulePriority: string(*rule.Properties.Priority),
dimension.NSGRulePriority: fmt.Sprint(*rule.Properties.Priority),
}
emitter.EmitGauge(n.emitter, MetricInvalidDenyRule, int64(1), n.dims, dims)
}

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

@ -415,24 +415,24 @@ func TestMonitor(t *testing.T) {
dimension.Location: ocLocation,
dimension.SubscriptionID: subscriptionID,
dimension.NSGResourceGroup: resourcegroupName,
dimension.ResourceName: nsg1Name,
dimension.NSG: nsg1Name,
dimension.NSGRuleName: nsgRuleName1,
dimension.NSGRuleSources: subsetOfMaster1,
dimension.NSGRuleDestinations: subsetOfMaster2,
dimension.NSGRuleDirection: string(armnetwork.SecurityRuleDirectionInbound),
dimension.NSGRulePriority: string(priority1),
dimension.NSGRulePriority: fmt.Sprint(priority1),
})
mock.EXPECT().EmitGauge(MetricInvalidDenyRule, int64(1), map[string]string{
dimension.ResourceID: ocID,
dimension.Location: ocLocation,
dimension.SubscriptionID: subscriptionID,
dimension.NSGResourceGroup: resourcegroupName,
dimension.ResourceName: nsg2Name,
dimension.NSG: nsg2Name,
dimension.NSGRuleName: nsgRuleName3,
dimension.NSGRuleSources: "10.0.1.1/32,10.0.1.2",
dimension.NSGRuleDestinations: "*",
dimension.NSGRuleDirection: string(armnetwork.SecurityRuleDirectionOutbound),
dimension.NSGRulePriority: string(priority3),
dimension.NSGRulePriority: fmt.Sprint(priority3),
})
},
},

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

@ -172,7 +172,7 @@ func toPrefixes(log *logrus.Entry, addresses []string) []netip.Prefix {
// 1. The strings always come directly from Azure, which has been validated.
// 2. Even if the value is wrong, it won't be neither master or worker.
// 3. We should also skip other service tags (VirtualNetwork, Internet, Any etc)
log.Errorf("Error while parsing %s. Full error %s.", address, err)
log.Debugf("Error while parsing %s. Full error %s.", address, err)
continue
}
prefixes = append(prefixes, prefix)

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

@ -7,9 +7,8 @@ import (
"net/netip"
"testing"
"github.com/sirupsen/logrus"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2"
"github.com/sirupsen/logrus"
utilerror "github.com/Azure/ARO-RP/test/util/error"
)

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

@ -19,9 +19,11 @@ var _ = Describe("Monitor", func() {
// This is more of an integration test rather than E2E.
It("must run and must not return any errors", func(ctx context.Context) {
By("creating a new monitor instance for the test cluster")
var wg sync.WaitGroup
wg.Add(1)
mon, err := cluster.NewMonitor(log, clients.RestConfig, &api.OpenShiftCluster{
ID: resourceIDFromEnv(),
}, &noop.Noop{}, nil, true, new(sync.WaitGroup))
}, &noop.Noop{}, nil, true, &wg)
Expect(err).NotTo(HaveOccurred())
By("running the monitor once")