From e371b253768b26d9bbd26f094b9efb4d0f2583f0 Mon Sep 17 00:00:00 2001 From: Simon Croome Date: Mon, 17 Aug 2020 18:03:24 +0100 Subject: [PATCH] Remove DBUpgrade, not needed for v2 --- .travis.yml | 4 +- Dockerfile | 4 +- daemonset.yaml | 52 +------ e2e.sh | 130 ++---------------- mocks/mock_runner.go | 15 +- scripts/10-dbupgrade-v1v2/README.md | 16 --- .../storageos_dbupgrade_v1v2 | 3 - 7 files changed, 28 insertions(+), 196 deletions(-) delete mode 100644 scripts/10-dbupgrade-v1v2/README.md delete mode 100755 scripts/10-dbupgrade-v1v2/storageos_dbupgrade_v1v2 diff --git a/.travis.yml b/.travis.yml index 584a73c..3d7c8b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,13 +3,13 @@ sudo: required language: go go: - - "1.12.9" + - "1.15" env: global: - IMAGE_NAME=storageos/init - IMAGE_TAG=test - - K8S_VERSION="v1.14.2" + - K8S_VERSION="v1.18.6" before_install: - | diff --git a/Dockerfile b/Dockerfile index 626b9cf..4f861cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.13.5 AS build +FROM golang:1.15.0 AS build WORKDIR /go/src/github.com/storageos/init/ COPY . /go/src/github.com/storageos/init/ @@ -8,7 +8,7 @@ FROM registry.access.redhat.com/ubi8/ubi LABEL name="StorageOS Init" \ maintainer="support@storageos.com" \ vendor="StorageOS" \ - version="1.0.1" \ + version="v2.0.0" \ release="1" \ distribution-scope="public" \ architecture="x86_64" \ diff --git a/daemonset.yaml b/daemonset.yaml index f1a1156..ad240f2 100644 --- a/daemonset.yaml +++ b/daemonset.yaml @@ -90,57 +90,11 @@ spec: - SYS_ADMIN containers: - name: storageos - image: storageos/node:1.3.0 + image: busybox imagePullPolicy: IfNotPresent args: - - server - ports: - - containerPort: 5705 - name: api - livenessProbe: - initialDelaySeconds: 65 - timeoutSeconds: 10 - failureThreshold: 5 - httpGet: - path: /v1/health - port: api - readinessProbe: - initialDelaySeconds: 65 - timeoutSeconds: 10 - failureThreshold: 5 - httpGet: - path: /v1/health - port: api - env: - - name: HOSTNAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: JOIN - valueFrom: - fieldRef: - fieldPath: status.podIP - - name: ADVERTISE_IP - valueFrom: - fieldRef: - fieldPath: status.podIP - - name: NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: DISABLE_TELEMETRY - value: "true" - volumeMounts: - - name: sys - mountPath: /sys - - name: state - mountPath: /var/lib/storageos - mountPropagation: Bidirectional - securityContext: - privileged: true - capabilities: - add: - - SYS_ADMIN + - sleep + - "600" volumes: - name: kernel-modules hostPath: diff --git a/e2e.sh b/e2e.sh index 3e4e3fe..a743311 100755 --- a/e2e.sh +++ b/e2e.sh @@ -8,12 +8,11 @@ prepare_host() { sudo mount --make-shared /sys sudo mount --make-shared / sudo mount --make-shared /dev - docker run --name enable_lio --privileged --rm --cap-add=SYS_ADMIN -v /lib/modules:/lib/modules -v /sys:/sys:rshared storageos/init:0.2 } run_kind() { echo "Download kind binary..." - wget -O kind 'https://docs.google.com/uc?export=download&id=1-oy-ui0ZE_T3Fglz1c8ZgnW8U-A4yS8u' --no-check-certificate && chmod +x kind && sudo mv kind /usr/local/bin/ + wget -O kind 'https://kind.sigs.k8s.io/dl/v0.8.1/kind-linux-amd64' --no-check-certificate && chmod +x kind && sudo mv kind /usr/local/bin/ echo "Download kubectl..." curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/"${K8S_VERSION}"/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ @@ -24,7 +23,8 @@ run_kind() { kind create cluster --image storageos/kind-node:"$K8S_VERSION" --name kind-1 echo "Export kubeconfig..." - export KUBECONFIG="$(kind get kubeconfig-path --name="kind-1")" + kind get kubeconfig --name="kind-1" > kubeconfig.yaml + export KUBECONFIG="kubeconfig.yaml" echo echo "Get cluster info..." @@ -36,98 +36,6 @@ run_kind() { echo } -# This tests the dataplane upgrade on the host, independent of any k8s cluster. -nok8s_dpupgrade() { - # Run StorageOS and create old dp database. - docker pull storageos/node:1.3.0 - NODE_IMAGE=storageos/node:1.3.0 bash run-stos.sh - sleep 10 - - # Wait until storageos node is healthy. - health=$(docker inspect storageos --type container | jq '.[0] | .State.Health.Status') - until [ $health == '"healthy"' ] - do - health=$(docker inspect storageos --type container | jq '.[0] | .State.Health.Status') - echo "storageos status $health" - echo "waiting for storageos node to be healthy..." - sleep 3 - done - - echo - echo "storageos node is healthy" - - # Stop storageos. - docker rm storageos -f - - # Run dp upgrade on old database. - echo - echo "Attempting dp upgrade" - UPGRADELOGS=/tmp/dpupgrade.log - make run > $UPGRADELOGS - if ! grep "successfully upgraded database" $UPGRADELOGS; then - echo "dpupgrade failed!" - echo - echo "init logs:" - cat $UPGRADELOGS - exit 1 - fi - echo "upgrade successful" -} - -# This tests the dataplane upgrade in a k8s cluster by updating node 1.3.0 -# storageos node to 1.4.0. -k8s_dpupgrade() { - # Get KinD container id. - x=$(docker ps -f name=kind-1-control-plane -q) - - # Re-tag node 1.3.0 as storageos/node:1.4.0 and copy into KinD. - # This is temporary until storageos/node:1.4.0 is released. - docker tag storageos/node:1.3.0 storageos/node:1.4.0 - docker save storageos/node:1.4.0 > stos140.tar - docker cp stos140.tar $x:/stos140.tar - docker exec $x bash -c "ctr -n k8s.io images import --base-name docker.io/storageos/node:1.4.0 /stos140.tar" - - # Get storageos pod. - stospod=$(kubectl get pods --template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep storageos) - - echo "Waiting for the storageos container to be ready" - # First and only container in this pod is the storageos container. - until kubectl get pod $stospod --template='{{ (index .status.containerStatuses 0).ready }}' | grep -q true; do sleep 5; done - echo "storageos pod found ready" - - sleep 5 - - # Patch DaemonSet with new storageos version. - kubectl set image ds/storageos-daemonset storageos=storageos/node:1.4.0 - - # kill the pod for the update to apply. - kubectl delete pod $stospod - - sleep 5 - - # Get new pod name. - stospod=$(kubectl get pods --template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep storageos) - - echo "Waiting for the storageos pod to be ready" - until kubectl get pod $stospod --template='{{ (index .status.containerStatuses 0).ready }}' | grep -q true; do sleep 5; done - echo "storageos pod found ready" - - echo "checking init container logs" - UPGRADELOGS=/tmp/dpupgrade-k8s.log - kubectl logs $stospod -c storageos-init > $UPGRADELOGS - echo - - if ! grep "successfully upgraded database" $UPGRADELOGS; then - echo "dpupgrade failed!" - echo - echo "init logs:" - cat $UPGRADELOGS - exit 1 - fi - echo "upgrade successful" - echo -} - main() { make unittest make image @@ -137,12 +45,6 @@ main() { echo "Ready for e2e testing" - # Run out of k8s dpupgrade test. - echo - echo "No k8s dp upgrade test" - echo - nok8s_dpupgrade - echo echo "Prepare for k8s test" echo @@ -155,29 +57,23 @@ main() { # containerd load image from tar archive (KinD with containerd). docker exec $x bash -c "ctr -n k8s.io images import --base-name docker.io/storageos/init:test /init.tar" - # Load storageos node 1.3.0 container image into KinD. - docker pull storageos/node:1.3.0 - docker save storageos/node:1.3.0 > stos130.tar - docker cp stos130.tar $x:/stos130.tar - docker exec $x bash -c "ctr -n k8s.io images import --base-name docker.io/storageos/node:1.3.0 /stos130.tar" + # Use busybox in place of the node container. + docker pull busybox:1.32 + docker save busybox:1.32 > busybox.tar + docker cp busybox.tar $x:/busybox.tar + docker exec $x bash -c "ctr -n k8s.io images import --base-name docker.io/busybox:1.32 /busybox.tar" - # Create storageos daemonset with node 1.3.0 + # Create storageos daemonset with node v1.5.3 kubectl apply -f daemonset.yaml sleep 5 - # Run dp upgrade test. - k8s_dpupgrade - # Get pod name. stospod=$(kubectl get pods --template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep storageos) - # NOTE: Once dataplane upgrade test is no longer needed, remove the - # k8s_dpupgrade call above and uncomment the following wait code. - - # echo "Waiting for the storageos pod to be ready" - # until kubectl get pod $stospod --template='{{ (index .status.containerStatuses 0).ready }}' | grep -q true; do sleep 5; done - # # until kubectl get pod $stospod --no-headers -o go-template='{{.status.phase}}' | grep -q Running; do sleep 5; done - # echo "storageos pod found ready" + echo "Waiting for the storageos pod to be ready" + until kubectl get pod $stospod --template='{{ (index .status.containerStatuses 0).ready }}' | grep -q true; do sleep 5; done + # until kubectl get pod $stospod --no-headers -o go-template='{{.status.phase}}' | grep -q Running; do sleep 5; done + echo "storageos pod found ready" echo echo "init container logs:" diff --git a/mocks/mock_runner.go b/mocks/mock_runner.go index 06c5e04..2130b78 100644 --- a/mocks/mock_runner.go +++ b/mocks/mock_runner.go @@ -5,34 +5,35 @@ package mocks import ( - gomock "github.com/golang/mock/gomock" reflect "reflect" + + gomock "github.com/golang/mock/gomock" ) -// MockRunner is a mock of Runner interface +// MockRunner is a mock of Runner interface. type MockRunner struct { ctrl *gomock.Controller recorder *MockRunnerMockRecorder } -// MockRunnerMockRecorder is the mock recorder for MockRunner +// MockRunnerMockRecorder is the mock recorder for MockRunner. type MockRunnerMockRecorder struct { mock *MockRunner } -// NewMockRunner creates a new mock instance +// NewMockRunner creates a new mock instance. func NewMockRunner(ctrl *gomock.Controller) *MockRunner { mock := &MockRunner{ctrl: ctrl} mock.recorder = &MockRunnerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockRunner) EXPECT() *MockRunnerMockRecorder { return m.recorder } -// RunScript mocks base method +// RunScript mocks base method. func (m *MockRunner) RunScript(arg0 string, arg1 map[string]string, arg2 ...string) ([]byte, []byte, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} @@ -46,7 +47,7 @@ func (m *MockRunner) RunScript(arg0 string, arg1 map[string]string, arg2 ...stri return ret0, ret1, ret2 } -// RunScript indicates an expected call of RunScript +// RunScript indicates an expected call of RunScript. func (mr *MockRunnerMockRecorder) RunScript(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{arg0, arg1}, arg2...) diff --git a/scripts/10-dbupgrade-v1v2/README.md b/scripts/10-dbupgrade-v1v2/README.md deleted file mode 100644 index b93af54..0000000 --- a/scripts/10-dbupgrade-v1v2/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# StorageoS DB Upgrade tool - -storageos/node:1.4.0 changes the way in which StorageOS stores volume metadata in its internal database. -We call this new format, v2. Before running a 1.4.0 StorageOS node container it is necessary to upgrade -any existing v1 databases to the new v2 format. `storageos_dbupgrade_v1v2` does that. - -Prior to running `storageos_dbupgrade_v1v2` the `NODE_IMAGE` environment variable must be set with the -intended StorageOS node container version, for example "storageos/node:1.4.0". `storageos_dbupgrade_v1v2` -uses this environment variable to work out whether or not to upgrade the database to the v2 format. -Obviously we don't want to upgrade the DB if we intend on running a version of StorageOS that's earlier -than 1.4.0. - -It's safe to run `storageos_dbupgrade_v1v2` more than once as subsequent attempts to upgrade an already -upgraded DB will simply do nothing. If the `storageos_dbupgrade_v1v2` is killed mid-way through upgrading -a subsequent run will complete the upgrade. After a successful upgrade a backup of the original v1 database -will be kept at `/var/lib/storageos/data/db-old`. diff --git a/scripts/10-dbupgrade-v1v2/storageos_dbupgrade_v1v2 b/scripts/10-dbupgrade-v1v2/storageos_dbupgrade_v1v2 deleted file mode 100755 index 5865fd6..0000000 --- a/scripts/10-dbupgrade-v1v2/storageos_dbupgrade_v1v2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:529fcb63de815a3bdeea1f05645e09929f2dd005b30da9ccf2f289c67776d2ef -size 79177832