Skip to content

Commit

Permalink
Merge pull request #20 from laincloud/deployd
Browse files Browse the repository at this point in the history
remove deployd dependency
  • Loading branch information
bibaijin authored Apr 12, 2018
2 parents ea06235 + da3216d commit 444a2c2
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 41 deletions.
43 changes: 16 additions & 27 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@

[[constraint]]
name = "github.com/coreos/etcd"
version = "3.1.8"
version = "3.3.3"

[[constraint]]
name = "github.com/coreos/go-semver"
version = "0.2.0"

[[constraint]]
branch = "master"
Expand All @@ -37,9 +41,21 @@
name = "github.com/golang/protobuf"
version = "1.0.0"

[[constraint]]
branch = "master"
name = "github.com/mijia/adoc"

[[constraint]]
branch = "master"
name = "github.com/mijia/sweb"

[[constraint]]
branch = "master"
name = "golang.org/x/net"

[[constraint]]
name = "google.golang.org/grpc"
version = "1.10.0"
version = "1.11.3"

[prune]
go-tests = true
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.2
2.4.1
4 changes: 2 additions & 2 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"path"
"strings"

"github.com/laincloud/deployd/engine"
"github.com/laincloud/lainlet/store"
"github.com/laincloud/lainlet/watcher"
"github.com/laincloud/lainlet/spec"
"github.com/laincloud/lainlet/watcher/depends"
"github.com/mijia/sweb/log"
"golang.org/x/net/context"
Expand Down Expand Up @@ -185,7 +185,7 @@ func podgroupInvertKey(key string) string {
func podgroupConvert(pairs []*store.KVPair) (map[string]interface{}, error) {
ret := make(map[string]interface{})
for _, kv := range pairs {
var pg engine.PodGroupWithSpec
var pg spec.PodGroupWithSpec
if err := json.Unmarshal(kv.Value, &pg); err != nil {
log.Errorf("Fail to unmarshal the dependency data: %s", string(kv.Value))
log.Errorf("JSON unmarshal error: %s", err.Error())
Expand Down
143 changes: 143 additions & 0 deletions spec/spec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package spec

import (
"time"

"github.com/mijia/adoc"
)

type PodGroupWithSpec struct {
Spec PodGroupSpec
PrevState []PodPrevState
PodGroup
}

type PodGroupSpec struct {
ImSpec
Pod PodSpec
NumInstances int
RestartPolicy RestartPolicy
}

type ImSpec struct {
Name string
Namespace string
Version int
CreatedAt time.Time
UpdatedAt time.Time
}

type PodSpec struct {
ImSpec
Network string
Containers []ContainerSpec
Filters []string // for cluster scheduling
Labels map[string]string
Dependencies []Dependency
Annotation string
Stateful bool
SetupTime int
KillTimeout int
PrevState PodPrevState
HealthConfig HealthConfig
}

type ContainerSpec struct {
ImSpec
Image string
Env []string
User string
WorkingDir string
DnsSearch []string
Volumes []string // a stateful flag
SystemVolumes []string // not a stateful flag, every node has system volumes
CloudVolumes []CloudVolumeSpec
Command []string
Entrypoint []string
CpuLimit int
MemoryLimit int64
Expose int
LogConfig adoc.LogConfig
}

type CloudVolumeSpec struct {
Type string
Dirs []string
}

type Dependency struct {
PodName string
Policy DependencyPolicy
}

type DependencyPolicy int

type HealthConfig struct {
Cmd string `json:"cmd"`
Options HealthCnfOptions `json:"options"`
}

type HealthCnfOptions struct {
Interval int `json:"interval"`
Timeout int `json:"timeout"`
Retries int `json:"retries"`
}

type RestartPolicy int

type PodPrevState struct {
NodeName string
IPs []string
}

type PodGroup struct {
Pods []Pod
BaseRuntime
}

type Pod struct {
InstanceNo int
Containers []Container
ImRuntime
}

type Container struct {
// FIXME(mijia): multiple ports supporing, will have multiple entries of <NodePort, ContainerPort, Protocol>
Id string
Runtime adoc.ContainerDetail
NodeName string
NodeIp string
ContainerIp string
NodePort int
ContainerPort int
Protocol string
}

type ImRuntime struct {
BaseRuntime
TargetState ExpectState
DriftCount int
RestartCount int
RestartAt time.Time
}

type BaseRuntime struct {
Healthst HealthState
State RunState
OOMkilled bool
LastError string
UpdatedAt time.Time
}

type HealthState int

type RunState int

type ExpectState int

type SharedPodWithSpec struct {
RefCount int
VerifyTime time.Time
Spec PodSpec
Pod Pod
}
6 changes: 3 additions & 3 deletions watcher/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

"github.com/laincloud/deployd/engine"
"github.com/laincloud/lainlet/spec"
"github.com/laincloud/lainlet/store"
"github.com/laincloud/lainlet/watcher"
"github.com/mijia/sweb/log"
Expand All @@ -18,7 +18,7 @@ const (
)

// PodGroup is actually from the deployd engine, it actually engine.PodGroupWithSpec
type PodGroup engine.PodGroupWithSpec
type PodGroup spec.PodGroupWithSpec

// Info represents the container info, the data type returned by this container watcher
type Info struct {
Expand All @@ -40,7 +40,7 @@ type ContainerWatcher struct {
// New create a new watcher which used to watch container info
func New(s store.Store, ctx context.Context) (watcher.Watcher, error) {
ret := &ContainerWatcher{
invertsTable:make(map[string]string),
invertsTable: make(map[string]string),
}
base, err := watcher.New(s, ctx, KEY, ret.convert, ret.invertKey)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions watcher/depends/depends.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"path"

"github.com/laincloud/deployd/engine"
"github.com/laincloud/lainlet/spec"
"github.com/laincloud/lainlet/store"
"github.com/laincloud/lainlet/watcher"
"github.com/mijia/sweb/log"
Expand All @@ -18,7 +18,7 @@ const (
)

// Depends represents the data type returned by this watcher. in fact, it's a type to represents map[nodename]map[appname]SharedPodWithSpec
type Depends map[string]map[string]engine.SharedPodWithSpec
type Depends map[string]map[string]spec.SharedPodWithSpec

// New create a new watcher which used to watch depends data
func New(s store.Store, ctx context.Context) (watcher.Watcher, error) {
Expand Down
9 changes: 5 additions & 4 deletions watcher/podgroup/podgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package podgroup
import (
"encoding/json"
"fmt"
"github.com/mijia/sweb/log"
"golang.org/x/net/context"
"github.com/laincloud/deployd/engine"

"github.com/laincloud/lainlet/spec"
"github.com/laincloud/lainlet/store"
"github.com/laincloud/lainlet/watcher"
"github.com/mijia/sweb/log"
"golang.org/x/net/context"
"path"
)

Expand All @@ -17,7 +18,7 @@ const (
)

// PodGroup represents the data type stored in backend for each pod. watcher will return data whose type is map[string]PodGroup.
type PodGroup engine.PodGroupWithSpec
type PodGroup spec.PodGroupWithSpec

// New create a new watcher which used to watch podgroup data
func New(s store.Store, ctx context.Context) (watcher.Watcher, error) {
Expand Down

0 comments on commit 444a2c2

Please sign in to comment.