private Optional<String> rewriteInstance(
InstanceConfigRewrite instanceRewrite,
MutableStoreProvider storeProvider) {
InstanceKey instanceKey = instanceRewrite.getInstanceKey();
Optional<String> error = Optional.absent();
Iterable<IScheduledTask> tasks = storeProvider.getTaskStore().fetchTasks(
Query.instanceScoped(IJobKey.build(instanceKey.getJobKey()),
instanceKey.getInstanceId())
.active());
Optional<IAssignedTask> task =
Optional.fromNullable(Iterables.getOnlyElement(tasks, null))
.transform(Tasks.SCHEDULED_TO_ASSIGNED);