Migration app gets stuck in "RUNNING" status

Hi all. I have an issue when migrating a Jira server app to cloud. I have implemented the listener on my server app.

This is my implementation of onStartAppMigration method

    @Override
    public void onStartAppMigration(String transferId,
                                    MigrationDetailsV1 migrationDetails) {

        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.serializeNulls();
        Gson gson = gsonBuilder.create();

        List<RetrospectiveDTO> retrospectiveDTOS = new ArrayList<>();
        try {
            retrospectiveDTOS = retrosMapDataService.matchRetrosForCloud(transferId, accessor,
                    migrationDetails.getJiraClientKey());

            LOGGER.info("{} retrospective sessions were found for migration", retrospectiveDTOS.size());

            OutputStream firstDataStream = accessor.getCloudMigrationGateway().createAppData(transferId);
            // You can even upload big files in here
            firstDataStream.write(gson.toJson(retrospectiveDTOS).getBytes());
            firstDataStream.close();
            LOGGER.info("Retrospectives migration finished with transferId: {}", transferId);

        } catch (Exception e) {
            LOGGER.error("Error uploading files to the cloud", e);
        }
    }

the issue is when an exception is thrown the migration app gets stuck in “RUNNING” status and the migration never ends. Is there a way to prevent this always “RUNNING” status or to stop the migration app to avoid such loop of running that never ends.

1 Like

Hi @MauryZapata,

Thanks for posting. In your cloud service, when you receive the app-data-uploaded event, and start processing the data you need to send status updates. You can see the details in Progress reporting.

In summary, when the transfer is complete and there is nothing more to do, you settle the transfer by sending a payload of SUCCESS

{
                "status" : "SUCCESS",
                "percent": 100,
                "message" : "Migration completed."
            }'

And this will update the status in the user interface in server.

The status is updated every 10 minutes, so if you’re testing you should use Dev Mode to change it to 60 seconds, and also bypass the App Assessment stage.

I recommend looking at the examples in App Migration - Vendor examples.

Hope this helps.

James.

Hi @jrichards thanks for your reply. I have tested the progress feedback API, when I execute a migration from my server instance to my cloud instance is working properly if I use the right data (happy path). The issue is when an exception is thrown in server instance before app-data-uploaded event is triggered. In this scenario the error occurs on server side and the information is not uploaded to the S3 cloud service due to the error. For such case, the migrations process gets stuck in “RUNNING” status. It seems that the error is not detected and the migration assistant does not know that something failed. Is there something that I can do to stop that RUNNING migration? Or any way to let the migration assistant know about the error and stop the migration automatically?

Hi @MauryZapata,

Your’re going to have to wrap the upload with a try / catch block and detect the errors yourself to make the code more resilient. We can’t do it in the S3 upload code because it’s a stream and we can’t restart it.

Regards,
James.

1 Like

Hello @MauryZapata :wave:

The method onStartAppMigration was designed to receive an event and handle it in async fashion.

As a matter of fact, for a long time we recommended partners to implement their migration heavy-lifting code somewhere else (like another thread or a scheduled job). Nowadays we are also embracing migrations processed within that method, but an exception coming out of it doesn’t give us enough details to guess their migration state.

It could’ve been an exception at the end of the process with no impact on it. It could’ve been also a partial migration.

What @jrichards suggested makes a lot of sense to me as the partners are probably in a better position to handle exceptions than the platform - as some awareness of the code is required to do it properly.

Thanks for the feedback!

Andre

1 Like

Hi @AndreRosot

I understand what you said, thanks for the feedback. The only thing that I can imagine now to handle the scenario that I mentioned, is catching the exception on onStartAppMigration and create a stream with server status data, e. g., { "serverStatus": "FAILED"} and then upload such data to S3 cloud service. So when I can retrieved in the cloud side I will be able to read the status and send the feedback with the progress api to stop the app migration. I don’t know if it is the better idea :sweat_smile: but it may be work. On the other hand, it could be nice to have an option in the migration assistant to stop a specific app migration if it has been running for much time (maybe hours or days). It’s just a suggestion.

Thanks both for your replies.

Regards!

1 Like

Hi @MauryZapata,

I think there’s some confusion here. What we’re talking about is in server, when you start sending the data through the App migration platform, have a try / catch block that detects errors and restarts the upload.

So, instead of just

} catch (Exception e) {
            LOGGER.error("Error uploading files to the cloud", e);
}

you have a mechanism to retry.

Once the upload has completed, the Connect app will receive the app-data-uploaded event and then, from Connect you send the progress update.

Regards,
James.

Hello again @MauryZapata !

I like your approach to report failures on upload. Even more if that’s after a retry. If you need to send details about the status I think that’s the way to go!

If you just need something simple, like reporting success/failure, perhaps you can take a shortcut and use the upload labels to express that. Eg: label = status:success. This would save you from having to download the file, since labels are present in the webhook event already.

However, the main reason I’m jumping into the resolved thread is to share with you some details about the “stop the migration” request. And they’re good ones :slightly_smiling_face:

Recently we announced Transfer cancellation. At this stage is a feature used by support in very specific cases, but we are working to make it a button in the CMAs so every customer would have access to it.

Have a great day!

Andre