From 3920c441f85ee7f3ccf41548c151956a03db0582 Mon Sep 17 00:00:00 2001 From: Timo Tietavainen Date: Fri, 11 Dec 2020 21:40:34 +0200 Subject: [PATCH] Update base image to redis:5.0.9-alpine3.11 and builder images Upgrade DBAAS container's base Redis image to redis:5.0.9-alpine3.11. Upgrade Redis module's base builder image to bldr-alpine3-go:2.0.0. Upgrade DBAAS unit test's base builder image to ubuntu:18.04, because 19.10 has reached end of life. Update DBAAS container tag to 0.5.0. Signed-off-by: Timo Tietavainen Change-Id: Iafee39c335da2044c4c5cb9cd1db63395310a90d --- README.md | 18 ++-- charts/dbaas-service/templates/deployment.yaml | 5 +- charts/dbaas-service/values.yaml | 4 +- charts/dbaas-test/templates/deployment.yaml | 6 +- charts/dbaas-test/values.yaml | 4 +- container-tag.yaml | 2 +- docker/Dockerfile.redis | 6 +- docker/Dockerfile.testapp | 4 +- docs/release-notes.rst | 6 ++ testapplication/go/sdl/sdl.go | 31 +++++- testapplication/go/testapp.go | 132 ++++++++++++------------- 11 files changed, 130 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index 6391fc4..6d2011b 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ This repository containes all the needed elements to deploy database as a servic ## Architecture Redis is the chosen database technology and the final product will deploy autonomous -redis cluster. In R0 schedule, single, non-redundant, non-persistent redis server is -deployed +redis cluster. Supported deployment options are standalone Redis server and HA +(Sentinel) Redis deployment. Either deployment option won't provide data persistency. ## Subsystem structure @@ -32,13 +32,17 @@ docker build --file docker/Dockerfile.testapp --tag dbaas-test . ### DBaaS service -In R0, dbaas service is realized with single container running redis database. -The database is configured to be non-persistent and non-redundant. The container -exposes single port which is hardcoded to be 6379. +Dbaas service is realized either with single container running redis database +or with HA deployment implemented by a redis sentinel solution. +Standalone dbaas database is configured to be non-persistent and +non-redundant. HA dbaas provides redundancy but it is also configured to be +non-persistent. After dbaas service is installed, environment variables **DBAAS_SERVICE_HOST** -and **DBAAS_SERVICE_PORT** are exposed to application containers. SDL library -will automatically use these environment variables. +and **DBAAS_SERVICE_PORT** are exposed to application containers. In the case +of HA dbaas deployment environment variables **DBAAS_MASTER_NAME** and +**DBAAS_SERVICE_SENTINEL_PORT** are also exposed to application containers. +SDL library will automatically use these environment variables. The service is installed via helm by using dbaas-service chart. Modify the values accordingly before installation (repository location, image name, ..) diff --git a/charts/dbaas-service/templates/deployment.yaml b/charts/dbaas-service/templates/deployment.yaml index 341d898..8446b8e 100644 --- a/charts/dbaas-service/templates/deployment.yaml +++ b/charts/dbaas-service/templates/deployment.yaml @@ -18,12 +18,15 @@ # platform project (RICP). # -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Values.backend.name }} spec: replicas: {{ .Values.backend.replicas }} + selector: + matchLabels: + app: {{ .Values.backend.name }} template: metadata: labels: diff --git a/charts/dbaas-service/values.yaml b/charts/dbaas-service/values.yaml index 9c66759..072bb15 100644 --- a/charts/dbaas-service/values.yaml +++ b/charts/dbaas-service/values.yaml @@ -25,6 +25,6 @@ backend: port: 6379 targetPort: 6379 image: - name: snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com/redis-standalone + name: redis-standalone tag: latest - imagePullPolicy: IfNotPresent + imagePullPolicy: Never diff --git a/charts/dbaas-test/templates/deployment.yaml b/charts/dbaas-test/templates/deployment.yaml index d748f06..98d6fb1 100644 --- a/charts/dbaas-test/templates/deployment.yaml +++ b/charts/dbaas-test/templates/deployment.yaml @@ -18,12 +18,16 @@ # platform project (RICP). # -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Values.testapp.name }} spec: replicas: {{ .Values.testapp.replicas }} + selector: + matchLabels: + app: {{ .Values.testapp.name }} + template: metadata: labels: diff --git a/charts/dbaas-test/values.yaml b/charts/dbaas-test/values.yaml index 1b23afa..bfb8850 100644 --- a/charts/dbaas-test/values.yaml +++ b/charts/dbaas-test/values.yaml @@ -23,6 +23,6 @@ testapp: replicas: 1 name: "dbaas-test-app" image: - name: snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com/dbaas-test + name: dbaas-test tag: latest - imagePullPolicy: IfNotPresent + imagePullPolicy: Never diff --git a/container-tag.yaml b/container-tag.yaml index 1f5d874..680b74d 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -2,4 +2,4 @@ # This file is expected to be in the docker build directory; # can be moved with suitable JJB configuration. --- -tag: '0.4.1' +tag: '0.5.0' diff --git a/docker/Dockerfile.redis b/docker/Dockerfile.redis index d97625b..7650919 100644 --- a/docker/Dockerfile.redis +++ b/docker/Dockerfile.redis @@ -25,7 +25,7 @@ # # NOTE: The valgrind false positive problem could also potentially be solved # with valgrind suppression files but that kind of approach may be fragile. -FROM ubuntu:19.10 as cpputest-build +FROM ubuntu:18.04 as cpputest-build RUN apt update && \ apt install -y \ @@ -60,7 +60,7 @@ RUN ./autogen.sh && \ ./configure --disable-unit-test-memcheck && \ make test -FROM nexus3.o-ran-sc.org:10004/o-ran-sc/bldr-alpine3:12-a3.11 as build-env +FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-alpine3-go:2.0.0 as build-env RUN apk add cpputest COPY ./redismodule /redismodule @@ -71,7 +71,7 @@ RUN ./autogen.sh && \ make install -FROM redis:5.0.5-alpine3.9 as build +FROM redis:5.0.9-alpine3.11 as build RUN apk add curl COPY --from=build-env /usr/local/libexec/redismodule/libredismodule.so /usr/local/libexec/redismodule/libredismodule.so diff --git a/docker/Dockerfile.testapp b/docker/Dockerfile.testapp index 1e88a62..74f9bb4 100644 --- a/docker/Dockerfile.testapp +++ b/docker/Dockerfile.testapp @@ -25,8 +25,8 @@ RUN apt-get update && \ apt install -y redis-tools && \ apt install -y git && \ apt install -y wget && \ - wget https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz && \ - tar -xvf go1.11.4.linux-amd64.tar.gz && \ + wget https://dl.google.com/go/go1.15.6.linux-amd64.tar.gz && \ + tar -xvf go1.15.6.linux-amd64.tar.gz && \ mv go /usr/local && \ apt-get clean diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 0b77d09..a54c4f5 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -30,6 +30,12 @@ This document provides the release notes of the dbaas. Version history --------------- +[0.5.0] - 2020-12-11 + +* Upgrade DBAAS container's base Redis image to redis:5.0.9-alpine3.11. +* Upgrade Redis module's base builder image to bldr-alpine3-go:2.0.0. +* Upgrade DBAAS unit test's base builder image to ubuntu:18.04. + [0.4.1] - 2020-06-17 * Upgrade base image to bldr-alpine3:12-a3.11 in Redis docker build diff --git a/testapplication/go/sdl/sdl.go b/testapplication/go/sdl/sdl.go index 2a40dac..5887b92 100644 --- a/testapplication/go/sdl/sdl.go +++ b/testapplication/go/sdl/sdl.go @@ -21,6 +21,7 @@ package sdl import ( + "fmt" "github.com/go-redis/redis" "os" "reflect" @@ -53,10 +54,35 @@ func Create(nameSpace string) *SdlInstance { nsPrefix: "{" + nameSpace + "},", client: client, } + s.CheckRedisModuleExtensionCommands() return &s } +func (s *SdlInstance) CheckRedisModuleExtensionCommands() { + var moduleError bool + commands, err := s.client.Command(s.client.Context()).Result() + if err == nil { + redisModuleCommands := []string{ + "setie", "delie", "setiepub", "setnxpub", + "msetmpub", "delmpub", + } + for _, v := range redisModuleCommands { + _, ok := commands[v] + if !ok { + fmt.Println("ERROR: Missing command:", v) + moduleError = true + } + } + } else { + fmt.Println("ERROR:", err) + } + if moduleError { + fmt.Println("Please make sure that redis extension modules have been installed.") + fmt.Println("To install: redis-cli module load /usr/local/libexec/redismodule/libredismodule.so") + } +} + func (s *SdlInstance) setNamespaceToKeys(pairs ...interface{}) []interface{} { var retVal []interface{} for i, v := range pairs { @@ -93,7 +119,7 @@ func (s *SdlInstance) setNamespaceToKeys(pairs ...interface{}) []interface{} { func (s *SdlInstance) Set(pairs ...interface{}) error { keyAndData := s.setNamespaceToKeys(pairs...) - err := s.client.MSet(keyAndData...).Err() + err := s.client.MSet(s.client.Context(), keyAndData...).Err() return err } @@ -102,7 +128,7 @@ func (s *SdlInstance) Get(keys []string) (map[string]interface{}, error) { for _, v := range keys { keysWithNs = append(keysWithNs, s.nsPrefix+v) } - val, err := s.client.MGet(keysWithNs...).Result() + val, err := s.client.MGet(s.client.Context(), keysWithNs...).Result() m := make(map[string]interface{}) if err != nil { return m, err @@ -136,4 +162,3 @@ func (s *SdlInstance) GetAll() []string { func (s *SdlInstance) RemoveAll() { panic("RemoveAll not implemented\n") } - diff --git a/testapplication/go/testapp.go b/testapplication/go/testapp.go index ee39cb8..ae05850 100644 --- a/testapplication/go/testapp.go +++ b/testapplication/go/testapp.go @@ -21,84 +21,84 @@ package main import ( - "fmt" - "./sdl" + "./sdl" + "fmt" ) func main() { - sdl1 := sdl.Create("test1") + sdl1 := sdl.Create("test1") - var err error + var err error - err = sdl1.Set("key1", "data1", "key2", "data2") - if err != nil { - fmt.Printf("unable to write to DB\n") - } + err = sdl1.Set("key1", "data1", "key2", "data2") + if err != nil { + fmt.Printf("unable to write to DB\n") + } - err = sdl1.Set("num1", 1, "num2", 2) - if err != nil { - fmt.Printf("unable to write to DB\n") - } + err = sdl1.Set("num1", 1, "num2", 2) + if err != nil { + fmt.Printf("unable to write to DB\n") + } - d := make([]byte, 3) - d[0] = 1 - d[1] = 2 - d[2] = 3 - err = sdl1.Set("arr1", d) - if err != nil { - fmt.Printf("unable to write to DB\n") - } + d := make([]byte, 3) + d[0] = 1 + d[1] = 2 + d[2] = 3 + err = sdl1.Set("arr1", d) + if err != nil { + fmt.Printf("unable to write to DB\n") + } - p := []string{"pair1", "data1", "pair2", "data2"} - err = sdl1.Set(p) - if err != nil { - fmt.Printf("unable to write to DB\n") - } + p := []string{"pair1", "data1", "pair2", "data2"} + err = sdl1.Set(p) + if err != nil { + fmt.Printf("unable to write to DB\n") + } - a := [4]string{"array1", "adata1", "array2", "adata2"} - err = sdl1.Set(a) - if err != nil { - fmt.Printf("unable to write to DB\n") - } + a := [4]string{"array1", "adata1", "array2", "adata2"} + err = sdl1.Set(a) + if err != nil { + fmt.Printf("unable to write to DB\n") + } - mix1 := []interface{}{"mix1", "data1", "mix2", 2} - err = sdl1.Set(mix1) - if err != nil { - fmt.Printf("unable to write to DB\n") - } + mix1 := []interface{}{"mix1", "data1", "mix2", 2} + err = sdl1.Set(mix1) + if err != nil { + fmt.Printf("unable to write to DB\n") + } - mix2 := [4]interface{}{"mix3", "data3", "mix4", 4} - err = sdl1.Set(mix2) - if err != nil { - fmt.Printf("unable to write to DB\n") - } + mix2 := [4]interface{}{"mix3", "data3", "mix4", 4} + err = sdl1.Set(mix2) + if err != nil { + fmt.Printf("unable to write to DB\n") + } - retDataMap, err := sdl1.Get([]string{"key1", "key3", "key2"}) - if err != nil { - fmt.Printf("Unable to read from DB\n") - } else { - for i, v := range retDataMap { - fmt.Printf("%s:%s\n", i, v) - } - } + retDataMap, err := sdl1.Get([]string{"key1", "key3", "key2"}) + if err != nil { + fmt.Printf("Unable to read from DB\n") + } else { + for i, v := range retDataMap { + fmt.Printf("%s:%s\n", i, v) + } + } - retDataMap2, err := sdl1.Get([]string{"num1", "num2"}) - if err != nil { - fmt.Printf("Unable to read from DB\n") - } else { - for i, v := range retDataMap2 { - fmt.Printf("%s:%s\n", i, v) - } - } + retDataMap2, err := sdl1.Get([]string{"num1", "num2"}) + if err != nil { + fmt.Printf("Unable to read from DB\n") + } else { + for i, v := range retDataMap2 { + fmt.Printf("%s:%s\n", i, v) + } + } - fmt.Println("-------------") - allKeys := []string{"key1", "key2", "num1", "num2", "pair1", "pair2", "array1", "array2", "mix1", "mix2", "mix3", "mix4", "arr1"} - retDataMap3, err := sdl1.Get(allKeys) - if err != nil { - fmt.Printf("Unable to read from DB\n") - } else { - for i3, v3 := range retDataMap3 { - fmt.Printf("%s:%s\n", i3, v3) - } - } + fmt.Println("-------------") + allKeys := []string{"key1", "key2", "num1", "num2", "pair1", "pair2", "array1", "array2", "mix1", "mix2", "mix3", "mix4", "arr1"} + retDataMap3, err := sdl1.Get(allKeys) + if err != nil { + fmt.Printf("Unable to read from DB\n") + } else { + for i3, v3 := range retDataMap3 { + fmt.Printf("%s:%s\n", i3, v3) + } + } } -- 2.16.6