Orchestrated Patterns processing incorrectly updated CI's statuses


Description

After Quebec Patch 7 and migrated from CAPI to Pattern, VM Instance states can be incorrectly updated to 'terminated' and statuses updated to 'retired' event though the VMs are still active.

Steps to Reproduce

1. Have either a Quebec instance with at least Patch 7 or a Rome instance
2. Have an Azure Account and make sure it has many VM Instances
3. Configure Cloud discovery for the Above Service account
4. Migrate CAPI to Pattern if still using CAPI
5. Run the Cloud Discovery schedule
6. Run the schedule multiple times and observe that the VMs state flaps.

Workaround

1. Edit 'Horizontal Discovery Sensor'
https://<;instance_name>.service-now.com/nav_to.do?uri=discovery_sensor.do?sys_id=2f32f7899f230200fe2ab0aec32e706a

2. Change lines 75 - 80
FROM:
//=====================
// PRB1441833: Calling isPagingComplete here to accomplish the following
// 1) Check if multipaging is complete
// 2) Verify that we ran this function call for updateCounts function
if (!resultHandler.isPagingComplete())
this.multipagingIncomplete = true;
this.ranPagingComplete = true;
//=====================

TO:
//=====================
/** CSTASK260546 Workaround
// PRB1441833: Calling isPagingComplete here to accomplish the following
// 1) Check if multipaging is complete
// 2) Verify that we ran this function call for updateCounts function
if (!resultHandler.isPagingComplete())
this.multipagingIncomplete = true;
this.ranPagingComplete = true;
**/
//=====================

3. Change lines 537 - 548 (527 - 538 for Rome)
FROM
//=====================
// PRB1441833: Typically called from DiscoverySensor, modifying behavior here
// so that we only update counts once multipaging is complete (or if just single page)
updateCounts: function() {
if (!this.multipagingIncomplete && this.ranPagingComplete)
this.updateDeviceCount();
else if (!this.ranPagingComplete) {
// This is only ran if we somehow reached here without ever running the isPagingComplete function
var resultHandler = new SNC.HorizontalDiscoveryResultHandler(g_probe, g_device, this.type, this.getEccQueueId());
if (resultHandler.isPagingComplete())
this.updateDeviceCount();
}
},
//=====================

TO:
//=====================
/** CSTASK260546 Workaround
// PRB1441833: Typically called from DiscoverySensor, modifying behavior here
// so that we only update counts once multipaging is complete (or if just single page)
updateCounts: function() {
if (!this.multipagingIncomplete && this.ranPagingComplete)
this.updateDeviceCount();
else if (!this.ranPagingComplete) {
// This is only ran if we somehow reached here without ever running the isPagingComplete function
var resultHandler = new SNC.HorizontalDiscoveryResultHandler(g_probe, g_device, this.type, this.getEccQueueId());
if (resultHandler.isPagingComplete())
this.updateDeviceCount();
}
},
**/
//=====================


Related Problem: PRB1541731