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

Register OpenShift resources to API groups #12986

Merged
merged 8 commits into from
Mar 17, 2017

Conversation

mfojtik
Copy link
Contributor

@mfojtik mfojtik commented Feb 16, 2017

This is a work-in-progress PR that registers the OpenShift types into API groups.

  • authorization.openshift.io
    • Fix the case when removing project deletes default clusterpolicies
    • Add test to make sure RootScopedResources agrees with the strategy IsNamespaced()
  • build.openshift.io
  • deploy.openshift.io => apps.openshift.io
  • image.openshift.io
  • oauth.openshift.io
  • project.openshift.io
  • route.openshift.io
    • Fix broken oc expose generator
  • networking.openshift.io
  • security.openshift.io
  • template.openshift.io
  • user.openshift.io
    • Fix broken impersonification
  • Fix broken describers
  • Fix unit tests
  • Fix integration tests
  • Fix extended tests
  • Refactor API group registration to use its own AddInternalTypes (and do not rely on legacy code)
  • CrossVersionObjectReference should have a Group field kubernetes/kubernetes#41878

@mfojtik mfojtik requested review from soltysh and sttts February 16, 2017 10:15
@mfojtik mfojtik added this to the 1.6.0 milestone Feb 16, 2017
knet "k8s.io/kubernetes/pkg/util/net"

build "github.com/openshift/origin/pkg/build/api"
buildv1 "github.com/openshift/origin/pkg/build/api/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

buildapi and buildapiv1 may be more appropriate.

@@ -12,7 +12,6 @@ import (
"k8s.io/kubernetes/pkg/util/diff"
"k8s.io/kubernetes/pkg/util/intstr"

v1 "github.com/openshift/origin/pkg/api/v1"
deployapi "github.com/openshift/origin/pkg/deploy/api"
_ "github.com/openshift/origin/pkg/deploy/api/install"
deployv1 "github.com/openshift/origin/pkg/deploy/api/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

deployapi and deployapiv1 may be more appropriate.

found := false
for _, g := range groups.Groups {
if g.Name == buildv1.GroupName {
found = true
Copy link
Contributor

Choose a reason for hiding this comment

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

add a break directly

@@ -171,6 +175,124 @@ func TestWellKnownOAuthOff(t *testing.T) {
}
}

func TestApiGroups(t *testing.T) {
testutil.RequireEtcd(t)
Copy link
Contributor

@guangxuli guangxuli Feb 16, 2017

Choose a reason for hiding this comment

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

Split this test function into three function TestBuildApiGroup TestDeployApiGroup TestTemplateApiGroup maybe better, and add another common test config function. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@guangxuli mind if all this refactoring will be a follow up? don't want to increase the diff size of already big change :-)

@mfojtik mfojtik requested a review from deads2k February 16, 2017 12:45
@pweil-
Copy link

pweil- commented Feb 16, 2017

@bparees @knobunc @legionus @enj FYI since this affects api types in your areas

@@ -7,7 +7,7 @@ import (

const GroupName = ""

// SchemeGroupVersion is group version used to register these objects
// LegacySchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: "v1"}
Copy link
Contributor

Choose a reason for hiding this comment

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

godoc misaligned w/ field name (i'm not sure which is correct....)

@bparees
Copy link
Contributor

bparees commented Feb 16, 2017

please make sure the extended builds tests get run on this PR before it merges.

@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 16, 2017

@bparees this is a long way to be testable :)

@mfojtik mfojtik force-pushed the apigroups branch 4 times, most recently from ece8195 to 29c7713 Compare February 20, 2017 16:47
@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 20, 2017

@sttts @deads2k this should now include all api groups for all origin resources. Besides broken tests, there are couple things that are worrying me:

  1. When I delete project, the default clusterPolicies are removed and breaking the cluster. I suspect the namespace finalizer it not working properly.
  2. The impersonification is not working (Error from server (Forbidden): User "test-admin" cannot "impersonate" "user.openshift.io.systemusers" with name "system:admin" in project ""). I suspect the newRESTMapper and the "rootScoped" resources...

@smarterclayton @liggitt PTAL if you have any comments/concerns/etc. before I go on the journey of fixing all tests...

@@ -21,7 +21,20 @@ var OldestVersion = unversioned.GroupVersion{Group: "", Version: "v1"}
// may be assumed to be most preferred to least preferred, and clients may
// choose to prefer the earlier items in the list over the latter items when presented
// with a set of versions to choose.
var Versions = []unversioned.GroupVersion{{Group: "", Version: "v1"}}
var Versions = []unversioned.GroupVersion{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k is there any less-uglier way to determine if a resource is "openshift"?

(or this will go away once we have client-go that includes k8s client as well?).

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 even remember what this is used for. I thought we used reflection to find out if it was an openshift type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i found this in our client that use this to distinguish between kube and origin resources...

@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 20, 2017

@sttts ./pkg/api/... unit tests are working \o/

@@ -133,7 +133,7 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
},
},
Rules: []authorizationapi.PolicyRule{
authorizationapi.NewRule("impersonate").Groups(kapiGroup).Resources(authorizationapi.SystemUserResource).Names(SystemAdminUsername).RuleOrDie(),
authorizationapi.NewRule("impersonate").Groups(authzGroup, legacyAuthzGroup, userGroup).Resources(authorizationapi.SystemUserResource).Names(SystemAdminUsername).RuleOrDie(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k PTAL (i think authzGroup is not required, what fixed this was addition of userGroup)

Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k PTAL (i think authzGroup is not required, what fixed this was addition of userGroup)

Our system users kind should be grouped, so the new code is probably overly loose.

@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 21, 2017

[test]

@@ -240,7 +240,7 @@ func OkHPAForDeploymentConfig(config *deployapi.DeploymentConfig, min, max int)
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{
Name: config.Name,
Kind: "DeploymentConfig",
Kind: "DeploymentConfig.deploy.openshift.io",
Copy link
Contributor

Choose a reason for hiding this comment

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

Um... this is wrong, Kind does not get group versions appended to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

CrossVersionObjectReference should have a Group field.

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.. it only have APIVersion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will open upstream issue

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 pretty sure that's the API version field that has the group and version squashed together with a slash :-(

@mfojtik mfojtik force-pushed the apigroups branch 2 times, most recently from af5aadc to e01344a Compare February 22, 2017 10:40
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addConversionFuncs, addDefaultingFuncs)
AddToScheme = SchemeBuilder.AddToScheme
)

// Adds the list of known types to api.Scheme.
// addKnownTypes adds types to API group
Copy link
Contributor

Choose a reason for hiding this comment

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

... adds the API group types to the scheme

@@ -14,11 +17,17 @@ func init() {
GroupName: api.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
Copy link
Contributor

Choose a reason for hiding this comment

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

why not here?

@@ -14,11 +17,17 @@ func init() {
GroupName: api.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
ImportPrefix: importPrefix,
//AddInternalObjectsToScheme: api.AddToScheme,
AddInternalObjectsToScheme: func(scheme *runtime.Scheme) error {
docker10.AddToScheme(scheme)
Copy link
Contributor

Choose a reason for hiding this comment

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

aggregate errors... ok for testing

@mfojtik mfojtik force-pushed the apigroups branch 3 times, most recently from baaba1a to bf2e2c2 Compare February 22, 2017 15:26
@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 22, 2017

@deads2k @liggitt @sttts @smarterclayton squashed and prettified for easier reviewing. all unit tests should be green by now.

@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 22, 2017

@smarterclayton
Copy link
Contributor

smarterclayton commented Mar 17, 2017 via email

@liggitt
Copy link
Contributor

liggitt commented Mar 17, 2017

For admission, why don't we put something early in the chain that collapses groups to core for now and slate a follow up?

Mutable admission attributes aren't tech debt I'm eager to take on

@smarterclayton
Copy link
Contributor

smarterclayton commented Mar 17, 2017 via email

@smarterclayton
Copy link
Contributor

smarterclayton commented Mar 17, 2017 via email

@openshift-bot
Copy link
Contributor

openshift-bot commented Mar 17, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (Image: devenv-rhel7_6074)

@mfojtik
Copy link
Contributor Author

mfojtik commented Mar 17, 2017

re-[merge]

(forgot to update bootstrap test fixture)

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 3e9c0f0

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test Running (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/283/) (Base Commit: bd446c7)

@openshift-bot
Copy link
Contributor

Evaluated for origin testextended up to 3e9c0f0

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 3e9c0f0

@mfojtik
Copy link
Contributor Author

mfojtik commented Mar 17, 2017

@smarterclayton @liggitt will

mfojtik@9a9032f do?

I looked at other admission controllers and it seems image policy is special as it takes list of resources to enforce the policy as part of configuration... I don't see any other admission plugin having the same problem (but maybe I'm wrong ;-)

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/testextended FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/46/) (Base Commit: bd446c7) (Extended Tests: core)

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS

@openshift-bot openshift-bot merged commit 75c6750 into openshift:master Mar 17, 2017
@mfojtik
Copy link
Contributor Author

mfojtik commented Mar 17, 2017

montypythonstoning

@sttts
Copy link
Contributor

sttts commented Mar 17, 2017

🎉

@smarterclayton
Copy link
Contributor

smarterclayton commented Mar 17, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.