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

Add appropriate application name to GAV deployments / FISH-1015 #5071

Merged
merged 7 commits into from
Jan 24, 2021

Conversation

avpinchuk
Copy link
Contributor

Description

This is a bug fix.

Remote artifact deployed with a temporary name app...tmp. But, e.g., for MDBs we need to specify resource adapter name activation property and we get an deployment error. This fix changes deploy name to artifactId-version.

When creating an uber jar a GAV artifacts are added with a context name, not a filename. When executes this uber jar an exception throws if context name length less than or equal 4. In other case we have an incomplete application name (context - last four chars). This fix writes GAV artifacts with their filenames and adds their contexts to the contexts.properties during uber jar creation.

Important Info

Blockers

Testing

New tests

Testing Performed

Testing Environment

Documentation

Notes for Reviewers

deploymentMapEntry.getKey(), "--force=true", "--loadOnly", "true");
String artefactName= artefactURI.getPath().substring(artefactURI.getPath().lastIndexOf('/') + 1);
// artefact name always has a valid extension
String name = artefactName.substring(0, artefactName.length() - 4);
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Could this be extracted to (tested) method?
  2. Could this variable be renamed to something like nameWithExtension - and above comment removed?

deploymentURLsMap.put(defaultContext, artefactMapEntry.getValue());
URL artefactURL = artefactMapEntry.getValue();
String artefactName = artefactURL.getPath().substring(artefactURL.getPath().lastIndexOf('/') + 1);

Copy link
Contributor

Choose a reason for hiding this comment

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

With above comment implemented - could new method be used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same code also in UberJarCreator class. Maybe make sense move this to utility class? Or such class already exists?

@lprimak
Copy link
Contributor

lprimak commented Dec 26, 2020

Can you put a problem example reproducer?
I’m not sure this solution is necessary or sideffect free.

Payara always has versioned deployment syntax wit a colon and not with a dash.
There should not be any other versioning syntax introduction

@lprimak lprimak self-requested a review December 26, 2020 05:03
Copy link
Contributor

@lprimak lprimak left a comment

Choose a reason for hiding this comment

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

@avpinchuk
Copy link
Contributor Author

There some examples.

  1. java -jar payara-micro.jar --deployFromGAV org.apache.actimemq,activemq-rar,5.16.0
    RAR will be deployed with name app541699296244089487tmp or similar.
    If we have an app with some MDB
