cmd/coordinator: start of a Kubernetes buildlet pool

Updates golang/go#12546

Change-Id: Ia70baeb1df441509f70c77e7b94e7eb9fddccbf3
Reviewed-on: https://go-review.googlesource.com/14392
Reviewed-by: Evan Brown <evanbrown@google.com>
This commit is contained in:
Brad Fitzpatrick 2015-09-08 15:18:47 -07:00
Родитель 1f41f3c1a6
Коммит 6925ce80a1
4 изменённых файлов: 52 добавлений и 1 удалений

Просмотреть файл

@ -1070,6 +1070,9 @@ func poolForConf(conf dashboard.BuildConfig) BuildletPool {
if conf.VMImage != "" {
return gcePool
}
if conf.KubeImage != "" {
return kubePool // Kubernetes
}
return reversePool
}

43
cmd/coordinator/kube.go Normal file
Просмотреть файл

@ -0,0 +1,43 @@
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"errors"
"fmt"
"io"
"sync"
"golang.org/x/build/buildlet"
)
/*
This file implements the Kubernetes-based buildlet pool.
*/
var kubePool = &kubeBuildletPool{}
// kubeBuildletPool is the Kubernetes buildlet pool.
type kubeBuildletPool struct {
// ...
mu sync.Mutex
}
func (p *kubeBuildletPool) GetBuildlet(cancel Cancel, machineType, rev string, el eventTimeLogger) (*buildlet.Client, error) {
return nil, errors.New("TODO")
}
func (p *kubeBuildletPool) WriteHTMLStatus(w io.Writer) {
io.WriteString(w, "<b>Kubernetes pool summary</b><ul><li>(TODO)</li></ul>")
}
func (p *kubeBuildletPool) String() string {
p.mu.Lock()
inUse := 0
total := 0
// ...
p.mu.Unlock()
return fmt.Sprintf("Kubernetes pool capacity: %d/%d", inUse, total)
}

Просмотреть файл

@ -312,6 +312,7 @@ func (p *reverseBuildletPool) WriteHTMLStatus(w io.Writer) {
func (p *reverseBuildletPool) String() string {
p.mu.Lock()
inUse := 0
total := len(p.buildlets)
for _, b := range p.buildlets {
if b.inUseAs != "" && b.inUseAs != "health" {
inUse++
@ -319,7 +320,7 @@ func (p *reverseBuildletPool) String() string {
}
p.mu.Unlock()
return fmt.Sprintf("Reverse pool capacity: %d/%d %s", inUse, len(p.buildlets), p.Modes())
return fmt.Sprintf("Reverse pool capacity: %d/%d %s", inUse, total, p.Modes())
}
// Modes returns the a deduplicated list of buildlet modes curently supported

Просмотреть файл

@ -25,6 +25,7 @@ type BuildConfig struct {
Notes string // notes for humans
Owner string // e.g. "bradfitz@golang.org", empty means golang-dev
VMImage string // e.g. "openbsd-amd64-56"
KubeImage string // e.g. "linux-buildlet-std:latest" (suffix after "gcr.io/<PROJ>/")
machineType string // optional GCE instance type
Go14URL string // URL to built Go 1.4 tar.gz
buildletURL string // optional override buildlet URL
@ -613,5 +614,8 @@ func addBuilder(c BuildConfig) {
if c.VMImage == "" && !c.IsReverse {
panic("empty VMImage")
}
if c.VMImage != "" && c.KubeImage != "" {
panic("there can be only one of VMImage/KubeImage")
}
Builders[c.Name] = c
}