Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Enable validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tfiduccia authored and Daishan Peng committed Jul 3, 2019
1 parent a9a39e4 commit 653c29e
Show file tree
Hide file tree
Showing 76 changed files with 221 additions and 3,648 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
./data-dir
./dist
./.trash-cache
./test/.pytest_cache
13 changes: 12 additions & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ FROM golang:1.12.6-alpine3.9

ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV K3S_VERSION v0.5.0
ENV KUBECTL_VERSION v1.15.0

RUN apk -U add bash git gcc musl-dev docker vim less file curl wget ca-certificates
RUN apk -U add bash git gcc musl-dev docker vim less file curl wget ca-certificates python3 py3-pip python3-dev openssl-dev libffi-dev jq
RUN pip3 install 'tox==3.6.0'
RUN go get -d golang.org/x/lint/golint && \
git -C /go/src/golang.org/x/lint/golint checkout -b current 06c8688daad7faa9da5a0c2f163a3d14aac986ca && \
go install golang.org/x/lint/golint && \
Expand All @@ -16,13 +19,21 @@ RUN rm -rf /go/src /go/pkg
RUN if [ "${ARCH}" == "amd64" ]; then \
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0; \
fi
RUN curl -sL https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s > /usr/bin/k3s && \
chmod +x /usr/bin/k3s
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl > /usr/bin/kubectl && \
chmod +x /usr/bin/kubectl

ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS
ENV DAPPER_SOURCE /go/src/github.com/rancher/rio/
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_RUN_ARGS --privileged
ENV HOME ${DAPPER_SOURCE}
WORKDIR ${DAPPER_SOURCE}
VOLUME /var/lib/rancher/k3s
VOLUME /var/lib/cni
VOLUME /var/log

ENTRYPOINT ["./scripts/entry"]
CMD ["ci"]
28 changes: 17 additions & 11 deletions cli/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type Install struct {
ServiceCidr string `desc:"Manually specify service CIDR for service mesh to intercept"`
DisableFeatures []string `desc:"Manually specify features to disable, supports CSV"`
Yaml bool `desc:"Only print out k8s yaml manifest"`
Check bool `desc:"Only check status, don't deploy controller'"`
Lite bool `desc:"Only install lite version of Rio(monitoring will be disabled, will be ignored if --disable-features is set)"`
}

Expand Down Expand Up @@ -177,21 +178,26 @@ func (i *Install) Run(ctx *clicontext.CLIContext) error {
return nil
}

