[jbosstools-issues] [JBoss JIRA] (JBIDE-25830) After starting CDK server adapter OpenShift Connection does not work when oc is not on path

Rob Stryker (JIRA) issues at jboss.org
Fri Apr 6 13:22:01 EDT 2018


    [ https://issues.jboss.org/browse/JBIDE-25830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13557582#comment-13557582 ] 

Rob Stryker commented on JBIDE-25830:
-------------------------------------

I just checked nad tested, and I can't replicate this bug. 

1) I removed oc from my path
2) I ensured no minishift_home is set
3) I start my eclipse environment
4) I open the openshift 3 preference page and verify there is no workspace setting for oc location
5) I create a cdk server, pointing to a cdk3.2 instance, and a minishift_home of ~/.minishift
6) I start the cdk server adapter
7) I wait
8) I get asked to approve an SSL connection, which I approve
9) The openshift connection is created
10) I edit the openshift connection, and expand the advanced section
11) I verify that "override oc location' is checked
12) I verify that the path to oc is set to /home/rob/.minishift/cache/oc/v3.6.173.0.21/oc

Since the usecase succeeded as expected, I then went to check the code to verify this wasn't magic. 

CDKOpenshiftUtility has the following logic:
{code}
		String ocLoc = env.get(ServiceManagerEnvironmentLoader.OC_LOCATION_KEY);
		if (ocLoc != null) {
			((Connection) con).setExtendedProperty(ICommonAttributes.OC_LOCATION_KEY, ocLoc);
			((Connection) con).setExtendedProperty(ICommonAttributes.OC_OVERRIDE_KEY, true);
		}
{code}

This means it is pulling the oc location from a "ServiceManagerEnvironment". Where did the service manager environment get it from? MinishiftServiceManagerEnvironmentLoader has some clues:

{code}
	private File findOCLocation(IServer server) {
		String profileHome = getMinishiftProfileHome(server);
		File root = new File(profileHome);
		if (root.exists()) {
			File cache = new File(root, "cache");
			File oc = new File(cache, "oc");
			if (oc.exists()) {
				String[] names = oc.list();
				if (names != null && names.length > 0) {
					Arrays.sort(names);
					String latest = names[names.length - 1];
					File latestF = new File(oc, latest);
					String platformDep = (Platform.getOS().equals(Platform.OS_WIN32) ? "oc.exe" : "oc");
					File ocBin = new File(latestF, platformDep);
					if (ocBin.exists())
						return ocBin;
				}
			}
		}
		return null;
	}
{code}

This seems to properly return ~/.minishift/cache/oc/v3.6.173.0.21/oc

Can you explain where this is going wrong for you? It seems to work 100% as expected for me. 

> After starting CDK server adapter OpenShift Connection does not work when oc is not on path
> -------------------------------------------------------------------------------------------
>
>                 Key: JBIDE-25830
>                 URL: https://issues.jboss.org/browse/JBIDE-25830
>             Project: Tools (JBoss Tools)
>          Issue Type: Enhancement
>          Components: cdk, openshift
>    Affects Versions: 4.5.3.AM3
>            Reporter: Josef Kopriva
>            Assignee: Rob Stryker
>              Labels: cdk_server_adapter, connection
>             Fix For: 4.5.3.Final
>
>
> OpenShift connection should be working, when user starts CDK server adapter, even if you do not have oc on path. In my opinion OpenShift connection should be working "out of box" when user starts CDK server adapter.
> steps:
> # ASSERT: oc is not on path
> # EXEC: Start CDK server adapter
> # ASSERT: OpenShift connection is created, but does not fully work (all oc related operations wont)
> Error: oc is not set for OpenShift connection to CDK and OpenShift connection does not work.
> Expected: OpenShift connection should be working without user touch.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jbosstools-issues mailing list