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

External graph library and company #20532

Merged
merged 9 commits into from
Aug 21, 2018

Conversation

soltysh
Copy link
Member

@soltysh soltysh commented Aug 3, 2018

No description provided.

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 3, 2018
@openshift-bot
Copy link
Contributor

/retest

@soltysh soltysh force-pushed the external_images branch 2 times, most recently from ae911b5 to ea2ce08 Compare August 14, 2018 13:50
@soltysh soltysh changed the title WIP: External graph library and company External graph library and company Aug 16, 2018
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 16, 2018
@soltysh
Copy link
Member Author

soltysh commented Aug 16, 2018

OK, this is ready for review, although I still have some prunning unit tests to fix.

/assign @bparees @dmage
for image and build changes

/assign @juanvallejo
for general CLI stuff

/assign @deads2k
for api changes (but small 😉 )

@@ -55,7 +55,7 @@ items:
strategy:
dockerStrategy:
from:
kind: DockerReference
kind: DockerImage
Copy link
Member Author

Choose a reason for hiding this comment

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

@bparees that was weird change, do we somehow convert DockerReference to DockerImage during conversion from external to internal, I coulnd't find anything like that. If not, how this could ever work?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can only speculate that this object was never being passed through build api validation?

because i don't think "DockerReference" would have ever been correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that what I imagined as well, that's why this is now fixed :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@soltysh would be nice if we can call the validation in test to ensure the objects are actually valid :-) (follow up issue?)

legacy.InstallExternalLegacyAll(scheme)
codecs := serializer.NewCodecFactory(scheme)
decoder := codecs.UniversalDeserializer()
obj, err := runtime.Decode(decoder, data)
Copy link
Member Author

Choose a reason for hiding this comment

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

@deads2k for the tests that rely on scheme I've decided to create a standalone scheme installing only the APIs I cared about, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k for the tests that rely on scheme I've decided to create a standalone scheme installing only the APIs I cared about, wdyt?

That's a good idea. You may wan to to use k8s.io/apimachinery/pkg/api/testing.SchemeForOrDie which allows you to just list the various install methods.

install.InstallInternalKube(scheme)
install.InstallInternalOpenShift(scheme)
codecs := serializer.NewCodecFactory(scheme)
decoder := codecs.UniversalDecoder()
obj, err := runtime.Decode(decoder, data)
Copy link
Member Author

Choose a reason for hiding this comment

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

@deads2k I had to leave this decode as it was before instead of deserializer b/c I needed defaulting to kick in.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine as a stepping stone. We'll need to sort it out before we can snip oc entirely.