if err := controllerStack.Deploy(answers); err != nil {
return err
if !i.Check {
fmt.Println("Deploying Rio control plane....")
if err := controllerStack.Deploy(answers); err != nil {
return err
}
}
fmt.Println("Deploying Rio control plane....")

start := time.Now()
for {
time.Sleep(time.Second * 2)
dep, err := ctx.K8s.AppsV1().Deployments(namespace).Get("rio-controller", metav1.GetOptions{})
if err != nil {
return err
}
if !serviceset.IsReady(&dep.Status) {
fmt.Printf("\r%v Waiting for deployment %s/%s to become ready", string(statusChar[statusIndex]), dep.Namespace, dep.Name)
statusIndex = modIndex(statusIndex)
continue
if !i.Check {
dep, err := ctx.K8s.AppsV1().Deployments(namespace).Get("rio-controller", metav1.GetOptions{})
if err != nil {
return err
}
if !serviceset.IsReady(&dep.Status) {
fmt.Printf("\r%v Waiting for deployment %s/%s to become ready", string(statusChar[statusIndex]), dep.Namespace, dep.Name)
statusIndex = modIndex(statusIndex)
continue
}
}
info, err := ctx.Project.RioInfos().Get("rio", metav1.GetOptions{})
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ github.com/rancher/cert-manager v0.7.0-rio.1 h1:o7XDzUpKg2X1fSFpy/B4uU0IIQEUzT7E
github.com/rancher/cert-manager v0.7.0-rio.1/go.mod h1:3cwEbVBo4BRNJ29j2MFyvX4Uno2lAQquejDtUXtE0YY=
github.com/rancher/gitwatcher v0.0.0-20190612060519-6eee8fc7a202 h1:ID3ndmm5OMdJdjd7EFfXJoPm9QA/0BlSmLtf8sJZLRQ=
github.com/rancher/gitwatcher v0.0.0-20190612060519-6eee8fc7a202/go.mod h1:8Ky3j8+TgcevUb7u6x7jSUDQf5amzYKYSv1mzn0zivQ=
github.com/rancher/k3s v1.14.3-k3s.2/go.mod h1:tMIUbj+a40AQcAd6RRazV5hcf7YWjhas4rNxidgJXms=
github.com/rancher/mapper v0.0.0-20190426050457-84da984f3146 h1:rdM/qnaTd2pnQLlF1TYdyGSd7/ssVuu/a0YituJxxjI=
github.com/rancher/mapper v0.0.0-20190426050457-84da984f3146/go.mod h1:zU4cm21k7ZBFVQhUu2aSH7NwouY317rLYxruOn+wdOQ=
github.com/rancher/moq v0.0.0-20190404221404-ee5226d43009 h1:Xsxh7fX3+2wAUJtPy8g2lZh0cYuyifqhBL0vxCIYojs=
Expand Down
54 changes: 30 additions & 24 deletions modules/istio/controllers/istio/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,36 @@ var (
evalTrigger trigger.Trigger
)

func RegisterNodeEndpointIndexer(ctx context.Context, rContext *types.Context) error {
i := indexer{
namespace: rContext.Namespace,
}
rContext.Core.Core().V1().Endpoints().Cache().AddIndexer(indexName, i.indexEPByNode)
return nil
}

type indexer struct {
namespace string
}

func (i indexer) indexEPByNode(ep *corev1.Endpoints) ([]string, error) {
if ep.Namespace != i.namespace || ep.Name != constants.IstioGateway {
return nil, nil
}

var result []string

for _, subset := range ep.Subsets {
for _, addr := range subset.Addresses {
if addr.NodeName != nil {
result = append(result, *addr.NodeName)
}
}
}

return result, nil
}

func Register(ctx context.Context, rContext *types.Context) error {
if err := ensureClusterDomain(rContext.Namespace, rContext.Global.Admin().V1().ClusterDomain()); err != nil {
return err
Expand Down Expand Up @@ -79,12 +109,6 @@ func Register(ctx context.Context, rContext *types.Context) error {
rContext.Global.Admin().V1().ClusterDomain(),
rContext.Global.Admin().V1().PublicDomain())

relatedresource.Watch(ctx, "node-enpoint", s.resolveEndpoint,
rContext.Core.Core().V1().Endpoints(),
rContext.Core.Core().V1().Node())

rContext.Core.Core().V1().Endpoints().Cache().AddIndexer(indexName, s.indexEPByNode)

switch {
case constants.UseIPAddress != "":
addresses := strings.Split(constants.UseIPAddress, ",")
Expand Down Expand Up @@ -313,24 +337,6 @@ func (i istioDeployController) updateClusterDomain(addresses []string) error {
return err
}

func (i *istioDeployController) indexEPByNode(ep *corev1.Endpoints) ([]string, error) {
if ep.Namespace != i.namespace || ep.Name != constants.IstioGateway {
return nil, nil
}

var result []string

for _, subset := range ep.Subsets {
for _, addr := range subset.Addresses {
if addr.NodeName != nil {
result = append(result, *addr.NodeName)
}
}
}

return result, nil
}

func (i *istioDeployController) syncSubdomain(key string, service *corev1.Service) (*corev1.Service, error) {
if service == nil {
return service, nil
Expand Down
3 changes: 3 additions & 0 deletions pkg/server/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package server
import (
"context"

"github.com/rancher/rio/modules/istio/controllers/istio"

"github.com/rancher/rio/modules"
"github.com/rancher/rio/pkg/constructors"
"github.com/rancher/rio/pkg/controllers"
Expand Down Expand Up @@ -96,6 +98,7 @@ func Startup(ctx context.Context, systemNamespace, kubeConfig string) error {
}

leader.RunOrDie(ctx, systemNamespace, "rio", rioContext.K8s, func(ctx context.Context) {
runtime.Must(istio.RegisterNodeEndpointIndexer(ctx, rioContext))
runtime.Must(controllers.Register(ctx, rioContext))
runtime.Must(modules.Register(ctx, rioContext))
runtime.Must(rioContext.Start(ctx))
Expand Down
26 changes: 24 additions & 2 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,27 @@ set -e

cd $(dirname $0)/..

echo Running tests
go test -cover -tags=test ./...
if [[ ${ARCH} == amd64 ]]; then
echo Running tests

k3s server &
sleep 10

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
export PATH=$(pwd)/bin:$PATH

rio-controller &
rio install --check

cd ./tests
PROC=$(nproc)
if [ "$PROC" > 8 ]; then
PROC=8
fi
# todo: set $PROC=1, figure out how to run test in parallel
PROC=1
tox -- -n $PROC
cd ..
fi


2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def nspc():

@pytest.fixture
def service(nspc):
srv = "tsrv" + str(random.randint(1000, 5000))
srv = "tsrv" + str(random.randint(1000000, 9999999))
fullName = (f"{nspc}/{srv}")

os.system(f"rio run -n {fullName} nginx")
Expand Down
14 changes: 0 additions & 14 deletions tests/init-nfs.bash

This file was deleted.

30 changes: 0 additions & 30 deletions tests/new-validation/test_run.py

This file was deleted.

66 changes: 0 additions & 66 deletions tests/new-validation/test_service_mesh.py

This file was deleted.

37 changes: 0 additions & 37 deletions tests/nfs-stack/nfs-client-stack.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions tests/nfs-stack/nfs-server-stack.yaml

This file was deleted.

Loading

0 comments on commit 653c29e

Please sign in to comment.