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

Commit dec09bc

Browse files
committed
Improve error reporting from scale-in protection modification
1 parent 300a3e2 commit dec09bc

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

src/ApiService/ApiService/OneFuzzTypes/Enums.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public enum ErrorCode {
4040
UNABLE_TO_SEND = 483,
4141
NODE_DELETED = 484,
4242
TASK_CANCELLED = 485,
43+
SCALE_IN_PROTECTION_UPDATE_ALREADY_IN_PROGRESS = 486,
44+
SCALE_IN_PROTECTION_INSTANCE_NO_LONGER_EXISTS = 487,
45+
SCALE_IN_PROTECTION_REACHED_MODEL_LIMIT = 488,
46+
SCALE_IN_PROTECTION_UNEXPECTED_ERROR = 489,
4347
// NB: if you update this enum, also update enums.py
4448
}
4549

src/ApiService/ApiService/onefuzzlib/NodeOperations.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,14 @@ await TryGetNodeInfo(node) is NodeInfo nodeInfo) {
113113

114114
var r = await _context.VmssOperations.UpdateScaleInProtection(nodeInfo.Scaleset, instanceId, protectFromScaleIn: true);
115115
if (!r.IsOk) {
116-
_logTracer.LogOneFuzzError(r.ErrorV);
116+
switch (r.ErrorV.Code) {
117+
case ErrorCode.SCALE_IN_PROTECTION_UPDATE_ALREADY_IN_PROGRESS:
118+
_logTracer.LogWarning("Transiently failed to modify scale-in protection: {}", r.ErrorV);
119+
break;
120+
default:
121+
_logTracer.LogOneFuzzError(r.ErrorV);
122+
break;
123+
}
117124
_logTracer.LogMetric("FailedAcquiringScaleInProtection", 1);
118125
return r.ErrorV;
119126
}
@@ -148,7 +155,15 @@ await TryGetNodeInfo(node) is NodeInfo nodeInfo) {
148155

149156
var r = await _context.VmssOperations.UpdateScaleInProtection(nodeInfo.Scaleset, instanceId, protectFromScaleIn: false);
150157
if (!r.IsOk) {
151-
_logTracer.LogOneFuzzError(r.ErrorV);
158+
switch (r.ErrorV.Code) {
159+
case ErrorCode.SCALE_IN_PROTECTION_INSTANCE_NO_LONGER_EXISTS:
160+
case ErrorCode.SCALE_IN_PROTECTION_UPDATE_ALREADY_IN_PROGRESS:
161+
_logTracer.LogWarning("Transiently failed to modify scale-in protection: {}", r.ErrorV);
162+
break;
163+
default:
164+
_logTracer.LogOneFuzzError(r.ErrorV);
165+
break;
166+
}
152167
_logTracer.LogMetric("FailedReleasingScaleInProtection", 1);
153168
return r;
154169
}

src/ApiService/ApiService/onefuzzlib/VmssOperations.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,14 @@ public async Async.Task<OneFuzzResultVoid> UpdateScaleInProtection(Scaleset scal
253253
_ = await vmCollection.CreateOrUpdateAsync(WaitUntil.Started, instanceId, data);
254254
return OneFuzzResultVoid.Ok;
255255
} catch (RequestFailedException ex) when (ex.Status == 409 && ex.Message.StartsWith("The request failed due to conflict with a concurrent request")) {
256-
return OneFuzzResultVoid.Error(ErrorCode.UNABLE_TO_UPDATE, $"protection policy update is already in progress: {instanceId} in vmss {scaleset.ScalesetId}");
256+
return OneFuzzResultVoid.Error(ErrorCode.SCALE_IN_PROTECTION_UPDATE_ALREADY_IN_PROGRESS, $"protection policy update is already in progress: {instanceId} in vmss {scaleset.ScalesetId}");
257257
} catch (RequestFailedException ex) when (ex.Status == 400 && ex.Message.Contains("The provided instanceId") && ex.Message.Contains("not an active Virtual Machine Scale Set VM instanceId.")) {
258-
return OneFuzzResultVoid.Error(ErrorCode.UNABLE_TO_UPDATE, $"The node with instanceId {instanceId} no longer exists in scaleset {scaleset.ScalesetId}");
258+
return OneFuzzResultVoid.Error(ErrorCode.SCALE_IN_PROTECTION_INSTANCE_NO_LONGER_EXISTS, $"The node with instanceId {instanceId} no longer exists in scaleset {scaleset.ScalesetId}");
259259
} catch (RequestFailedException ex) when (ex.Status == 400 && ex.Message.Contains("reached its limit") && ex.Message.Contains("Upgrade the VMs to the latest model")) {
260-
return OneFuzzResultVoid.Error(ErrorCode.UNABLE_TO_UPDATE, $"VMSS has reached model limit. Could not update scaling protection for scaleset {scaleset.ScalesetId}.");
260+
return OneFuzzResultVoid.Error(ErrorCode.SCALE_IN_PROTECTION_REACHED_MODEL_LIMIT, $"VMSS has reached model limit. Could not update scaling protection for scaleset {scaleset.ScalesetId}.");
261261
} catch (Exception ex) {
262262
_log.LogError(ex, "unable to set protection policy on: {InstanceId} in vmss {ScalesetId}", instanceId, scaleset.ScalesetId);
263-
return OneFuzzResultVoid.Error(ErrorCode.UNABLE_TO_UPDATE, $"unable to set protection policy on: {instanceId} in vmss {scaleset.ScalesetId}");
263+
return OneFuzzResultVoid.Error(ErrorCode.SCALE_IN_PROTECTION_UNEXPECTED_ERROR, $"unable to set protection policy on: {instanceId} in vmss {scaleset.ScalesetId}");
264264
}
265265

266266
}

src/pytypes/onefuzztypes/enums.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ class ErrorCode(Enum):
292292
UNABLE_TO_SEND = 483
293293
NODE_DELETED = 484
294294
TASK_CANCELLED = 485
295+
SCALE_IN_PROTECTION_UPDATE_ALREADY_IN_PROGRESS = 486
296+
SCALE_IN_PROTECTION_INSTANCE_NO_LONGER_EXISTS = 487
297+
SCALE_IN_PROTECTION_REACHED_MODEL_LIMIT = 488
298+
SCALE_IN_PROTECTION_UNEXPECTED_ERROR = 489
295299
# NB: if you update this enum, also update Enums.cs
296300

297301

0 commit comments

Comments
 (0)