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

Externalize newapp / newbuild #20645

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Aug 14, 2018

Work in progress, does not build yet. It builds! Creates a few TODOs, externalizes "oc set env" as a side-effect :)
Decouples more apihelpers.

Depends on #20532

cc @soltysh @deads2k

@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 14, 2018
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

I left you some comments and suggestions already :-)

// TODO(juanvallejo): change internal helper to "GetInputReferenceInternal" once https://github.com/openshift/origin/pull/20532 merges
// GetInputReferenceV1 returns the From ObjectReference associated with the
// BuildStrategy.
func GetInputReferenceV1(strategy buildv1.BuildStrategy) *corev1.ObjectReference {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not like this, see how it's done in https://github.com/openshift/origin/pull/20532/files#diff-5cb0d8a77f515d00d8e768a169ded24c it'll be easier for both of us to have those in sync. Besides never create *V1 versions, rather call the old one *Internal and let the external version re-use the name.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can probably just pick the commit that contains all those fixes from that PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do - wanted to do it this way at first, but did not want to overlap changes in that PR. Seeing as how your PR will merge first anyway, I'll go ahead and apply your changes here

@@ -30,9 +28,8 @@ import (

buildv1 "github.com/openshift/api/build/v1"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/oc/util/clientcmd"
envresolve "github.com/openshift/origin/pkg/oc/lib/env"
utilenv "github.com/openshift/origin/pkg/oc/util/env"
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, we have two utils for working with env, we should merge them together.

Copy link
Contributor Author

@juanvallejo juanvallejo Aug 17, 2018

Choose a reason for hiding this comment

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

The utils from the envresolve package depend on the ResourceStore in that same package. They are also used by the build controller. Maybe we could duplicate them and have them live in the oc/lib tree? Misunderstood, initially thought you were referencing the controller helper and the newly created oc/cli envresolve file.

Will go ahead and merge these two cli helpers

resolutionErrorsEncountered := false
containers, _ := selectContainers(spec.Containers, o.ContainerSelector)
containers, _ := selectContainersV1(spec.Containers, o.ContainerSelector)
Copy link
Contributor

Choose a reason for hiding this comment

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

selectContainers should work with external versions, selectContainersInternal with internals.

@@ -26,6 +27,20 @@ func selectContainers(containers []kapi.Container, spec string) ([]*kapi.Contain
return out, skipped
}

// TODO(juanvallejo): remove internal helper once all callers are switched to externals
func selectContainersV1(containers []corev1.Container, spec string) ([]*corev1.Container, []*corev1.Container) {
Copy link
Contributor

Choose a reason for hiding this comment

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

See my other comment about naming this.

@@ -0,0 +1,168 @@
package env
Copy link
Contributor

Choose a reason for hiding this comment

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

See my other comment about this file and package. One of them needs to die, having two will cause confusion and may lead to code duplication.

@@ -13,14 +13,14 @@ import (
kapi "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource"

templatev1 "github.com/openshift/api/template/v1"
templatev1client "github.com/openshift/client-go/template/clientset/versioned/typed/template/v1"
"github.com/openshift/origin/pkg/oc/util/ocscheme"
Copy link
Contributor

Choose a reason for hiding this comment

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

While you're at it, figure out what this is used for and if this can be replaced with kubectl's scheme.

}

// TODO(juanvallejo): we're no longer using an api helper here - but are duplicating logic
// from internal image api helper to make it suitable for the v1 api. Is this okay?
Copy link
Contributor

Choose a reason for hiding this comment

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

Image controller will eventually need the external versions. Make the helpers in image package in that case. At some point in time when we'll decide to split oc out we'll have to figure something out.

@soltysh soltysh self-assigned this Aug 15, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch 2 times, most recently from 3162dfb to b423bc8 Compare August 16, 2018 22:49
@juanvallejo juanvallejo changed the title [WIP] Externalize newapp / newbuild Externalize newapp / newbuild 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
@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch 3 times, most recently from ee8151c to a47edb9 Compare August 17, 2018 17:04
@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch 3 times, most recently from f042e27 to 8231223 Compare August 21, 2018 14:17
@juanvallejo
Copy link
Contributor Author

/retest

@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch 4 times, most recently from 9d22c12 to c00eee8 Compare August 21, 2018 23:11
@@ -24,7 +24,7 @@ import (
imageapi "github.com/openshift/origin/pkg/image/apis/image"
imageclientinternal "github.com/openshift/origin/pkg/image/generated/internalclientset"
imagetypedclient "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion"
"github.com/openshift/origin/pkg/oc/util/clientcmd"
"k8s.io/kubernetes/pkg/api/legacyscheme"
Copy link
Contributor

Choose a reason for hiding this comment

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

Move the import up.

for _, e := range env.List() {
internal := &kapi.EnvVar{}
err := kapiv1.Convert_v1_EnvVar_To_core_EnvVar(&e, internal, nil)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Log the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done


"encoding/json"
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this import up to all of golang imports.

if err != nil {
return nil, err
}
objects = append(objects, runtime.RawExtension{
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks very wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I am a bit hesitant about doing this as well. Maybe it is worth leaving QueryResult.List as an internal list, rather than corev1.List

@@ -789,6 +814,24 @@ func (c *AppConfig) validate() (app.Environment, app.Environment, app.Environmen
return env, buildEnv, params, nil
}

func templateObjectsToAppObjects(objs []runtime.RawExtension) (app.Objects, error) {
converted := []runtime.Object{}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be needed, as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, I needed a way to take all of the raw.Extension objects I receive from building the (now) external templates, and convert them into []runtime.Object

templateclientv1 "github.com/openshift/origin/pkg/template/client/v1"
)

// TODO: remove this helper once all consumers are switched to external versions
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 23, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch from c00eee8 to eacc705 Compare August 31, 2018 03:15
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 31, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch from 81b8f77 to 0da4237 Compare August 31, 2018 21:02
@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 31, 2018
@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch 2 times, most recently from bd6592f to b951eba Compare August 31, 2018 21:23
@juanvallejo
Copy link
Contributor Author

/test end_to_end

@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch from acb2b41 to f119626 Compare September 7, 2018 19:46
@juanvallejo
Copy link
Contributor Author

/retest

@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch from f119626 to 3e4322d Compare September 7, 2018 19:52
@juanvallejo
Copy link
Contributor Author

/test cmd

@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch 3 times, most recently from 87202a1 to 3a5c87b Compare September 8, 2018 21:49
@juanvallejo
Copy link
Contributor Author

/retest

@juanvallejo juanvallejo force-pushed the jvallejo/update-newapp-external branch from 3a5c87b to 40f620e Compare September 8, 2018 22:18
@juanvallejo
Copy link
Contributor Author

/test gcp

@@ -344,7 +344,18 @@ func (o *AppOptions) RunNewApp() error {
}

if o.Action.ShouldPrint() {
return o.Printer.PrintObj(result.List, o.Out)
// TODO(juanvallejo): this needs to be fixed by updating QueryResult.List to be of type corev1.List
Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed with @juanvallejo, this will be fixed in a followup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracked in #20919

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 10, 2018
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

config.KubeClient = kclient

config.KubeClient, err = kubernetes.NewForConfig(clientConfig)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know why you're such a fan of empty lines 😜, you put quite a lot of them in your PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes things less claustrophobic? :)

From: &objRef,
},
})
source.Images = []buildapi.ImageSource{imgSrc}
source.Images = []buildv1.ImageSource{imgSrc}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing this was one of your problems. I fixed a similar problem in the generator as well.

@soltysh
Copy link
Contributor

soltysh commented Sep 10, 2018

Applying the approve label manually, since all the changes are CLI-triggered from new-app/new-build commands switch to externals.

@soltysh soltysh added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2018
@openshift-merge-robot openshift-merge-robot merged commit 5ab1a78 into openshift:master Sep 10, 2018
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: juanvallejo, 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

@juanvallejo juanvallejo deleted the jvallejo/update-newapp-external branch September 10, 2018 13:52
@gabemontero gabemontero mentioned this pull request Apr 25, 2019
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.

5 participants