diff --git a/.dockerignore b/.dockerignore index 1795a17b..aaac5cfc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,5 +4,4 @@ website-docs dist kubectl-hlf .git -fixtures -hlf-operator \ No newline at end of file +fixtures \ No newline at end of file diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 1523c676..b4510182 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.15 + go-version: 1.16 - name: Docker Login uses: docker/login-action@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e0b13210..5ecf75d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: test: strategy: matrix: - go-version: [ 1.15.x, 1.16.x ] + go-version: [ 1.16.x ] os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} steps: diff --git a/Dockerfile b/Dockerfile index f2d1fc43..98d8b6ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,15 +6,15 @@ LABEL name="HLF Operator" \ version="v1.1.0" \ release="v1.1.0" +RUN \ + microdnf update --nodocs && \ + microdnf install curl ca-certificates shadow-utils --nodocs + COPY CREDITS /licenses/CREDITS COPY LICENSE /licenses/LICENSE COPY LICENSE /licenses/LICENSE COPY charts /charts -RUN \ - microdnf update --nodocs && \ - microdnf install curl ca-certificates shadow-utils --nodocs - COPY hlf-operator /hlf-operator CMD ["/hlf-operator"] \ No newline at end of file diff --git a/charts/hlf-peer/templates/configmap--peer--core.yaml b/charts/hlf-peer/templates/configmap--peer--core.yaml index 5ff8d392..933720bf 100644 --- a/charts/hlf-peer/templates/configmap--peer--core.yaml +++ b/charts/hlf-peer/templates/configmap--peer--core.yaml @@ -633,7 +633,7 @@ data: blockchain: state: - # stateDatabase - options are "goleveldb", "couchdb" + # stateDatabase - options are "goleveldb", "CouchDB" # goleveldb - default state database stored in goleveldb. # CouchDB - store state database in CouchDB stateDatabase: goleveldb diff --git a/charts/hlf-peer/templates/configmap--peer.yaml b/charts/hlf-peer/templates/configmap--peer.yaml index bc06da14..ff6265d0 100644 --- a/charts/hlf-peer/templates/configmap--peer.yaml +++ b/charts/hlf-peer/templates/configmap--peer.yaml @@ -73,7 +73,7 @@ data: {{- end }} CORE_LEDGER_STATE_STATEDATABASE: {{ .Values.peer.databaseType | quote }} # Containers in the same pod share the host - {{- if eq .Values.peer.databaseType "couchdb" }} + {{- if eq .Values.peer.databaseType "CouchDB" }} CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS: localhost:5984 {{- end }} PEER_CFG_PATH: /var/hyperledger/config diff --git a/charts/hlf-peer/templates/deployment.yaml b/charts/hlf-peer/templates/deployment.yaml index 266697a5..ee6aefea 100644 --- a/charts/hlf-peer/templates/deployment.yaml +++ b/charts/hlf-peer/templates/deployment.yaml @@ -23,7 +23,7 @@ spec: {{ toYaml .Values.hostAliases | indent 10 }} volumes: - name: couchdb - {{- if eq .Values.peer.databaseType "couchdb" }} + {{- if eq .Values.peer.databaseType "CouchDB" }} {{- if .Values.persistence.couchdb.enabled }} persistentVolumeClaim: claimName: {{ include "hlf-peer.fullname" . }}--couchdb @@ -149,7 +149,7 @@ spec: value: '127.0.0.1:8080' {{- end }} envFrom: - {{- if eq .Values.peer.databaseType "couchdb" }} + {{- if eq .Values.peer.databaseType "CouchDB" }} - secretRef: name: {{ include "hlf-peer.fullname" . }}--couchdb {{- end }} @@ -215,7 +215,7 @@ spec: apiVersion: v1 fieldPath: status.podIP {{- end }} - {{- if eq $.Values.peer.databaseType "couchdb" }} + {{- if eq $.Values.peer.databaseType "CouchDB" }} - name: couchdb image: "couchdb:3.1.1" imagePullPolicy: {{ .Values.image.pullPolicy }} @@ -251,7 +251,7 @@ spec: {{- with .Values.affinity }} affinity: ## This affinity is required to ensure reasonable ledger access speeds - {{- if eq $.Values.peer.databaseType "couchdb" }} + {{- if eq $.Values.peer.databaseType "CouchDB" }} podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: diff --git a/charts/hlf-peer/templates/pvc-couchdb.yaml b/charts/hlf-peer/templates/pvc-couchdb.yaml index 1b624980..e47d50fa 100644 --- a/charts/hlf-peer/templates/pvc-couchdb.yaml +++ b/charts/hlf-peer/templates/pvc-couchdb.yaml @@ -1,4 +1,4 @@ -{{- if eq .Values.peer.databaseType "couchdb" }} +{{- if eq .Values.peer.databaseType "CouchDB" }} {{- if and .Values.persistence.couchdb.enabled (not .Values.persistence.couchdb.existingClaim) }} kind: PersistentVolumeClaim apiVersion: v1 diff --git a/charts/hlf-peer/templates/secret--couchdb.yaml b/charts/hlf-peer/templates/secret--couchdb.yaml index d5788cb8..92cca4cb 100644 --- a/charts/hlf-peer/templates/secret--couchdb.yaml +++ b/charts/hlf-peer/templates/secret--couchdb.yaml @@ -1,4 +1,4 @@ -{{- if eq .Values.peer.databaseType "couchdb" }} +{{- if eq .Values.peer.databaseType "CouchDB" }} apiVersion: v1 kind: Secret metadata: diff --git a/controllers/ca/ca_controller_test.go b/controllers/ca/ca_controller_test.go index 46726961..52ab38ff 100644 --- a/controllers/ca/ca_controller_test.go +++ b/controllers/ca/ca_controller_test.go @@ -14,8 +14,8 @@ import ( "github.com/kfsoftware/hlf-operator/controllers/ordnode" operatorv1alpha1 "github.com/kfsoftware/hlf-operator/pkg/client/clientset/versioned" - apierrors "k8s.io/apimachinery/pkg/api/errors" log "github.com/sirupsen/logrus" + apierrors "k8s.io/apimachinery/pkg/api/errors" "github.com/Masterminds/sprig" pb "github.com/hyperledger/fabric-protos-go/peer" @@ -1407,6 +1407,14 @@ var _ = Describe("Fabric Controllers", func() { By("add the peer to the consortium") ordClient := getClientForOrderer(orderer, ordererCA) + Eventually(func() bool{ + _, err := ordClient.QueryConfigBlockFromOrderer(systemChannelID) + Expect(err).ToNot(HaveOccurred()) + if err != nil { + return false + } + return true + }, "100s", defInterval) block, err := ordClient.QueryConfigBlockFromOrderer(systemChannelID) Expect(err).ToNot(HaveOccurred()) systemChannelConfig, err := resource.ExtractConfigFromBlock(block) @@ -1539,7 +1547,7 @@ var _ = Describe("Fabric Controllers", func() { } return err == nil }, - "140s", + "280s", defInterval, ).Should(BeTrue(), "peer should join the channel") diff --git a/controllers/peer/peer_controller.go b/controllers/peer/peer_controller.go index 9888eeec..50a0377d 100644 --- a/controllers/peer/peer_controller.go +++ b/controllers/peer/peer_controller.go @@ -697,6 +697,15 @@ func GetConfig(conf *hlfv1alpha1.FabricPeer, client *kubernetes.Clientset, chart if imagePullPolicy == "" { imagePullPolicy = hlfv1alpha1.DefaultImagePullPolicy } + stateDb := "goleveldb" + switch spec.StateDb { + case hlfv1alpha1.StateDBCouchDB: + stateDb = "CouchDB" + case hlfv1alpha1.StateDBLevelDB: + stateDb = "goleveldb" + default: + stateDb = "goleveldb" + } var c = FabricPeerChart{ Image: Image{ Repository: spec.Image, @@ -706,7 +715,7 @@ func GetConfig(conf *hlfv1alpha1.FabricPeer, client *kubernetes.Clientset, chart ExternalBuilders: externalBuilders, DockerSocketPath: spec.DockerSocketPath, Peer: Peer{ - DatabaseType: string(spec.StateDb), + DatabaseType: stateDb, MspID: spec.MspID, Gossip: Gossip{ Bootstrap: spec.Gossip.Bootstrap, diff --git a/go.mod b/go.mod index f76c5e4f..5fe3b5f2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/kfsoftware/hlf-operator -go 1.13 +go 1.16 require ( cloud.google.com/go v0.49.0 // indirect