Skip to content

Commit

Permalink
Merge branch 'main' into chore/log-out-grafana-loki
Browse files Browse the repository at this point in the history
  • Loading branch information
chaudum authored Dec 13, 2024
2 parents 9b76542 + db2b6db commit 7a42645
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/grafana/loki/v3

go 1.23.0

toolchain go1.23.4
toolchain go1.23.1

require (
cloud.google.com/go/bigtable v1.33.0
Expand Down
2 changes: 1 addition & 1 deletion pkg/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ func Test_DiscardEmptyStreamsAfterValidation(t *testing.T) {
limits, ingester := setup()
distributors, _ := prepare(t, 1, 5, limits, func(_ string) (ring_client.PoolClient, error) { return ingester, nil })

_, err := distributors[0].Push(ctx, makeWriteRequestWithLabels(1, 1, []string{}))
_, err := distributors[0].Push(ctx, makeWriteRequestWithLabels(1, 1, []string{}, false, false, false))
require.Equal(t, err, httpgrpc.Errorf(http.StatusUnprocessableEntity, validation.MissingStreamsErrorMsg))
topVal := ingester.Peek()
require.Nil(t, topVal)
Expand Down
4 changes: 4 additions & 0 deletions pkg/storage/chunk/client/azure/blob_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ func (b *BlobStorage) getServicePrincipalToken(authFunctions authFunctions) (*ad

if b.cfg.UseFederatedToken {
token, err := b.servicePrincipalTokenFromFederatedToken(resource, authFunctions.NewOAuthConfigFunc, authFunctions.NewServicePrincipalTokenFromFederatedTokenFunc)
if err != nil {
return nil, err
}

var customRefreshFunc adal.TokenRefresh = func(_ context.Context, resource string) (*adal.Token, error) {
newToken, err := b.servicePrincipalTokenFromFederatedToken(resource, authFunctions.NewOAuthConfigFunc, authFunctions.NewServicePrincipalTokenFromFederatedTokenFunc)
if err != nil {
Expand Down
24 changes: 24 additions & 0 deletions pkg/storage/chunk/client/azure/blob_storage_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"testing"
"time"

"github.com/pkg/errors"

"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/grafana/dskit/flagext"
Expand Down Expand Up @@ -80,6 +82,28 @@ func (suite *FederatedTokenTestSuite) TestGetServicePrincipalToken() {
require.True(suite.T(), suite.mockedServicePrincipalToken == token, "should return the mocked object")
}

func (suite *FederatedTokenTestSuite) Test_HandleNoServicePrincipalToken() {
newOAuthConfigFunc := func(activeDirectoryEndpoint, tenantID string) (*adal.OAuthConfig, error) {
require.Equal(suite.T(), azure.PublicCloud.ActiveDirectoryEndpoint, activeDirectoryEndpoint)
require.Equal(suite.T(), "myTenantId", tenantID)

_, err := adal.NewOAuthConfig(activeDirectoryEndpoint, tenantID)
require.NoError(suite.T(), err)

return suite.mockOAuthConfig, nil
}

servicePrincipalTokenFromFederatedTokenFunc := func(_ adal.OAuthConfig, _ string, _ string, _ string, _ ...adal.TokenRefreshCallback) (*adal.ServicePrincipalToken, error) {
return nil, errors.New("No token")
}

token, err := suite.config.getServicePrincipalToken(authFunctions{newOAuthConfigFunc, servicePrincipalTokenFromFederatedTokenFunc})

require.Error(suite.T(), err)
require.EqualError(suite.T(), err, "No token")
require.True(suite.T(), token == nil, "should return error if no token was retrieved")
}

func Test_Hedging(t *testing.T) {
for _, tc := range []struct {
name string
Expand Down

0 comments on commit 7a42645

Please sign in to comment.