@@ -94,36 +96,66 @@ func GetPodSpec(obj runtime.Object) (*kapi.PodSpec, *field.Path, error) {
// This only returns pod specs for v1 compatible objects.
func GetPodSpecV1(obj runtime.Object) (*kapiv1.PodSpec, *field.Path, error) {
switch r := obj.(type) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, since we have cli commands that depend on this, couldn't we snip this link between oc and api helpers by creating a PodSpecGetter or similar under polymorphic helpers?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, worth discussing, but definitely not in this PR ;-)

@bparees
Copy link
Contributor

bparees commented Aug 16, 2018

@soltysh the commit for the builds (7240c76) looks fine.. where are the image changes? (I don't really want to dig through 94 files if i can avoid it)

if cast.ReplicaSet.Spec.Selector != nil {
selector = cast.ReplicaSet.Spec.Selector.MatchLabels
}
AddManagedByControllerPodEdges(g, cast, cast.ReplicaSet.Namespace, selector)
Copy link
Contributor

Choose a reason for hiding this comment

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

:/ we will eventually do this in a more generic way (rather than an ever-increasing switch) right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hehe, we'll need to figure something out, for sure.

}
// image.DockerImageMetadata = imagev1.DockerImage{
// ID: *configName,
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a TODO? Do we still need to find a way to modify the contents of imagev1.DockerImage metadata?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that was that failing unit tests that I fixed already.

@@ -728,44 +744,14 @@ func (p *describingManifestDeleter) DeleteManifest(registryClient *http.Client,
return err
}

// getClients returns a OpenShift client and Kube client.
func getClients(f kcmdutil.Factory) (appsclient.DeploymentConfigsGetter, buildclient.BuildInterface, imageclient.ImageInterface, kclientset.Interface, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

glad to see old pieces of the cmdutil factory gone

@juanvallejo
Copy link
Contributor

A few comments, otherwise cli pieces lgtm

@@ -143,6 +143,9 @@ func (intstr *IntOrString) Fuzz(c fuzz.Continue) {
}

func GetValueFromIntOrPercent(intOrPercent *IntOrString, total int, roundUp bool) (int, error) {
if intOrPercent == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

per my comment upstream. I think we need to avoid value compression. You can have a defaulttozeroifnil function that you wrap the call to this with, but this method needs the distinction.

@soltysh
Copy link
Member Author

soltysh commented Aug 17, 2018

@soltysh the commit for the builds (7240c76) looks fine.. where are the image changes? (I don't really want to dig through 94 files if i can avoid it)

I was hoping you look through both graph changes and admin cli, at least the parts that are touching images.

@@ -1,17 +1,17 @@
package graphview
Copy link
Contributor

Choose a reason for hiding this comment

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

the file itself probably deserves a rename :-)

@@ -38,15 +35,7 @@ func FindHPASpecsMissingCPUTargets(graph osgraph.Graph, namer osgraph.Namer) []o
for _, uncastNode := range graph.NodesByKind(kubenodes.HorizontalPodAutoscalerNodeKind) {
node := uncastNode.(*kubenodes.HorizontalPodAutoscalerNode)

cpuFound := false
Copy link
Contributor

Choose a reason for hiding this comment

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

what happened here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Difference in internal vs external API.

@@ -120,7 +119,7 @@ func AddManagedByControllerPodEdges(g osgraph.MutableUniqueGraph, to graph.Node,
continue
}
if query.Matches(labels.Set(target.Labels)) {
g.AddEdge(target, to, ManagedByControllerEdgeKind)
g.AddEdge(target, to, appsgraph.ManagedByControllerEdgeKind)
Copy link
Contributor

Choose a reason for hiding this comment

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

does not sound right :-) you importing this just to get a const...

Copy link
Member Author

Choose a reason for hiding this comment

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

I had to move that constant, otherwise I was getting import cycles.

Copy link
Contributor

Choose a reason for hiding this comment

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

@soltysh maybe create some common package for const, we can handle that as follow up

history := imageStream.Status.Tags[tag]
newHistory := imageapi.TagEventList{}
var history imagev1.NamedTagEventList
for _, t := range imageStream.Status.Tags {
Copy link
Contributor

Choose a reason for hiding this comment

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

@soltysh this pattern repeats over and over in code... I would make this a helper, something like:

func IfHasTag(imageStream, tagName, func(t Tag) error) bool, error

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll open a followup for these helpers.

@@ -210,7 +210,7 @@ func (o *CancelBuildOptions) RunCancelBuild() error {
}
}

if stateMatch && !buildutil.IsTerminalPhase(build.Phase) {
if stateMatch && !buildutil.IsTerminalPhase(build.Status.Phase) {
Copy link
Contributor

Choose a reason for hiding this comment

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

sneaky :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sneaky, but that's how the external API differs from internal.

@soltysh
Copy link
Member Author

soltysh commented Aug 21, 2018

Switched the build commit to use internal helpers.

@soltysh
Copy link
Member Author

soltysh commented Aug 21, 2018

/retest

@mfojtik
Copy link
Contributor

mfojtik commented Aug 21, 2018

/lgtm

let the race begin!

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 21, 2018
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2018
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mfojtik, soltysh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@soltysh
Copy link
Member Author

soltysh commented Aug 21, 2018

Rebased - tagging back.

@soltysh soltysh added the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2018
@openshift-merge-robot openshift-merge-robot merged commit d87f18a into openshift:master Aug 21, 2018
@soltysh soltysh deleted the external_images branch August 22, 2018 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants