Merge pull request #25307 from derekwaynecarr/set_uid_from_context

Automatic merge from submit-queue

Allow handlers earlier in a request flow to inject a UID for an object

This lets admission controllers specify a stable UID for an object prior to its creation.  That lets the admission controller then record a reference to the object on another resource using that stable UID prior to the object being created.  This would be a prerequisite for supporting quota reservations.

/cc @smarterclayton @lavalamp @deads2k
This commit is contained in:
k8s-merge-robot
2016-07-20 09:58:51 -07:00
committed by GitHub
3 changed files with 37 additions and 5 deletions

View File

@@ -29,7 +29,13 @@ import (
// FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta.
func FillObjectMetaSystemFields(ctx Context, meta *ObjectMeta) {
meta.CreationTimestamp = unversioned.Now()
meta.UID = util.NewUUID()
// allows admission controllers to assign a UID earlier in the request processing
// to support tracking resources pending creation.
uid, found := UIDFrom(ctx)
if !found {
uid = util.NewUUID()
}
meta.UID = uid
meta.SelfLink = ""
}