Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
46 changes: 46 additions & 0 deletions .github/workflows/auxiliary-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Auxiliary Checks
on:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
repository-plugin-check:
if: github.repository == 'opensearch-project/OpenSearch'
runs-on: ubuntu-latest
continue-on-error: true
timeout-minutes: 60
strategy:
matrix:
plugin: [repository-azure, repository-gcs]
steps:
- uses: actions/checkout@v6

- name: Remove unnecessary files
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: 21
distribution: temurin
cache: gradle

- name: Run ${{ matrix.plugin }} check
run: ./gradlew :plugins:${{ matrix.plugin }}:check

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.plugin }}-test-results
path: plugins/${{ matrix.plugin }}/build/reports/tests/
retention-days: 7
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.common.policy.RequestRetryPolicy;
import com.microsoft.aad.msal4j.MsalServiceException;
import org.opensearch.common.settings.MockSecureSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.settings.SettingsException;
Expand All @@ -61,7 +60,6 @@
import reactor.netty.http.HttpResources;

import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -193,19 +191,17 @@ public void testGettingSecondaryStorageBlobEndpoint() throws IOException {
}

public void testClientUsingManagedIdentity() throws IOException {
// Enabled managed identity
// Verify that when MANAGED_IDENTITY is configured alongside a key, the client uses
// the managed identity credential path (HTTPS endpoint) rather than the key-based connection string.
final Settings settings = Settings.builder()
.setSecureSettings(buildSecureSettings())
.put("azure.client.azure1.token_credential_type", TokenCredentialType.MANAGED_IDENTITY.name())
.build();
try (AzureRepositoryPlugin plugin = pluginWithSettingsValidation(settings)) {
try (final AzureStorageService azureStorageService = plugin.azureStoreService) {
final BlobServiceClient client1 = azureStorageService.client("azure1").v1();

// Expect the client to use managed identity for authentication, and it should fail because managed identity environment is
// not setup in the test
final MsalServiceException e = expectThrows(MsalServiceException.class, () -> client1.getAccountInfo());
assertThat(e.getMessage(), containsString("[Managed Identity] MSI returned 401"));
// Managed identity path builds an HTTPS endpoint URL, not a connection string with embedded key
assertThat(client1.getAccountUrl(), equalTo("https://myaccount1.blob.core.windows.net"));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the error seen here: https://github.com/opensearch-project/OpenSearch/actions/runs/23354788293/job/67942749650

Suite: Test class org.opensearch.repositories.azure.AzureStorageServiceTests
  2> REPRODUCE WITH: ./gradlew ':plugins:repository-azure:test' --tests 'org.opensearch.repositories.azure.AzureStorageServiceTests.testClientUsingManagedIdentity' -Dtests.seed=F2A1209AD7C630AC -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=cgg-UG -Dtests.timezone=America/Fortaleza -Druntime.java=25
  2> java.lang.AssertionError: 
    Expected: a string containing "[Managed Identity] MSI returned 401"
         but: was "[Managed Identity] Authentication unavailable. The requested identity has not been assigned to this resource.Status: 400Content:{"error":"invalid_request","error_description":"Identity not found"}Headers:Server[IMDS/150.870.65.1854]Content-Length[68]x-ms-request-id[23532fc5-479b-4cb6-9835-9485a51600a3]Date[Fri, 20 Mar 2026 17:35:08 GMT]Content-Type[application/json; charset=utf-8] [Managed Identity] Error Code: invalid_request Error Message: Identity not found"

}
}
}
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/azure-fixture/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
azure-fixture:
build:
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/gcs-fixture/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
gcs-fixture:
build:
Expand Down
Loading