Restricting mastership recheck when role NONE.
Avoids also log pollution.

Reason: This avoids one mastership recheck per instance every minute on unreachable AND unavailable device when role of instance is NONE.
Still treats the corner case where role is NONE and device is still available in the store.

Change-Id: I0bd0be5a9ed491a61cc1dc1e988dcf3a53e33993
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
index a0c74ca..f499d1b 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
@@ -434,6 +434,7 @@
                     // can't be master if device is not reachable
                     try {
                         if (myRole == MASTER) {
+                            log.info("Local Role {}, Marking unreachable device {} offline", MASTER, deviceId);
                             post(store.markOffline(deviceId));
                         }
                         //relinquish master role and ability to be backup.
@@ -445,10 +446,11 @@
                         log.error("Exception thrown while relinquishing role for {}", deviceId, e);
                     }
                 } else {
-                    // check if the device has master, if not, mark it offline
+                    // check if the device has master and is available to the store, if not, mark it offline
                     // only the nodes which has mastership role can mark any device offline.
+                    // This condition should never be hit unless in a device removed phase for NONE mastership roles.
                     NodeId master = mastershipService.getMasterFor(deviceId);
-                    if (master == null) {
+                    if (master == null && isAvailable(deviceId)) {
                         CompletableFuture<MastershipRole> roleFuture = mastershipService.requestRoleFor(deviceId);
                         roleFuture.thenAccept(role -> {
                             MastershipTerm term = termService.getMastershipTerm(deviceId);