@MessageDriven(activationConfig = {
...
@ActivationConfigProperty(propertyName="resourceAdapter", propertyValue="activemq-rar-5.16.0"),
...
}

and deploy it with second --deployFromGAV option we have an deployment error.

  1. java -jar payara-micro.jar --deployFromGAV org.apache.actimemq,activemq-rar,5.16.0 --outputUberJar micro.jar
    adds RAR to MICRO-INF/deploy as activemq-rar without extension (because artifactId is a deploymentURLsMap's keys and used as a filename).

java -jar micro.jar give us name activemq and context activemq-rar after deployment

  1. PayaraMicroImpl, line 1543 and below
for (String entry : microInfEntries) {
                    File file = new File(entry);
                    String deployContext = file.getName();
                    String name = deployContext.substring(0, deployContext.length() - 4);

last line give us exception or empty name and other exception in case of filename length <= 4 and unconditionally truncate last four chars otherwise.

  1. As opposed, java -jar payara-micro.jar --deploy app-1.0-SNAPSHOT.war
    Everything is fine here: name and context is app-1.0-SNAPSHOT

@avpinchuk avpinchuk requested a review from lprimak December 26, 2020 10:25
@avpinchuk
Copy link
Contributor Author

avpinchuk commented Dec 26, 2020

This does not change versioning scheme.

This patch try to make three things:

  1. add name parameter to deploy command for GAV
  2. writes GAV contexts to uberJar's contexts.properties when create it and deploys GAVs from uberJar with this contexts when execute
  3. writes GAV to uberJar with actual filename not with atrifactId

"true", "--contextroot",
deploymentMapEntry.getKey(), "--force=true", "--loadOnly", "true");
String artefactName = getFileName(artefactURI.getPath());
String name = artefactName.substring(0, artefactName.length() - 4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this will break in so many ways, I cannot count 👍

Copy link
Contributor Author

@avpinchuk avpinchuk Dec 29, 2020

Choose a reason for hiding this comment

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

Thanks I understand. May be try to fix this by writing artifact with actual file name to a temporary directory instead of temp file?

There is reproducer https://github.com/avpinchuk/issue-gav
Install to your local repo and run micro (from current master)
java -jar payara-micro.jar --deployFromGAV org.apache.activemq:actevemq-rar:5.16.0 --deployFromGAV org.example:issue-gav:1.0 --additionalRepository file:///path/to/your/local/repo

@lprimak
Copy link
Contributor

lprimak commented Dec 29, 2020

I am working on some suggested simple changes...

@avpinchuk
Copy link
Contributor Author

I am working on some suggested simple changes...

Close this PR?

@lprimak
Copy link
Contributor

lprimak commented Dec 29, 2020

No

I am working on some suggested simple changes...

Close this PR?

no

@avpinchuk
Copy link
Contributor Author

I have a few more questions about Payara Micro boot time deployment. Where can they be discussed?

@lprimak lprimak self-assigned this Dec 29, 2020
@lprimak lprimak added PR: CLA CLA submitted on PR by the contributor Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev labels Dec 29, 2020
@lprimak lprimak changed the title Fix GAV deployment Add appropriate application name to GAV deployments Dec 29, 2020
@lprimak
Copy link
Contributor

lprimak commented Dec 30, 2020

I have a few more questions about Payara Micro boot time deployment. Where can they be discussed?

there is a discussion forum on GitHub for Payara.

Also, please take a look at the PR I made for your PR

@avpinchuk
Copy link
Contributor Author

Also, please take a look at the PR I made for your PR

I have some questions. Take a look at code comments in your PR, please.

refactored primitive obsession when getting file name from path to ex…
@lprimak
Copy link
Contributor

lprimak commented Dec 30, 2020

jenkins test

@avpinchuk
Copy link
Contributor Author

No. Need fix.

@lprimak
Copy link
Contributor

lprimak commented Dec 30, 2020

No. Need fix.

ok, just let us know when it's done

@lprimak lprimak added the PR: DO NOT MERGE Don't merge PR until further notice label Dec 30, 2020
@avpinchuk
Copy link
Contributor Author

Yes. Approx 1 hour

@avpinchuk
Copy link
Contributor Author

I finished. Please take a look at my last commit. Thanks!

@avpinchuk avpinchuk requested a review from lprimak December 30, 2020 20:09
@lprimak
Copy link
Contributor

lprimak commented Dec 30, 2020

jenkins test

@lprimak lprimak removed the PR: DO NOT MERGE Don't merge PR until further notice label Dec 30, 2020
@lprimak lprimak requested review from Cousjava and Pandrex247 January 5, 2021 17:48
Copy link
Member

@Pandrex247 Pandrex247 left a comment

Choose a reason for hiding this comment

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

Just a little something I spotted.

}
}

private static boolean hasJavaArchiveExtension(String filePath) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm probably being blind, but is there a reason this is being made static?

Copy link
Contributor

Choose a reason for hiding this comment

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

Because it has no access to fields. Good enough reason for me :)

@AlanRoth AlanRoth added Type: Community Contribution and removed PR: CLA CLA submitted on PR by the contributor labels Jan 18, 2021
@AlanRoth AlanRoth changed the title Add appropriate application name to GAV deployments Add appropriate application name to GAV deployments / FISH-1015 Jan 18, 2021
@AlanRoth AlanRoth added PR: CLA CLA submitted on PR by the contributor and removed Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev labels Jan 18, 2021
@lprimak lprimak merged commit 2595404 into payara:master Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: CLA CLA submitted on PR by the contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants