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-24184] get debug port and devmode switch from image #1518
Conversation
59d1780
to
a79af5c
Compare
714d04f
to
606e098
Compare
@bdshadow @jeffmaury @rhopp could you please test this huge one? the changes here are (among a general overhaul of the server adapter code):
|
8d412e4
to
f0ba3c6
Compare
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.
Andre, look at some of the remarks after a quick look. Of course i'll review and test it more later.
* @param collection | ||
* @return | ||
*/ | ||
public static <T> boolean isEmpty(Collection<T> collection) { |
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.
don't think that we really need it. Apache CollectionUtils
has already this method and can be seen from all the places of usage of this isEmpty
.
} | ||
return ValidationStatus.ok(); | ||
} | ||
|
||
protected boolean isDisabled() { | ||
Boolean disabled = this.disabledObservable.getValue(); |
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.
return this.disabledObservable.getValue();
is enough here
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.
i dont think so, since it could be null
DockerImageURI uri = trigger.getFrom(); | ||
|
||
return getImageStreamTag(uri, resource.getNamespace()); | ||
// String imageRef = getImageRef(dc, connection); |
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.
do we need such a big comment left here?
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.
@adietish i think we can remove it
boolean running = POD_STATE_RUNNING.equalsIgnoreCase(it.next().getStatus()); | ||
if (expectedRunning == !running) { | ||
return false; | ||
} else if (expectedRunning == running) { |
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.
smth really strange is going here. If we go to else
, there is no sense to check expectedRunning == running
- it'll be 100% true. And why do we return false
in both cases?
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.
lol, indeed +100. this looks like a snippet worth publishing to "coding horror".
} | ||
|
||
@Test | ||
public void testEnableDebug() 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.
possibly, worth deleting these comments too
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 test is in the doing
@adietish tested multiple times with eap application. Can't debug it ;(
|
@bdshadow
while in the explorer, as child of the service, I see a different pod namely |
* | ||
* @author Andre Dietisheim | ||
*/ | ||
public interface OpenShiftResourceSelectors { |
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.
@@ -27,24 +29,27 @@ | |||
private static final String ENV = "Env"; | |||
private static final String EXPOSED_PORT = "ExposedPorts"; | |||
private static final String VOLUMES = "Volumes"; | |||
private static final String LABELS = "Labels"; | |||
|
|||
private final ModelNode node; | |||
private final String [] CONFIG_ROOT; |
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.
@@ -27,24 +29,27 @@ | |||
private static final String ENV = "Env"; | |||
private static final String EXPOSED_PORT = "ExposedPorts"; | |||
private static final String VOLUMES = "Volumes"; | |||
private static final String LABELS = "Labels"; | |||
|
|||
private final ModelNode node; | |||
private final String [] CONFIG_ROOT; | |||
private final String[] PORT_KEY; |
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.
@@ -27,24 +29,27 @@ | |||
private static final String ENV = "Env"; | |||
private static final String EXPOSED_PORT = "ExposedPorts"; | |||
private static final String VOLUMES = "Volumes"; | |||
private static final String LABELS = "Labels"; | |||
|
|||
private final ModelNode node; | |||
private final String [] CONFIG_ROOT; | |||
private final String[] PORT_KEY; | |||
private final String[] VOLUMES_KEY; |
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.
@@ -27,24 +29,27 @@ | |||
private static final String ENV = "Env"; | |||
private static final String EXPOSED_PORT = "ExposedPorts"; | |||
private static final String VOLUMES = "Volumes"; | |||
private static final String LABELS = "Labels"; | |||
|
|||
private final ModelNode node; | |||
private final String [] CONFIG_ROOT; | |||
private final String[] PORT_KEY; | |||
private final String[] VOLUMES_KEY; | |||
private final String[] ENV_KEY; |
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 @bdshadow as discussed and agreed upon we should merge this asap when branch freeze is repealed |
Connection connection = ConnectionsRegistryUtil.getConnectionFor(rc); | ||
List<IPod> allPods = connection.getResources(ResourceKind.POD, rc.getNamespace()); | ||
return ResourceUtils.getPodsFor(rc, allPods).stream() | ||
.filter(pod -> ResourceUtils.isRuntimePod(pod)) |
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.
605e45e
to
896303f
Compare
*/ | ||
public boolean isRunning(ILaunchConfiguration launchConfiguration) { | ||
return getLaunches() | ||
.filter(l -> !l.isTerminated() && launchMatches(l, launchConfiguration)) |
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.
7808af3
to
9b82489
Compare
if (dc == null) { | ||
throw new CoreException(StatusFactory.errorStatus( | ||
OpenShiftCoreActivator.PLUGIN_ID, "No deployment config present that can be updated.")); | ||
} |
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 complaint is false! the "|" is used on purpose so that both bethods are ALWAYS executed.
62ee9a2
to
b5cc2c1
Compare
public static DebugContext createContext(IControllableServerBehavior behaviour, String devmodeKey, String debugPortKey, String debugPort) { | ||
Assert.isNotNull(behaviour); | ||
|
||
DebugContext context = new DebugContext(behaviour, |
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.
} | ||
|
||
public void setupRemoteDebuggerLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProject project, int debugPort) | ||
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.
IControllableServerBehavior behavior = server.getAdapter(IControllableServerBehavior.class); | ||
return behavior; | ||
protected void launchServerProcess(OpenShiftServerBehaviour beh, ILaunch launch, | ||
IProgressMonitor monitor) { |
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.
monitor.subTask("waiting for docker image to become available..."); | ||
while (!monitor.isCanceled()) { | ||
while (!metadata.load() | ||
&& sleep(RECHECK_DELAY)) { |
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.
ILaunch debuggerLaunch = attachRemoteDebugger(server, localPort, monitor); | ||
if( debuggerLaunch != null ) { | ||
if (debuggerLaunch != 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.
(kind == IncrementalProjectBuilder.FULL_BUILD) || | ||
((kind == IncrementalProjectBuilder.AUTO_BUILD && | ||
ResourcesPlugin.getWorkspace().isAutoBuilding())); | ||
kind == IncrementalProjectBuilder.INCREMENTAL_BUILD |
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.
return images.iterator().next(); | ||
} | ||
|
||
private String getImageStreamTag(String imageDigest, String imageRef, String namespace, Connection connection) { |
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.
} | ||
|
||
if (updateDebugmode(dc, context, monitor) | ||
| updateDevmode(dc, context, monitor)) { |
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.
|
||
private void stopDebugging(IReplicationController rc, DebuggingContext debugContext, IProgressMonitor monitor) | ||
throws CoreException { | ||
private void stopDebugging(DebugContext debugContext, IProgressMonitor monitor) { |
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.
33515d0
to
ae953c6
Compare
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
debugContext.setDebugPort(8787);//TODO get default port from server settings? | ||
} | ||
protected void startDebugging(OpenShiftServerBehaviour behaviour, DebugContext context, | ||
IProgressMonitor monitor) { |
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.
SonarQube analysis reported 61 issues Watch the comments in this conversation to review them. 7 extra issuesNote: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:
|
Pull Request Checklist
General
Code
Testing
Function