Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 0df6a54

Browse files
committed
only remove the retention policy
1 parent 164e26b commit 0df6a54

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/ApiService/ApiService/onefuzzlib/AutoScale.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ public async Async.Task<OneFuzzResultVoid> AddAutoScaleToVmss(ScalesetId vmss, A
136136
var workspaceId = _context.LogAnalytics.GetWorkspaceId().ToString();
137137
_logTracer.LogInformation("Setting up diagnostics for {AutoscaleResourceId} - {AutoscaleResourceName} - {WorkspaceId}", autoScaleResource.OkV.Id!, autoScaleResource.OkV.Data.Name, workspaceId);
138138

139-
140-
139+
var diagnosticsResource = await SetupAutoScaleDiagnostics(autoScaleResource.OkV, workspaceId);
140+
if (!diagnosticsResource.IsOk) {
141+
return OneFuzzResultVoid.Error(diagnosticsResource.ErrorV);
142+
}
141143

142144
return OneFuzzResultVoid.Ok;
143145
}
@@ -254,6 +256,35 @@ public AutoscaleProfile DefaultAutoScaleProfile(string queueUri, long scaleSetSi
254256
return CreateAutoScaleProfile(queueUri, 1L, scaleSetSize, scaleSetSize, 1, 10.0, 1, 5.0);
255257
}
256258

259+
260+
private async Async.Task<OneFuzzResult<DiagnosticSettingsResource>> SetupAutoScaleDiagnostics(AutoscaleSettingResource autoscaleSettingResource, string logAnalyticsWorkspaceId) {
261+
try {
262+
// TODO: we are missing CategoryGroup = "allLogs", we cannot set it since current released dotnet SDK is missing the field
263+
// The field is there in github though, so need to update this code once that code is released:
264+
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.ResourceManager.Monitor/src/Generated/Models/LogSettings.cs
265+
// But setting logs one by one works the same as "allLogs" being set...
266+
267+
var parameters = new DiagnosticSettingsData {
268+
WorkspaceId = logAnalyticsWorkspaceId
269+
};
270+
271+
var diagnostics = await autoscaleSettingResource.GetDiagnosticSettings().CreateOrUpdateAsync(WaitUntil.Started, $"{autoscaleSettingResource.Data.Name}-diagnostics", parameters);
272+
if (diagnostics != null && diagnostics.HasValue) {
273+
return OneFuzzResult.Ok(diagnostics.Value);
274+
}
275+
return OneFuzzResult<DiagnosticSettingsResource>.Error(
276+
ErrorCode.UNABLE_TO_CREATE,
277+
$"The resulting diagnostics settings resource was null when attempting to create for {autoscaleSettingResource.Id}"
278+
);
279+
} catch (Exception ex) {
280+
_logTracer.LogError(ex, "SetupAutoScaleDiagnostics");
281+
return OneFuzzResult<DiagnosticSettingsResource>.Error(
282+
ErrorCode.UNABLE_TO_CREATE,
283+
$"unable to setup diagnostics for auto-scale resource: {autoscaleSettingResource.Id} and name: {autoscaleSettingResource.Data.Name}"
284+
);
285+
}
286+
}
287+
257288
public OneFuzzResult<AutoscaleSettingResource?> GetAutoscaleSettings(ScalesetId vmss) {
258289
_logTracer.LogInformation("Checking scaleset {ScalesetId} for existing auto scale resource", vmss);
259290
try {

0 commit comments

Comments
 (0)