Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-8259 Improve Dev Mode Fail-Safe Mechanism #293

Merged
merged 4 commits into from
Feb 7, 2024
Merged

FISH-8259 Improve Dev Mode Fail-Safe Mechanism #293

merged 4 commits into from
Feb 7, 2024

Conversation

jGauravGupta
Copy link
Contributor

@jGauravGupta jGauravGupta commented Jan 29, 2024

This pull request addresses the challenges faced in the Payara Micro Maven Plugin's dev mode, specifically when deployment fails after a successful build. The proposed solution introduces a fail-safe mechanism that involves the addition of a dev-mode flag for persistent deployment.

Introduction of Dev Mode Flag in .reload file:

Added a new dev mode flag that can be passed to Payara Micro. This flag instructs Payara Micro to persistently monitor for changes after the failure of application deployment.

Testing Scenarios:

Implemented test cases to cover various scenarios:

  • Payara Micro instance started, and application deployed:
    • Compilation/Build failed
    • Build successful but application deployment failed
  • The Payara Micro instance started, but the application was not deployed due to deployment failure:
    • Compilation/Build failed
    • Build successful but application deployment failed

Steps to create the deployment failure scenario:

Deploy the web application in dev mode with the provided CircleResource class containing a sample REST endpoint.

import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Response;

@Path("circle")
public class CircleResource {

    @GET
    public Response calculateCircleArea(@QueryParam("radi") double radius) {
        if (radius <= 0) {
            return Response.status(Response.Status.BAD_REQUEST)
                    .entity("Radius must be a positive number.")
                    .build();
        }

        double area = Math.PI * radius * radius;
        return Response
                .ok("Area of the circle with radius " + radius + " is: " + area)
                .build();
    }
}

The CircleResource class initially has a @GET annotation on the calculateCircleArea function.

Start the application and verify the correct functioning of the REST endpoint.

Scenario Leading to Deployment Failure:

  1. After starting the application, dynamically modify the calculateCircleArea function by adding a @POST annotation to it.

  2. Save the modified source file with both @GET and @POST annotations in the same function.

  3. Observe that this modification results in a deployment failure and the Payara instance stops looking at the .reload file.

  4. Notice that, in response to the deployment failure, the Payara Micro instance stops monitoring the .reload file, preventing subsequent deployments even after addressing the error.

Related PRs:

payara/Payara#6542
https://github.com/payara/Payara-Enterprise/pull/1087

Copy link
Contributor

@simonladen simonladen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally with different sample web applications.
The issue with "Build failed" appearing in the title has been fixed.
Another issue using the Petclinic project may require further investigation, but could not be reproduced with other applications, so it doesn't need to block this PR

@jGauravGupta jGauravGupta merged commit 07316ca into payara:master Feb 7, 2024
1 check passed
@jGauravGupta jGauravGupta added this to the 2.2 milestone Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants