Skip to content

Register OpenShift resources to API groups - #12986

Merged
openshift-bot merged 8 commits into
openshift:masterfrom
mfojtik:apigroups
Mar 17, 2017
Merged

openshift-bot merged 8 commits into
openshift:masterfrom
mfojtik:apigroups

Conversation

@mfojtik

@mfojtik mfojtik commented Feb 16, 2017 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

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
Copy Markdown
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
Copy Markdown
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

}

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

@guangxuli guangxuli Feb 16, 2017 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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-

pweil- commented Feb 16, 2017

Copy link
Copy Markdown

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

Comment thread pkg/build/api/v1/register.go Outdated

// 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
Copy Markdown
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

bparees commented Feb 16, 2017

Copy link
Copy Markdown
Contributor

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

@mfojtik

mfojtik commented Feb 16, 2017

Copy link
Copy Markdown
Contributor Author

@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

mfojtik commented Feb 20, 2017 •

Copy link
Copy Markdown
Contributor Author

@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...

Comment thread pkg/api/latest/latest.go
// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

mfojtik commented Feb 20, 2017

Copy link
Copy Markdown
Contributor Author

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

},
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
Copy Markdown
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
Copy Markdown
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

mfojtik commented Feb 21, 2017

Copy link
Copy Markdown
Contributor Author

[test]

Comment thread pkg/deploy/api/test/ok.go Outdated
ScaleTargetRef: autoscaling.CrossVersionObjectReference{
Name: config.Name,
Kind: "DeploymentConfig",
Kind: "DeploymentConfig.deploy.openshift.io",

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
)

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

Copy link
Copy Markdown
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

Comment thread pkg/image/api/install/apigroup.go Outdated
@@ -14,11 +17,17 @@ func init() {
GroupName: api.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not here?

Comment thread pkg/image/api/install/apigroup.go Outdated
ImportPrefix: importPrefix,
//AddInternalObjectsToScheme: api.AddToScheme,
AddInternalObjectsToScheme: func(scheme *runtime.Scheme) error {
docker10.AddToScheme(scheme)

Copy link
Copy Markdown
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

mfojtik commented Feb 22, 2017

Copy link
Copy Markdown
Contributor Author

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

@mfojtik

mfojtik commented Feb 22, 2017

Copy link
Copy Markdown
Contributor Author

@liggitt

liggitt commented Mar 16, 2017

Copy link
Copy Markdown
Contributor

@liggitt I think the reason the infa_sa policy works as it is now (we should have APIGroups for all origin resources) is that all controllers in Origin use legacy client code (and we store all resources in legacy format in etcd).

actual API used doesn't matter for virtual resources, since we construct the group/resource check ourselves (and the admission plugin is constructing it using the groupified resource)

@soltysh

soltysh commented Mar 16, 2017

Copy link
Copy Markdown
Contributor

Based on overall approval we're merging this as is, all the remaining this will be addressed as followups.

[merge]

@smarterclayton

smarterclayton commented Mar 17, 2017 via email

Copy link
Copy Markdown
Contributor

@liggitt

liggitt commented Mar 17, 2017

Copy link
Copy Markdown
Contributor

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

smarterclayton commented Mar 17, 2017 via email

Copy link
Copy Markdown
Contributor

@smarterclayton

smarterclayton commented Mar 17, 2017 via email

Copy link
Copy Markdown
Contributor

@openshift-bot

openshift-bot commented Mar 17, 2017 •

Copy link
Copy Markdown
Contributor

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

@mfojtik

mfojtik commented Mar 17, 2017

Copy link
Copy Markdown
Contributor Author

re-[merge]

(forgot to update bootstrap test fixture)

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 3e9c0f0

@openshift-bot

Copy link
Copy Markdown
Contributor

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin testextended up to 3e9c0f0

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 3e9c0f0

@mfojtik

mfojtik commented Mar 17, 2017 •

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/test SUCCESS

@mfojtik

mfojtik commented Mar 17, 2017

Copy link
Copy Markdown
Contributor Author

montypythonstoning

@sttts

sttts commented Mar 17, 2017

Copy link
Copy Markdown
Contributor

🎉

@smarterclayton

smarterclayton commented Mar 17, 2017 via email

Copy link
Copy Markdown
Contributor

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.