Skip to content

Commit 590b99e

Browse files
mocsharpdependabot[bot]lillie-dae
authored
Release/0.2.3 (#56)
* Storage service extension for health check service (#46) * Add health check for MinIO * Update packages & licenses Signed-off-by: Victor Chang <[email protected]> * Bump codecov/codecov-action from 2 to 3 (#37) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md) - [Commits](codecov/codecov-action@v2...v3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-dotnet from 1 to 2 (#36) Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 1 to 2. - [Release notes](https://github.com/actions/setup-dotnet/releases) - [Commits](actions/setup-dotnet@v1...v2) --- updated-dependencies: - dependency-name: actions/setup-dotnet dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jungwinter/split from 1 to 2 (#31) Bumps [jungwinter/split](https://github.com/jungwinter/split) from 1 to 2. - [Release notes](https://github.com/jungwinter/split/releases) - [Commits](winterjung/split@v1...v2) --- updated-dependencies: - dependency-name: jungwinter/split dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump gittools/actions from 0.9.11 to 0.9.13 (#33) Bumps [gittools/actions](https://github.com/gittools/actions) from 0.9.11 to 0.9.13. - [Release notes](https://github.com/gittools/actions/releases) - [Commits](GitTools/actions@v0.9.11...v0.9.13) --- updated-dependencies: - dependency-name: gittools/actions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-java from 1 to 3 (#34) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 1 to 3. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@v1...v3) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/checkout from 2 to 3 (#51) Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/download-artifact from 2 to 3 (#48) Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 3. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@v2...v3) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/upload-artifact from 2.3.1 to 3.1.0 (#49) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2.3.1 to 3.1.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v2.3.1...v3.1.0) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/cache from 2.1.7 to 3.0.8 (#50) Bumps [actions/cache](https://github.com/actions/cache) from 2.1.7 to 3.0.8. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](actions/cache@v2.1.7...v3.0.8) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update ci.yml * Add minio admin heath check (#54) * add minio admin health check Signed-off-by: Lillie Dae <[email protected]> Signed-off-by: Victor Chang <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Lillie Dae <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Lillie Dae <[email protected]>
1 parent a746587 commit 590b99e

File tree

7 files changed

+177
-23
lines changed

7 files changed

+177
-23
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v3
4343
with:
4444
fetch-depth: 0
45-
- uses: actions/setup-dotnet@v1
45+
- uses: actions/setup-dotnet@v2
4646
with:
4747
dotnet-version: "6.0.x"
4848

@@ -52,7 +52,7 @@ jobs:
5252
tools: licensefinder
5353

5454
- name: Enable NuGet cache
55-
uses: actions/cache@v2.1.7
55+
uses: actions/cache@v3.0.8
5656
with:
5757
path: ~/.nuget/packages
5858
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
@@ -88,23 +88,24 @@ jobs:
8888
runs-on: ubuntu-latest
8989
steps:
9090
- name: Set up JDK 11
91-
uses: actions/setup-java@v1
91+
uses: actions/setup-java@v3
9292
with:
93-
java-version: 1.11
93+
distribution: 'zulu'
94+
java-version: '11'
9495

95-
- uses: actions/setup-dotnet@v1
96+
- uses: actions/setup-dotnet@v2
9697
with:
9798
dotnet-version: "6.0.x"
9899

99100
- name: Enable NuGet cache
100-
uses: actions/cache@v2.1.7
101+
uses: actions/cache@v3.0.8
101102
with:
102103
path: ~/.nuget/packages
103104
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
104105
restore-keys: |
105106
${{ runner.os }}-nuget
106107
107-
- uses: actions/checkout@v2
108+
- uses: actions/checkout@v3
108109
with:
109110
fetch-depth: 0
110111

@@ -144,7 +145,7 @@ jobs:
144145
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
145146
working-directory: ./src
146147

147-
- uses: codecov/codecov-action@v2
148+
- uses: codecov/codecov-action@v3
148149
with:
149150
token: ${{ secrets.CODECOV_TOKEN }}
150151
directory: "src/${{ env.TEST_RESULTS }}"
@@ -173,16 +174,16 @@ jobs:
173174

174175
steps:
175176
- name: Checkout repository
176-
uses: actions/checkout@v2
177+
uses: actions/checkout@v3
177178
with:
178179
fetch-depth: 0
179180

180-
- uses: actions/setup-dotnet@v1
181+
- uses: actions/setup-dotnet@v2
181182
with:
182183
dotnet-version: "6.0.x"
183184

184185
- name: Enable NuGet cache
185-
uses: actions/cache@v2.1.7
186+
uses: actions/cache@v3.0.8
186187
with:
187188
path: ~/.nuget/packages
188189
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
@@ -198,7 +199,7 @@ jobs:
198199

199200
- name: Determine Version
200201
id: gitversion
201-
uses: gittools/actions/gitversion/[email protected].11
202+
uses: gittools/actions/gitversion/[email protected].13
202203
with:
203204
useConfigFile: true
204205
updateAssemblyInfo: true
@@ -227,15 +228,15 @@ jobs:
227228

228229
- name: Upload Nuget
229230
if: ${{ matrix.os == 'ubuntu-latest' }}
230-
uses: actions/upload-artifact@v2.3.1
231+
uses: actions/upload-artifact@v3.1.0
231232
with:
232233
name: nuget
233234
path: ${{ github.workspace }}/release/*.nupkg
234235
retention-days: 30
235236

236237
- name: Upload Zipped Plug-ins
237238
if: ${{ matrix.os == 'ubuntu-latest' }}
238-
uses: actions/upload-artifact@v2.3.1
239+
uses: actions/upload-artifact@v3.1.0
239240
with:
240241
name: plug-ins
241242
path: ${{ github.workspace }}/src/Plugins/release/*.zip
@@ -247,7 +248,7 @@ jobs:
247248
needs: [build, unit-test]
248249
if: ${{ ! ( github.event.inputs.nuget ) }}
249250
steps:
250-
- uses: actions/download-artifact@v2
251+
- uses: actions/download-artifact@v3
251252
id: download
252253

253254
- name: List artifacts
@@ -256,7 +257,7 @@ jobs:
256257
- name: Install grp
257258
run: dotnet tool install gpr -g
258259

259-
- uses: actions/setup-dotnet@v1
260+
- uses: actions/setup-dotnet@v2
260261
env:
261262
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
262263
with:
@@ -272,7 +273,7 @@ jobs:
272273
needs: [build, unit-test]
273274
if: ${{ github.event.inputs.nuget }}
274275
steps:
275-
- uses: actions/download-artifact@v2
276+
- uses: actions/download-artifact@v3
276277
id: download
277278

278279
- name: List artifacts
@@ -281,7 +282,7 @@ jobs:
281282
- name: Install grp
282283
run: dotnet tool install gpr -g
283284

284-
- uses: actions/setup-dotnet@v1
285+
- uses: actions/setup-dotnet@v2
285286
env:
286287
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
287288
with:
@@ -300,11 +301,11 @@ jobs:
300301
MAJORMINORPATCH: ${{ needs.build.outputs.majorMinorPatch }}
301302

302303
steps:
303-
- uses: actions/checkout@v2
304+
- uses: actions/checkout@v3
304305
with:
305306
fetch-depth: 0
306307

307-
- uses: actions/download-artifact@v2
308+
- uses: actions/download-artifact@v3
308309
id: download
309310

310311
- name: List artifacts
@@ -314,7 +315,7 @@ jobs:
314315
run: dotnet nuget push ${{ steps.download.outputs.download-path }}/nuget/*.nupkg -s https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET }} --skip-duplicate
315316

316317
- name: Extract owner and repo
317-
uses: jungwinter/split@v1
318+
uses: jungwinter/split@v2
318319
id: repo
319320
with:
320321
seperator: "/"

src/Plugins/AWSS3/StorageAdminService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
using System;
18+
using System.Collections.Generic;
1819
using System.Threading.Tasks;
1920
using Amazon.SecurityToken.Model;
2021
using Monai.Deploy.Storage.API;
@@ -28,6 +29,10 @@ public class StorageAdminService : IStorageAdminService
2829

2930
public Task<Credentials> CreateUserAsync(string username, PolicyRequest[] policyRequests) => throw new NotImplementedException();
3031

32+
public Task<List<string>> GetConnectionAsync() => throw new NotImplementedException();
33+
34+
public Task<bool> HasConnectionAsync() => throw new NotImplementedException();
35+
3136
public Task RemoveUserAsync(string username) => throw new NotImplementedException();
3237
}
3338
}

src/Plugins/MinIO/HealthCheckBuilder.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Microsoft.Extensions.DependencyInjection;
1818
using Microsoft.Extensions.Diagnostics.HealthChecks;
1919
using Microsoft.Extensions.Logging;
20+
using Monai.Deploy.Storage.API;
2021

2122
namespace Monai.Deploy.Storage.MinIO
2223
{
@@ -39,6 +40,19 @@ public override IHealthChecksBuilder Configure(
3940
failureStatus,
4041
tags,
4142
timeout));
43+
44+
builder.Add(new HealthCheckRegistration(
45+
$"{ConfigurationKeys.StorageServiceName}-admin",
46+
serviceProvider =>
47+
{
48+
var logger = serviceProvider.GetRequiredService<ILogger<MinIoAdminHealthCheck>>();
49+
var storageAdminService = serviceProvider.GetRequiredService<IStorageAdminService>();
50+
return new MinIoAdminHealthCheck(storageAdminService, logger);
51+
},
52+
failureStatus,
53+
tags,
54+
timeout));
55+
4256
return builder;
4357
}
4458
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2022 MONAI Consortium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
using System.Collections.ObjectModel;
18+
using Microsoft.Extensions.Diagnostics.HealthChecks;
19+
using Microsoft.Extensions.Logging;
20+
using Monai.Deploy.Storage.API;
21+
22+
namespace Monai.Deploy.Storage.MinIO
23+
{
24+
internal class MinIoAdminHealthCheck : IHealthCheck
25+
{
26+
private readonly IStorageAdminService _storageAdminService;
27+
private readonly ILogger<MinIoAdminHealthCheck> _logger;
28+
29+
public MinIoAdminHealthCheck(IStorageAdminService storageAdminService, ILogger<MinIoAdminHealthCheck> logger)
30+
{
31+
_storageAdminService = storageAdminService ?? throw new ArgumentNullException(nameof(storageAdminService));
32+
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
33+
}
34+
35+
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new())
36+
{
37+
try
38+
{
39+
var hasConnection = await _storageAdminService.HasConnectionAsync();
40+
var connectionResult = await _storageAdminService.GetConnectionAsync();
41+
var joinedResult = string.Join("\n", connectionResult);
42+
43+
var roDict = new ReadOnlyDictionary<string, object>(new Dictionary<string, object>() { { "MinoAdminResult", joinedResult } });
44+
45+
if (hasConnection)
46+
{
47+
return HealthCheckResult.Healthy(data: roDict);
48+
}
49+
50+
return HealthCheckResult.Unhealthy(data: roDict);
51+
}
52+
catch (Exception exception)
53+
{
54+
_logger.HealthCheckError(exception);
55+
return HealthCheckResult.Unhealthy(exception: exception);
56+
}
57+
}
58+
}
59+
}

src/Plugins/MinIO/StorageAdminService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ private Process CreateProcess(string cmd)
168168

169169
public async Task<bool> HasConnectionAsync()
170170
{
171-
var result = await ExecuteAsync(_get_connections_cmd).ConfigureAwait(false);
171+
var result = await GetConnectionAsync().ConfigureAwait(false);
172172
return result.Any(r => r.Equals(_serviceName));
173173
}
174174

175+
public async Task<List<string>> GetConnectionAsync() => await ExecuteAsync(_get_connections_cmd).ConfigureAwait(false);
176+
175177
public async Task<bool> SetConnectionAsync()
176178
{
177179
if (await HasConnectionAsync().ConfigureAwait(false))
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2022 MONAI Consortium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
using Microsoft.Extensions.Diagnostics.HealthChecks;
18+
using Microsoft.Extensions.Logging;
19+
using Monai.Deploy.Storage.API;
20+
using Moq;
21+
using Xunit;
22+
23+
namespace Monai.Deploy.Storage.MinIO.Tests
24+
{
25+
public class MinIoAdminHealthCheckTest
26+
{
27+
private readonly Mock<IStorageAdminService> _storageAdminService;
28+
private readonly Mock<ILogger<MinIoAdminHealthCheck>> _logger;
29+
30+
public MinIoAdminHealthCheckTest()
31+
{
32+
_storageAdminService = new Mock<IStorageAdminService>();
33+
_logger = new Mock<ILogger<MinIoAdminHealthCheck>>();
34+
}
35+
36+
[Fact]
37+
public async Task CheckHealthAsync_WhenConnectionThrows_ReturnUnhealthy()
38+
{
39+
_storageAdminService.Setup(p => p.HasConnectionAsync()).Throws(new Exception("error"));
40+
41+
var healthCheck = new MinIoAdminHealthCheck(_storageAdminService.Object, _logger.Object);
42+
var results = await healthCheck.CheckHealthAsync(new HealthCheckContext()).ConfigureAwait(false);
43+
44+
Assert.Equal(HealthStatus.Unhealthy, results.Status);
45+
Assert.NotNull(results.Exception);
46+
Assert.Equal("error", results.Exception.Message);
47+
}
48+
49+
[Fact]
50+
public async Task CheckHealthAsync_WhenConnectionSucceeds_ReturnHealthy()
51+
{
52+
_storageAdminService.Setup(p => p.HasConnectionAsync()).ReturnsAsync(true);
53+
_storageAdminService.Setup(p => p.GetConnectionAsync()).ReturnsAsync(new List<string>() { "strings" });
54+
var healthCheck = new MinIoAdminHealthCheck(_storageAdminService.Object, _logger.Object);
55+
var results = await healthCheck.CheckHealthAsync(new HealthCheckContext()).ConfigureAwait(false);
56+
57+
Assert.Equal(HealthStatus.Healthy, results.Status);
58+
Assert.Null(results.Exception);
59+
}
60+
}
61+
}

src/Storage/API/IStorageAdminService.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,17 @@ public interface IStorageAdminService
4444
/// </summary>
4545
/// <param name="username">Username</param>
4646
Task RemoveUserAsync(string username);
47+
48+
/// <summary>
49+
/// Gets list of alias connections.
50+
/// </summary>
51+
/// <returns></returns>
52+
Task<List<string>> GetConnectionAsync();
53+
54+
/// <summary>
55+
/// If connection contains configured service name.
56+
/// </summary>
57+
/// <returns></returns>
58+
Task<bool> HasConnectionAsync();
4759
}
4860
}

0 commit comments

Comments
 (0)