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
Refactor inspectContainer() and add commit(), removeImage() #4085
Conversation
Can one of the admins verify this patch? |
return null; | ||
} | ||
|
||
String podPullSpec = pod.getSpec().getContainers().get(0).getImage(); |
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 would be more defensive here. I would check if the num of containers returned by getContainers() is > 0 and if the value returned by getImage() is nullOrEmpty
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.
Fixed
String sourceImage = params.getImage(); // e.g. eclipse/ubuntu_jdk8 | ||
String targetImage = params.getRepository(); // e.g. eclipse-che/<identifier> | ||
String tag = params.getTag(); | ||
if (tag == null || tag.isEmpty()) { | ||
if (sourceImage.contains(":")) { |
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.
You split images string into tag and image name multiple times in the code. To avoid duplication you can probably extract that logic in a new method.
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.
Fixed, there's a few methods in KubernetesStringUtils
that can do most of the work now.
|
||
@Override | ||
public ImageInfo inspectImage(InspectImageParams params) throws IOException { | ||
|
||
String image = params.getImage(); | ||
if (image.contains(":")) { // Image to inspect passed in with tag, which we don't support |
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 code is duplicated in removeImage too. You may want to extract it to a new method
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.
Fixed, this was an oversight by me -- the method already existed.
@amisevsk you should rebase your PR |
@amisevsk that's not related to this PR but you could have a look at that: in method |
fb3b14e
to
1be7e29
Compare
I've rebased the PR and added some test cases. @l0rd For the Another option I considered (instead of truncating) was to do a |
Adds commit() and removeImage() implementations to OpenShiftConnector. This requires some refactoring of existing methods (mostly refactoring repeated processes into their own methods -- e.g. creating an ImageStreamTag and getting image info from a tag). Additionally, refactors inspectContainer() method to remove a call to DockerConnector, instead obtaining the same information from what's available through the OpenShift API. This fixes an issue where the IP address of a workspace was unavailable from the ContainerInfo returned by DockerConnector. Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Signed-off-by: Angel Misevski <amisevsk@redhat.com>
1be7e29
to
29f4f30
Compare
…che#4085) Adds commit() and removeImage() implementations to OpenShiftConnector. This requires some refactoring of existing methods (mostly refactoring repeated processes into their own methods -- e.g. creating an ImageStreamTag and getting image info from a tag). Additionally, refactors inspectContainer() method to remove a call to DockerConnector, instead obtaining the same information from what's available through the OpenShift API. This fixes an issue where the IP address of a workspace was unavailable from the ContainerInfo returned by DockerConnector. Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Adds
commit()
andremoveImage()
implementations toOpenShiftConnector
. This requires some refactoring of existing methods (mostly refactoring repeated processes into their own methods -- e.g. creating anImageStreamTag
and getting image info from a tag).Additionally, refactors
inspectContainer()
method to remove a call toDockerConnector
, instead obtaining the same information from what's available through the OpenShift API. This fixes an issue where the IP address of a workspace was unavailable from theContainerInfo
returned byDockerConnector
.The benefit of these changes is that -- except for exec-related methods -- most uses of
DockerConnector
are removed when running on OpenShift. Note however that custom stacks are still not supported.What does this PR do?
Refactors
inspectContainer()
to use ImageStreamTags instead of Docker, and addscommit()
andremoveImage()
methods.Changelog
Improved OpenShift connector independence from DockerConnector
Release Notes
(Internal changes -- not ready for public release)
Docs PR
Issue tracking work on OpenShift integration docs: https://github.com/eclipse/che-docs/issues/76.