-
Notifications
You must be signed in to change notification settings - Fork 55
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
jbide-26175: cannot create server adapter for eap71-basic-s2i template #1785
Conversation
@@ -36,7 +36,7 @@ protected String getOutputNameFromSettings(IServerAttributes server, IModule mod | |||
String ret = super.getOutputNameFromSettings(server, module); | |||
if (ret == null && module.equals(findProjectModule(server))) { | |||
String suffix = ServerModelUtilities.getDefaultSuffixForModule(module); | |||
ret = "ROOT" + suffix; | |||
ret = module.getName() + suffix; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would probably fix for EAP 7.1 but for 7.0 as the OpenShift profile is probably not set you will not get the proper module name. Can you test with EAP 7.0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeffmaury you're right. It fails. But i think it must be part of https://issues.jboss.org/browse/JBIDE-22138?focusedCommentId=13608828&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-13608828. @adietish wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdshadow Yes, since the reason for the module name not being handled correctly lies in JBIDE-22138 aka upstream. As long as upstream isn't fixed the decision whether we want to apply this fix boils down to whether we want eap-70 or eap-71 templates to fail. I'd opt for sticking to the status quo aka not applying this fix.
@jeffmaury @bdshadow thoughts?
As J2EEDeployableFactory is a singleton can't we call the clearCache from our stuff before we generate the module name ? |
@jeffmaury I get the idea and yes, I agree: even though very dirty we could try to work around the bug in JBIDE-22138 and manually clear the module factory cache(s). |
I am also against applying this patch, we need to have more complex solution to have both(eap70 and eap71) templates working. |
@adietish @jeffmaury @jkopriva "openshift" profile is now activated when an openshift server adapter is created. Anyway it doesn't solve our problems. Please, take a look and test it. WDYT? |
return OpenShiftServerUtils.findProjectModule(getEclipseProject(server)); | ||
} | ||
|
||
private IProject getEclipseProject(IServerAttributes server) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any particular reason for extracting the call to the util method to it's own private method?
return model.saveServer(monitor); | ||
} | ||
|
||
@SuppressWarnings("restriction") | ||
private void setOpenshiftMavenProfileActive(IProject newDeployProject) throws CoreException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could make this method even more useful by refactoring it to something like activateMavenProfile(String profilename, IProject project)
?
|
||
@SuppressWarnings("restriction") | ||
private void setOpenshiftMavenProfileActive(IProject newDeployProject) throws CoreException { | ||
IFile pom = newDeployProject.getFile(IMavenConstants.POM_FILE_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the file may only be retrieved if the project has the maven nature, so the call could be easily moved to l1112 making it more logical, I think.
if (profiles.stream().anyMatch(p -> OPENSHIFT_MAVEN_PROFILE.equals(p.getId())) && !activeProfiles.contains(OPENSHIFT_MAVEN_PROFILE)) { | ||
activeProfiles.add(OPENSHIFT_MAVEN_PROFILE); | ||
profileManager.updateActiveProfiles(facade, activeProfiles, false, true, new NullProgressMonitor()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l1111-1122 could be refactored to a set of 3 methods which then would be reusable - if then moved to a common bundle :
- ProfileData getActiveProfiles(IProject project)
- boolean isActiveProfile(String profileId, IProject project) - optional, could be included in setActiveProfile
- void setActiveProfile(String profileId)
Looks like a benefit if done so, agree?
testPR |
@bdshadow I have retested it with last commit and I was able to create server adapter for eap70 and eap71 template/ |
@jkopriva thank you Now i'm going to refactor my code according to the remarks, rebase it and test against java 9. |
@SuppressWarnings("restriction") | ||
private void setOpenshiftMavenProfileActive(IProject newDeployProject) throws CoreException { | ||
IFile pom = newDeployProject.getFile(IMavenConstants.POM_FILE_NAME); | ||
if (newDeployProject.hasNature(IMavenConstants.NATURE_ID) && pom != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking IFile "pom" against being null isn't enough I believe. IContainer#getFile always returns an instance, regardless whether it exists or not. I think that we should also check pom.isAccessible()
List<ProfileData> profiles = profileManager.getProfileDatas(facade, new NullProgressMonitor()); | ||
List<String> activeProfiles = profiles.stream() | ||
.filter(p -> ProfileState.Active.equals(p.getActivationState())) | ||
.map(p -> p.getId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this lambda can be replaced by a method reference for improved readability: ProfileData::getId
IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(pom, true, new NullProgressMonitor()); | ||
List<ProfileData> profiles = profileManager.getProfileDatas(facade, new NullProgressMonitor()); | ||
List<String> activeProfiles = profiles.stream() | ||
.filter(p -> ProfileState.Active.equals(p.getActivationState())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writing down what we discussed/found out:
with a ~/.m2/settings.xml file, that also has profiles, filtering only on activation states this will have all those activated:
One needs to also filter autoactive profiles:
.filter(p -> ProfileState.Active.equals(p.getActivationState())
&& !p.isAutoActive())
Another thing that we should do:
I thus think that activating the profile should be done where the adapter gets started, not upon creation like it is now |
5e4401b
to
9be188d
Compare
extracted the maven profile to it's own class MavenProfile (which can be activate and eventually deactivated) in org.jboss.tools.openshift.core. |
bae57fa
to
44a104e
Compare
@bdshadow rebased and added tests for MaveProfile |
Signed-off-by: Dmitrii Bocharov <dbocharo@redhat.com>
Signed-off-by: Dmitrii Bocharov <dbocharo@redhat.com>
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
testPR |
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
Signed-off-by: Dmitrii Bocharov <dbocharo@redhat.com>
Tested with java 9. Works fine |
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
@bdshadow When trying the eap70 basic template, I have the project switched to the correct openshift profile but still the kitchensink.war artifact deployed. Weird enough, I see the correct |
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
@adietish actually i removed the usage of property name. I debugged it for eap70 and eap71 and it was returning the same for both: I don't know why it didn't work for you with eap70. I've tested it lots of times already, and once i also had such a problem, and i wrote to you about it. Then everything was fine. I have no idea why this happens sometimes |
we agreed that deploying using the deploy name, rather the module name is the right way to do it. Steps:
Result:a new deployed war directory is created in the temporary server-adapter directory. The existing one stays in place, it is not removed. Therefore rsync will copy both (exploded) wars to OpenShift @robstryker thoughts? |
To solve the above we have to be able to identify that a new war is to be created, the old one should be removed. I currently don't see how we can achieve this. We could simply clean the local "deploy" directory (local sever-adapter storage) before it gets rsynced up to the OpenShift pod.
|
by now it's better to wait for @robstryker as we can be missing smth and solution can be easier (or in the contrary we don't see smth complex). I discussed it with @adietish yesterday. It seems to me that he agreed, though he won't be available for the following 2 weeks too |
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
* Cache is not cleaned properly and we get an incorrect name of the module for deployment | ||
* https://issues.jboss.org/browse/JBIDE-22138#comment-13617731 | ||
*/ | ||
private void clearJSTcache(IProject project) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdshadow I added an additional commit which makes sure that modules get notified of the cleared module cache. Things now work for me:
ps. manually switching the maven profile once the war has already been published will NOT remove the previous jar (see #1785 (comment)). But this won't harm the intended fix for https://issues.jboss.org/browse/JBIDE-26175 where the war stays constant. I'll file this to a new issue |
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import junit.framework.TestCase; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class OpenShiftModuleDeploymentPrefsUtilTest extends TestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 Tested on Win10 with both EAP7.0 and EAP7.1 quickstarts
Signed-off-by: Dmitrii Bocharov dbocharo@redhat.com
A very easy and little fix, but needs to be tested a lot, as can have some unpredictable repercussions.