Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2cc7fd

Browse files
committedMay 10, 2016
Merge pull request #18 from mfojtik/rebase
Pick down release 1.2 stable 20160411
2 parents f88b290 + 2c6e844 commit c2cc7fd

File tree

89 files changed

+2921
-288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2921
-288
lines changed
 

‎cmd/kube-apiserver/app/options/options.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,15 @@ func NewAPIServer() *APIServer {
101101
AuthorizationMode: "AlwaysAllow",
102102
DeleteCollectionWorkers: 1,
103103
EnableLogsSupport: true,
104+
EnableProfiling: true,
105+
EnableWatchCache: true,
104106
EtcdConfig: etcdstorage.EtcdConfig{
105107
Prefix: genericapiserver.DefaultEtcdPathPrefix,
106108
},
107109
EventTTL: 1 * time.Hour,
108110
MasterCount: 1,
109111
MasterServiceNamespace: api.NamespaceDefault,
112+
MinRequestTimeout: 1800,
110113
RuntimeConfig: make(config.ConfigurationMap),
111114
StorageVersions: registered.AllPreferredGroupVersions(),
112115
DefaultStorageVersions: registered.AllPreferredGroupVersions(),
@@ -242,17 +245,17 @@ func (s *APIServer) AddFlags(fs *pflag.FlagSet) {
242245
fs.IntVar(&s.MasterCount, "apiserver-count", s.MasterCount, "The number of apiservers running in the cluster")
243246
fs.IntVar(&s.DeleteCollectionWorkers, "delete-collection-workers", s.DeleteCollectionWorkers, "Number of workers spawned for DeleteCollection call. These are used to speed up namespace cleanup.")
244247
fs.Var(&s.RuntimeConfig, "runtime-config", "A set of key=value pairs that describe runtime configuration that may be passed to apiserver. apis/<groupVersion> key can be used to turn on/off specific api versions. apis/<groupVersion>/<resource> can be used to turn on/off specific resources. api/all and api/legacy are special keys to control all and legacy api versions respectively.")
245-
fs.BoolVar(&s.EnableProfiling, "profiling", true, "Enable profiling via web interface host:port/debug/pprof/")
248+
fs.BoolVar(&s.EnableProfiling, "profiling", s.EnableProfiling, "Enable profiling via web interface host:port/debug/pprof/")
246249
// TODO: enable cache in integration tests.
247-
fs.BoolVar(&s.EnableWatchCache, "watch-cache", true, "Enable watch caching in the apiserver")
250+
fs.BoolVar(&s.EnableWatchCache, "watch-cache", s.EnableWatchCache, "Enable watch caching in the apiserver")
248251
fs.BoolVar(&s.EnableSwaggerUI, "enable-swagger-ui", false, "Enables swagger ui on the apiserver at /swagger-ui")
249-
fs.StringVar(&s.ExternalHost, "external-hostname", "", "The hostname to use when generating externalized URLs for this master (e.g. Swagger API Docs.)")
250-
fs.IntVar(&s.MaxRequestsInFlight, "max-requests-inflight", 400, "The maximum number of requests in flight at a given time. When the server exceeds this, it rejects requests. Zero for no limit.")
251-
fs.IntVar(&s.MinRequestTimeout, "min-request-timeout", 1800, "An optional field indicating the minimum number of seconds a handler must keep a request open before timing it out. Currently only honored by the watch request handler, which picks a randomized value above this number as the connection timeout, to spread out load.")
252+
fs.StringVar(&s.ExternalHost, "external-hostname", s.ExternalHost, "The hostname to use when generating externalized URLs for this master (e.g. Swagger API Docs.)")
253+
fs.IntVar(&s.MaxRequestsInFlight, "max-requests-inflight", s.MaxRequestsInFlight, "The maximum number of requests in flight at a given time. When the server exceeds this, it rejects requests. Zero for no limit.")
254+
fs.IntVar(&s.MinRequestTimeout, "min-request-timeout", s.MinRequestTimeout, "An optional field indicating the minimum number of seconds a handler must keep a request open before timing it out. Currently only honored by the watch request handler, which picks a randomized value above this number as the connection timeout, to spread out load.")
252255
fs.StringVar(&s.LongRunningRequestRE, "long-running-request-regexp", s.LongRunningRequestRE, "A regular expression matching long running requests which should be excluded from maximum inflight request handling.")
253-
fs.StringVar(&s.SSHUser, "ssh-user", "", "If non-empty, use secure SSH proxy to the nodes, using this user name")
254-
fs.StringVar(&s.SSHKeyfile, "ssh-keyfile", "", "If non-empty, use secure SSH proxy to the nodes, using this user keyfile")
255-
fs.Int64Var(&s.MaxConnectionBytesPerSec, "max-connection-bytes-per-sec", 0, "If non-zero, throttle each user connection to this number of bytes/sec. Currently only applies to long-running requests")
256+
fs.StringVar(&s.SSHUser, "ssh-user", s.SSHUser, "If non-empty, use secure SSH proxy to the nodes, using this user name")
257+
fs.StringVar(&s.SSHKeyfile, "ssh-keyfile", s.SSHKeyfile, "If non-empty, use secure SSH proxy to the nodes, using this user keyfile")
258+
fs.Int64Var(&s.MaxConnectionBytesPerSec, "max-connection-bytes-per-sec", s.MaxConnectionBytesPerSec, "If non-zero, throttle each user connection to this number of bytes/sec. Currently only applies to long-running requests")
256259
// Kubelet related flags:
257260
fs.BoolVar(&s.KubeletConfig.EnableHttps, "kubelet-https", s.KubeletConfig.EnableHttps, "Use https for kubelet connections")
258261
fs.UintVar(&s.KubeletConfig.Port, "kubelet-port", s.KubeletConfig.Port, "Kubelet port")
@@ -262,8 +265,8 @@ func (s *APIServer) AddFlags(fs *pflag.FlagSet) {
262265
fs.StringVar(&s.KubeletConfig.KeyFile, "kubelet-client-key", s.KubeletConfig.KeyFile, "Path to a client key file for TLS.")
263266
fs.StringVar(&s.KubeletConfig.CAFile, "kubelet-certificate-authority", s.KubeletConfig.CAFile, "Path to a cert. file for the certificate authority.")
264267
// See #14282 for details on how to test/try this option out. TODO remove this comment once this option is tested in CI.
265-
fs.IntVar(&s.KubernetesServiceNodePort, "kubernetes-service-node-port", 0, "If non-zero, the Kubernetes master service (which apiserver creates/maintains) will be of type NodePort, using this as the value of the port. If zero, the Kubernetes master service will be of type ClusterIP.")
268+
fs.IntVar(&s.KubernetesServiceNodePort, "kubernetes-service-node-port", s.KubernetesServiceNodePort, "If non-zero, the Kubernetes master service (which apiserver creates/maintains) will be of type NodePort, using this as the value of the port. If zero, the Kubernetes master service will be of type ClusterIP.")
266269
// TODO: delete this flag as soon as we identify and fix all clients that send malformed updates, like #14126.
267-
fs.BoolVar(&validation.RepairMalformedUpdates, "repair-malformed-updates", true, "If true, server will do its best to fix the update request to pass the validation, e.g., setting empty UID in update request to its existing value. This flag can be turned off after we fix all the clients that send malformed updates.")
270+
fs.BoolVar(&validation.RepairMalformedUpdates, "repair-malformed-updates", validation.RepairMalformedUpdates, "If true, server will do its best to fix the update request to pass the validation, e.g., setting empty UID in update request to its existing value. This flag can be turned off after we fix all the clients that send malformed updates.")
268271
fs.StringSliceVar(&s.WatchCacheSizes, "watch-cache-sizes", s.WatchCacheSizes, "List of watch cache sizes for every resource (pods, nodes, etc.), comma separated. The individual override format: resource#size, where size is a number. It takes effect when watch-cache is enabled.")
269272
}

‎cmd/libs/go2idl/conversion-gen/generators/conversion.go

+26-22
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ type genConversion struct {
287287
preexisting conversions
288288
imports namer.ImportTracker
289289
typesForInit []conversionType
290+
291+
globalVariables map[string]interface{}
290292
}
291293

292294
func NewGenConversion(sanitizedName, targetPackage string, preexisting conversions) generator.Generator {
@@ -365,12 +367,6 @@ func (g *genConversion) isOtherPackage(pkg string) bool {
365367

366368
func (g *genConversion) Imports(c *generator.Context) (imports []string) {
367369
importLines := []string{"reflect \"reflect\""}
368-
if g.isOtherPackage(apiPackagePath) {
369-
importLines = append(importLines, "api \""+apiPackagePath+"\"")
370-
}
371-
if g.isOtherPackage(conversionPackagePath) {
372-
importLines = append(importLines, "conversion \""+conversionPackagePath+"\"")
373-
}
374370
for _, singleImport := range g.imports.ImportLines() {
375371
if g.isOtherPackage(singleImport) {
376372
importLines = append(importLines, singleImport)
@@ -379,7 +375,16 @@ func (g *genConversion) Imports(c *generator.Context) (imports []string) {
379375
return importLines
380376
}
381377

382-
func argsFromType(inType, outType *types.Type) interface{} {
378+
func (g *genConversion) withGlobals(args map[string]interface{}) map[string]interface{} {
379+
for k, v := range g.globalVariables {
380+
if _, ok := args[k]; !ok {
381+
args[k] = v
382+
}
383+
}
384+
return args
385+
}
386+
387+
func argsFromType(inType, outType *types.Type) map[string]interface{} {
383388
return map[string]interface{}{
384389
"inType": inType,
385390
"outType": outType,
@@ -399,13 +404,20 @@ func (g *genConversion) preexists(inType, outType *types.Type) (*types.Type, boo
399404
}
400405

401406
func (g *genConversion) Init(c *generator.Context, w io.Writer) error {
407+
scheme := c.Universe.Variable(types.Name{Package: apiPackagePath, Name: "Scheme"})
408+
g.imports.AddType(scheme)
409+
scope := c.Universe.Type(types.Name{Package: conversionPackagePath, Name: "Scope"})
410+
g.imports.AddType(scope)
411+
g.globalVariables = map[string]interface{}{
412+
"scheme": scheme,
413+
"Scope": scope,
414+
}
415+
402416
sw := generator.NewSnippetWriter(w, c, "$", "$")
403417
sw.Do("func init() {\n", nil)
404-
if g.targetPackage == apiPackagePath {
405-
sw.Do("if err := Scheme.AddGeneratedConversionFuncs(\n", nil)
406-
} else {
407-
sw.Do("if err := api.Scheme.AddGeneratedConversionFuncs(\n", nil)
408-
}
418+
sw.Do("if err := $.scheme|raw$.AddGeneratedConversionFuncs(\n", map[string]interface{}{
419+
"scheme": scheme,
420+
})
409421
for _, conv := range g.typesForInit {
410422
funcName := g.funcNameTmpl(conv.inType, conv.outType)
411423
sw.Do(fmt.Sprintf("%s,\n", funcName), argsFromType(conv.inType, conv.outType))
@@ -432,11 +444,7 @@ func (g *genConversion) GenerateType(c *generator.Context, t *types.Type, w io.W
432444

433445
func (g *genConversion) generateConversion(inType, outType *types.Type, sw *generator.SnippetWriter) {
434446
funcName := g.funcNameTmpl(inType, outType)
435-
if g.targetPackage == conversionPackagePath {
436-
sw.Do(fmt.Sprintf("func auto%s(in *$.inType|raw$, out *$.outType|raw$, s Scope) error {\n", funcName), argsFromType(inType, outType))
437-
} else {
438-
sw.Do(fmt.Sprintf("func auto%s(in *$.inType|raw$, out *$.outType|raw$, s conversion.Scope) error {\n", funcName), argsFromType(inType, outType))
439-
}
447+
sw.Do(fmt.Sprintf("func auto%s(in *$.inType|raw$, out *$.outType|raw$, s $.Scope|raw$) error {\n", funcName), g.withGlobals(argsFromType(inType, outType)))
440448
sw.Do("if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {\n", nil)
441449
sw.Do("defaulting.(func(*$.|raw$))(in)\n", inType)
442450
sw.Do("}\n", nil)
@@ -446,11 +454,7 @@ func (g *genConversion) generateConversion(inType, outType *types.Type, sw *gene
446454

447455
// If there is no public preexisting Convert method, generate it.
448456
if _, ok := g.preexists(inType, outType); !ok {
449-
if g.targetPackage == conversionPackagePath {
450-
sw.Do(fmt.Sprintf("func %s(in *$.inType|raw$, out *$.outType|raw$, s Scope) error {\n", funcName), argsFromType(inType, outType))
451-
} else {
452-
sw.Do(fmt.Sprintf("func %s(in *$.inType|raw$, out *$.outType|raw$, s conversion.Scope) error {\n", funcName), argsFromType(inType, outType))
453-
}
457+
sw.Do(fmt.Sprintf("func %s(in *$.inType|raw$, out *$.outType|raw$, s $.Scope|raw$) error {\n", funcName), g.withGlobals(argsFromType(inType, outType)))
454458
sw.Do(fmt.Sprintf("return auto%s(in, out, s)\n", funcName), argsFromType(inType, outType))
455459
sw.Do("}\n\n", nil)
456460
}

0 commit comments

Comments
 (0)
Please sign in to comment.