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

Commit

Permalink
scaleset vm instance scale-in protection
Browse files Browse the repository at this point in the history
  • Loading branch information
stas committed May 16, 2022
1 parent 3dd27be commit 2e4209d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/TimerTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Async.Task Run([TimerTrigger("1.00:00:00")] TimerInfo myTimer) {
var expiredJobs = _jobOperations.SearchExpired();

await foreach (var job in expiredJobs) {
_logger.Info($"stopping expired job. job_id:{job.JobId }");
_logger.Info($"stopping expired job. job_id:{job.JobId}");
await _jobOperations.Stopping(job, _taskOperations);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/onefuzzlib/TaskOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public IAsyncEnumerable<Task> SearchStates(Guid? jobId = null, IEnumerable<TaskS
}

public IAsyncEnumerable<Task> SearchExpired() {
var timeFilter = $"end_time lt Datetime'{DateTimeOffset.UtcNow.ToString("o") }'";
var timeFilter = $"end_time lt Datetime'{DateTimeOffset.UtcNow.ToString("o")}'";
return QueryAsync(filter: timeFilter);
}

Expand Down
17 changes: 9 additions & 8 deletions src/ApiService/ApiService/onefuzzlib/VmssOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ public async Async.Task<OneFuzzResultVoid> UpdateScaleInProtection(Guid name, Gu
instanceVm.Data.ProtectionPolicy = newProtectionPolicy;

var scaleSet = GetVmssResource(name);

VirtualMachineScaleSetVmInstanceRequiredIds ids = new VirtualMachineScaleSetVmInstanceRequiredIds(new[] { instanceVm.Data.InstanceId });
var updateRes = await scaleSet.UpdateInstancesAsync(WaitUntil.Started, ids);

//TODO: finish this after UpdateInstance method is fixed
//https://github.com/Azure/azure-sdk-for-net/issues/28491

throw new NotImplementedException("Update instance does not work as expected. See https://github.com/Azure/azure-sdk-for-net/issues/28491");
var vmCollection = scaleSet.GetVirtualMachineScaleSetVms();
var r = await vmCollection.CreateOrUpdateAsync(WaitUntil.Started, instanceVm.Data.InstanceId, instanceVm.Data);
if (r.GetRawResponse().IsError) {
var msg = $"failed to update scale in protection on vm {vmId} for scaleset {name}";
_log.WithHttpStatus((r.GetRawResponse().Status, r.GetRawResponse().ReasonPhrase)).Error(msg);
return OneFuzzResultVoid.Error(ErrorCode.UNABLE_TO_UPDATE, msg);
} else {
return OneFuzzResultVoid.Ok();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/onefuzzlib/orm/Orm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public StatefulOrm(ILogTracer logTracer, IOnefuzzContext context) : base(logTrac
});

if (func != null) {
_logTracer.Info($"processing state update: {typeof(T)} - PartitionKey {_partitionKeyGetter?.Value() } {_rowKeyGetter?.Value() } - %s");
_logTracer.Info($"processing state update: {typeof(T)} - PartitionKey {_partitionKeyGetter?.Value()} {_rowKeyGetter?.Value()} - %s");
return await func(entity);
}
return null;
Expand Down

0 comments on commit 2e4209d

Please sign in to comment.