Skip to content

Add initializer support to admission and uninitialized filtering to rest storage#36721

Merged
k8s-github-robot merged 5 commits into
kubernetes:masterfrom
smarterclayton:initializers
Jun 3, 2017
Merged

Add initializer support to admission and uninitialized filtering to rest storage#36721
k8s-github-robot merged 5 commits into
kubernetes:masterfrom
smarterclayton:initializers

Conversation

@smarterclayton

@smarterclayton smarterclayton commented Nov 13, 2016

Copy link
Copy Markdown
Contributor

Initializers are the opposite of finalizers - they allow API clients to react to object creation and populate fields prior to other clients seeing them.

High level description:

  1. Add metadata.initializers field to all objects
  2. By default, filter objects with > 0 initializers from LIST and WATCH to preserve legacy client behavior (known as partially-initialized objects)
  3. Add an admission controller that populates .initializer values per type, and denies mutation of initializers except by certain privilege levels (you must have the initialize verb on a resource)
  4. Allow partially-initialized objects to be viewed via LIST and WATCH for initializer types
  5. When creating objects, the object is "held" by the server until the initializers list is empty
  6. Allow some creators to bypass initialization (set initializers to []), or to have the result returned immediately when the object is created.

The code here should be backwards compatible for all clients because they do not see partially initialized objects unless they GET the resource directly. The watch cache makes checking for partially initialized objects cheap. Some reflectors may need to change to ask for partially-initialized objects.

Kubernetes resources, when the `Initializers` admission controller is enabled, can be initialized (defaulting or other additive functions) by other agents in the system prior to those resources being visible to other clients.  An initialized resource is not visible to clients unless they request (for get, list, or watch) to see uninitialized resources with the `?includeUninitialized=true` query parameter.  Once the initializers have completed the resource is then visible.  Clients must have the the ability to perform the `initialize` action on a resource in order to modify it prior to initialization being completed.

@smarterclayton smarterclayton added this to the v1.6 milestone Nov 13, 2016
@smarterclayton smarterclayton added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Nov 13, 2016
@smarterclayton

smarterclayton commented Nov 13, 2016

Copy link
Copy Markdown
Contributor Author

@liggitt @bgrant0607 @derekwaynecarr @ncdc @kubernetes/sig-api-machinery as discussed at KubeCon there was a general feeling that initializers are technically solvable and a better path than more complexity in admission extension (make admission extensible like controllers is a better story than more web hooks, each of which is a net new API). I think from prototyping it that this will be no worse for performance than any out of process admission controller, and because it can leverage informers it's actually the most performant approach.

This does not obviate cleaning up admission control in process - the most efficient way to have admission would still be one big chain, as opposed to many small ones. But I think it solves the fifth part of #34131 better than the other approaches.

@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note-label-needed labels Nov 13, 2016
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Jenkins GCI GKE smoke e2e failed for commit 2444005. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Jenkins GKE smoke e2e failed for commit 2444005. Full PR test history.

The magic incantation to run this job again is @k8s-bot cvm gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@bgrant0607

Copy link
Copy Markdown
Member

(5) means that apiserver doesn't respond to the creation request until initialization has completed or failed, correct?

@bgrant0607

Copy link
Copy Markdown
Member

#17305

@smarterclayton

Copy link
Copy Markdown
Contributor Author

Or timeout, correct. Will be trying to draft a larger proposal soon to cover the full scope of extension (on top of ncdc's previous work).

}

func (i initializer) Handles(op admission.Operation) bool {
return op == admission.Create

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought we still have some objects that support create on update?

@derekwaynecarr

Copy link
Copy Markdown
Member

I like where this is going. Let me know if I can help in any particular area.

@deads2k

deads2k commented Nov 23, 2016

Copy link
Copy Markdown
Contributor

I like where this is going. Let me know if I can help in any particular area.

Funny you should ask. :) Quota of non-count resources needs to be refactored to be an initializer so that it can run after all initializers have had a chance to update those resources. The admission path for "update things that haven't been initialized" is different than a normal "update" and could easily end up more noisy than it needs to be with multiple writes happening before the end of initialization which would require excessive compensation (openshift normally goes through two passes right?).

Also, refactoring resource quota as initialization makes it possible to provide an easy entry point for any API server to ask for quota on an immutable field (or an expensive count implementation) without needing to compile in and configure an implementation of quota in its admission chain. Combine it with a way find resource-y things (same problem as our current podspec-y things) and it ought to just work.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 24, 2016
@smarterclayton

Copy link
Copy Markdown
Contributor Author

Started a proposal at kubernetes/community#132

@smarterclayton

smarterclayton commented Jan 1, 2017 via email

Copy link
Copy Markdown
Contributor Author

@deads2k

deads2k commented Jan 9, 2017

Copy link
Copy Markdown
Contributor

Quota would not be an initializer - it doesn't need to be extensible in the
vast majority of cases (each api server only manages quota for its own
resources).

You have to calculate quota after all limits have been set. That can't be done in the admission chain since an initializer can change it. Where would it happen?

@smarterclayton

smarterclayton commented Jan 9, 2017 via email

Copy link
Copy Markdown
Contributor Author

@ncdc

ncdc commented Jun 1, 2017

Copy link
Copy Markdown
Member

I see it in the queue

@smarterclayton

smarterclayton commented Jun 1, 2017 via email

Copy link
Copy Markdown
Contributor Author

@smarterclayton

Copy link
Copy Markdown
Contributor Author

Rebased for the change to third party resources.

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-e2e-kops-aws test this

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-unit test this

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-verify test this

@caesarxuchao

Copy link
Copy Markdown
Contributor

@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this
@k8s-bot pull-kubernetes-federation-e2e-gce test this

@shashidharatd

Copy link
Copy Markdown

@k8s-bot pull-kubernetes-federation-e2e-gce test this
ref: #46827

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this

@smarterclayton

Copy link
Copy Markdown
Contributor Author

Trivial rebase

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-unit test this

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-unit test this
@k8s-bot pull-kubernetes-e2e-kops-aws test this

@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-verify test this

Add support for creating resources that are not immediately visible to
naive clients, but must first be initialized by one or more privileged
cluster agents. These controllers can mark the object as initialized,
allowing others to see them.

Permission to override initialization defaults or modify an initializing
object is limited per resource to a virtual subresource "RESOURCE/initialize"
via RBAC.

Initialization is currently alpha.
Running without an authorizer is a valid configuration.
@smarterclayton

Copy link
Copy Markdown
Contributor Author

@k8s-bot pull-kubernetes-verify test this

@smarterclayton

Copy link
Copy Markdown
Contributor Author

/lgtm
rebase fixup

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

@smarterclayton: you cannot LGTM your own PR.

Details

In response to this:

/lgtm
rebase fixup

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-github-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lavalamp, smarterclayton

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

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot

Copy link
Copy Markdown

Automatic merge from submit-queue

@lavalamp

lavalamp commented Jun 5, 2017

Copy link
Copy Markdown
Contributor

yay, it merged. Time for me to rebase :)

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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.