Skip to content

Commit

Permalink
docs: add the development guide and fix the lint
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Feb 3, 2020
1 parent 0be2551 commit 1159873
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 27 deletions.
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ ROLES=node controller cni db webhook pinger
DEV_TAG=dev
RELEASE_TAG=$(shell cat VERSION)

.PHONY: build-dev-images build-go build-bin test lint up down halt suspend resume kind
.PHONY: build-dev-images build-go build-bin test lint up down halt suspend resume kind push-dev push-release

build-dev-images: build-bin
@for role in ${ROLES} ; do \
docker build -t ${REGISTRY}/kube-ovn-$$role:${DEV_TAG} -f dist/images/Dockerfile.$$role dist/images/; \
done

push-dev:
@for role in ${ROLES} ; do \
docker push ${REGISTRY}/kube-ovn-$$role:${DEV_TAG}; \
done

Expand All @@ -21,9 +25,13 @@ build-go:
CGO_ENABLED=0 GOOS=linux go build -o $(PWD)/dist/images/kube-ovn-webhook -ldflags "-w -s" -v ./cmd/webhook
CGO_ENABLED=0 GOOS=linux go build -o $(PWD)/dist/images/kube-ovn-pinger -ldflags "-w -s" -v ./cmd/pinger

release: build-go
release: lint build-go
@for role in ${ROLES} ; do \
docker build -t ${REGISTRY}/kube-ovn-$$role:${RELEASE_TAG} -f dist/images/Dockerfile.$$role dist/images/; \
done

push-release:
@for role in ${ROLES} ; do \
docker push ${REGISTRY}/kube-ovn-$$role:${RELEASE_TAG}; \
done

Expand All @@ -35,14 +43,13 @@ lint:
test:
GOOS=linux go test -cover -v ./...

build-bin: lint
build-bin:
docker run --rm -e GOOS=linux -e GOCACHE=/tmp \
-u $(shell id -u):$(shell id -g) \
-v $(CURDIR):/go/src/github.com/alauda/kube-ovn:ro \
-v $(CURDIR)/dist:/go/src/github.com/alauda/kube-ovn/dist/ \
golang:$(GO_VERSION) /bin/bash -c '\
cd /go/src/github.com/alauda/kube-ovn && \
make test && \
make build-go '

up:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ If you want to install Kubernetes from scratch, you can try [kubespray](https://
- [Tracing/Diagnose/Dump Traffic with Kubectl Plugin](docs/kubectl-plugin.md)
- [Prometheus Integration](docs/prometheus.md)


## Contribution
We are looking forwards to your PR!

- [Development Guide](docs/development.md)

## Companies using Kube-OVN

Not in the list? Open a pull request and add yourself!
Expand Down
4 changes: 2 additions & 2 deletions cmd/cni/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func generateCNIResult(cniVersion string, cniResponse *request.CniResponse) curr

route := types.Route{
Dst: net.IPNet{IP: net.ParseIP("0.0.0.0").To4(), Mask: net.CIDRMask(0, 32)},
GW: net.ParseIP(cniResponse.Gateway).To4(),
GW: net.ParseIP(cniResponse.Gateway).To4(),
}
result.Routes = []*types.Route{&route}
case kubeovnv1.ProtocolIPv6:
Expand All @@ -84,7 +84,7 @@ func generateCNIResult(cniVersion string, cniResponse *request.CniResponse) curr

route := types.Route{
Dst: net.IPNet{IP: net.ParseIP("::").To16(), Mask: net.CIDRMask(0, 128)},
GW: net.ParseIP(cniResponse.Gateway).To16(),
GW: net.ParseIP(cniResponse.Gateway).To16(),
}
result.Routes = []*types.Route{&route}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func loopOvnNbctlDaemon(config *controller.Configuration) {

// ovn-nbctl daemon may hang and cannot precess further request.
// In case of that, we need to start a new daemon.
if err := ovs.CheckAlive(); err != nil {
if err := ovs.CheckAlive(); err != nil {
klog.Warningf("ovn-nbctl daemon doesn't return, start a new daemon")
ovs.StartOvnNbctlDaemon(config.OvnNbHost, config.OvnNbPort)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/webhook/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func loopOvnNbctlDaemon(ovnNbHost string, ovnNbPort int) {
ovs.StartOvnNbctlDaemon(ovnNbHost, ovnNbPort)
}

if err := ovs.CheckAlive(); err != nil {
if err := ovs.CheckAlive(); err != nil {
klog.Warningf("ovn-nbctl daemon doesn't return, start a new daemon")
ovs.StartOvnNbctlDaemon(ovnNbHost, ovnNbPort)
}
Expand Down
23 changes: 23 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Development Guide

## How to build Kube-OVN

Kube-OVN is developed by [Go](https://golang.org/) and uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependency.

```
git clone https://github.com/alauda/kube-ovn.git
cd kube-ovn
make release
```

## How to run e2e tests

Kube-OVN uses [KIND](https://kind.sigs.k8s.io/) to setup a local Kubernetes cluster
and [Ginkgo](https://onsi.github.io/ginkgo/) as the test framework to run the e2e tests.

```
make kind-init
# wait all pod ready
make e2e
```
2 changes: 1 addition & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func (c *Controller) gcLogicalSwitchPort() error {
klog.Errorf("failed to list node, %v", err)
return err
}
ipNames := make([]string, 0, len(pods) + len(nodes))
ipNames := make([]string, 0, len(pods)+len(nodes))
for _, pod := range pods {
ipNames = append(ipNames, fmt.Sprintf("%s.%s", pod.Name, pod.Namespace))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func formatSubnet(subnet *kubeovnv1.Subnet, c *Controller) error {
changed := false
_, ipNet, err := net.ParseCIDR(subnet.Spec.CIDRBlock)
if err != nil {
return fmt.Errorf("subnet %s cidr %s is not a valid cidrblock", subnet.Name, subnet.Spec.CIDRBlock )
return fmt.Errorf("subnet %s cidr %s is not a valid cidrblock", subnet.Name, subnet.Spec.CIDRBlock)
}
if ipNet.String() != subnet.Spec.CIDRBlock {
subnet.Spec.CIDRBlock = ipNet.String()
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ func StartOvnNbctlDaemon(nbHost string, nbPort int) (string, error) {
"pkill",
"-f",
"ovn-nbctl",
).CombinedOutput()
).CombinedOutput()
if err != nil {
klog.Errorf("failed to kill old ovn-nbctl daemon: %q", output)
return "", err
Expand Down
2 changes: 1 addition & 1 deletion pkg/pinger/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func pingExternal(config *Configuration) {
func nslookup(config *Configuration) {
klog.Infof("start to check dns connectivity")
t1 := time.Now()
ctx, cancel := context.WithTimeout(context.TODO(), 10 * time.Second)
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
defer cancel()
var r net.Resolver
addrs, err := r.LookupHost(ctx, config.DNS)
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
_ "github.com/alauda/kube-ovn/test/e2e/subnet"
)



func TestE2e(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Kube-OVN E2E Suite")
Expand Down
7 changes: 3 additions & 4 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
)

type Framework struct {
BaseName string
BaseName string
KubeOvnNamespace string
KubeClientSet kubernetes.Interface
OvnClientSet clientset.Interface
KubeClientSet kubernetes.Interface
OvnClientSet clientset.Interface
}

func NewFramework(baseName, kubeConfig string) *Framework {
Expand Down Expand Up @@ -77,7 +77,6 @@ func (f *Framework) WaitPodReady(pod, namespace string) error {
return nil
}


switch getPodStatus(p) {
case Completed:
return fmt.Errorf("pod already completed")
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/ip/static_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ var _ = Describe("[IP Allocation]", func() {
autoMount := false
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Name: name,
Namespace: namespace,
Annotations: map[string]string{
util.IpAddressAnnotation: "12.10.0.10",
util.IpAddressAnnotation: "12.10.0.10",
util.MacAddressAnnotation: "00:00:00:53:6B:B6",
},
},
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/subnet/normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var _ = Describe("[Subnet]", func() {
By("create subnet")
s := kubeovn.Subnet{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: name,
Labels: map[string]string{"e2e": "true"},
},
Spec: kubeovn.SubnetSpec{
Expand Down Expand Up @@ -68,11 +68,11 @@ var _ = Describe("[Subnet]", func() {
By("create subnet")
s := kubeovn.Subnet{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: name,
Labels: map[string]string{"e2e": "true"},
},
Spec: kubeovn.SubnetSpec{
CIDRBlock: "11.11.0.0/16",
CIDRBlock: "11.11.0.0/16",
GatewayType: kubeovn.GWCentralizedType,
GatewayNode: "kube-ovn-control-plane,kube-ovn-worker,kube-ovn-worker2",
},
Expand All @@ -97,7 +97,7 @@ var _ = Describe("[Subnet]", func() {
By("create subnet")
s := &kubeovn.Subnet{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: name,
Labels: map[string]string{"e2e": "true"},
},
Spec: kubeovn.SubnetSpec{
Expand Down Expand Up @@ -132,7 +132,7 @@ var _ = Describe("[Subnet]", func() {
By("create subnet")
s := kubeovn.Subnet{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: name,
Labels: map[string]string{"e2e": "true"},
},
Spec: kubeovn.SubnetSpec{
Expand All @@ -155,7 +155,7 @@ var _ = Describe("[Subnet]", func() {
By("create subnet")
s := &kubeovn.Subnet{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: name,
Labels: map[string]string{"e2e": "true"},
},
Spec: kubeovn.SubnetSpec{
Expand Down

0 comments on commit 1159873

Please sign in to comment.