@@ -91,6 +91,9 @@ public async Task<OneFuzzResult<Node>> AcquireScaleInProtection(Node node) {
9191 if ( node . ScalesetId is ScalesetId scalesetId &&
9292 await TryGetNodeInfo ( node ) is NodeInfo nodeInfo ) {
9393
94+ var metricDimensions = new Dictionary < string , string > {
95+ { "MachineId" , node . MachineId . ToString ( ) }
96+ } ;
9497 _logTracer . Info ( $ "Setting scale-in protection on node { node . MachineId : Tag:MachineId} ") ;
9598
9699 var instanceId = node . InstanceId ;
@@ -110,17 +113,25 @@ await TryGetNodeInfo(node) is NodeInfo nodeInfo) {
110113 var r = await _context . VmssOperations . UpdateScaleInProtection ( nodeInfo . Scaleset , instanceId , protectFromScaleIn : true ) ;
111114 if ( ! r . IsOk ) {
112115 _logTracer . Error ( r . ErrorV ) ;
116+ _logTracer . Metric ( $ "FailedAcquiringScaleInProtection", 1 , metricDimensions ) ;
117+ return r . ErrorV ;
113118 }
119+
120+ _logTracer . Metric ( $ "AcquiredScaleInProtection", 1 , metricDimensions ) ;
121+ return OneFuzzResult . Ok ( node ) ;
114122 }
115123
116- return OneFuzzResult . Ok ( node ) ;
124+ return Error . Create ( ErrorCode . INVALID_NODE , "Failed getting NodeInfo. Cannot acquire scale-in protection" ) ;
117125 }
118126
119127 public async Task < OneFuzzResultVoid > ReleaseScaleInProtection ( Node node ) {
120128 if ( ! node . DebugKeepNode &&
121129 node . ScalesetId is ScalesetId scalesetId &&
122130 await TryGetNodeInfo ( node ) is NodeInfo nodeInfo ) {
123131
132+ var metricDimensions = new Dictionary < string , string > {
133+ { "MachineId" , node . MachineId . ToString ( ) }
134+ } ;
124135 _logTracer . Info ( $ "Removing scale-in protection on node { node . MachineId : Tag:MachineId} ") ;
125136
126137 var instanceId = node . InstanceId ;
@@ -136,7 +147,11 @@ await TryGetNodeInfo(node) is NodeInfo nodeInfo) {
136147 var r = await _context . VmssOperations . UpdateScaleInProtection ( nodeInfo . Scaleset , instanceId , protectFromScaleIn : false ) ;
137148 if ( ! r . IsOk ) {
138149 _logTracer . Error ( r . ErrorV ) ;
150+ _logTracer . Metric ( $ "FailedReleasingScaleInProtection", 1 , metricDimensions ) ;
151+ return r ;
139152 }
153+
154+ _logTracer . Metric ( $ "ReleasedScaleInProection", 1 , metricDimensions ) ;
140155 return r ;
141156 }
142157
0 commit comments