Skip to content

Commit

Permalink
Fix statedb mapping (#13)
Browse files Browse the repository at this point in the history
* Map state database to a valid one
* Increase timeout for tests & Use go1.16
* test only 1.16.x
  • Loading branch information
Dviejopomata authored Apr 28, 2021
1 parent 0049332 commit 6e7cfd2
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 20 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ website-docs
dist
kubectl-hlf
.git
fixtures
hlf-operator
fixtures
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion charts/hlf-peer/templates/configmap--peer--core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/hlf-peer/templates/configmap--peer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions charts/hlf-peer/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion charts/hlf-peer/templates/pvc-couchdb.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/hlf-peer/templates/secret--couchdb.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if eq .Values.peer.databaseType "couchdb" }}
{{- if eq .Values.peer.databaseType "CouchDB" }}
apiVersion: v1
kind: Secret
metadata:
Expand Down
12 changes: 10 additions & 2 deletions controllers/ca/ca_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1539,7 +1547,7 @@ var _ = Describe("Fabric Controllers", func() {
}
return err == nil
},
"140s",
"280s",
defInterval,
).Should(BeTrue(), "peer should join the channel")

Expand Down
11 changes: 10 additions & 1 deletion controllers/peer/peer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 6e7cfd2

Please sign in to comment.