Skip to content

Commit

Permalink
FAB-16544 Homogenize orderer endpoint overrides
Browse files Browse the repository at this point in the history
This CR is meant to bring the config between master and release-1.4
inline.  It adds the caCertsFile to the sample config, and additionally
tweaks the way errors are handled in the config processing to match
feedback which was incorporated into the master CRs.

Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
Change-Id: Ibf3c21489bd81cf0434a3ec457180e1ddf95aa56
  • Loading branch information
Jason Yellick authored and mastersingh24 committed Nov 12, 2019
1 parent 3257ed6 commit 707f763
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
10 changes: 9 additions & 1 deletion core/peer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,17 @@ func GetOrdererAddressOverrides() (map[string]*comm.OrdererEndpoint, error) {
if len(overrides) > 0 {
overrideMap = make(map[string]*comm.OrdererEndpoint)
for _, override := range overrides {
if override.CACertsFile == "" {
overrideMap[override.From] = &comm.OrdererEndpoint{
Address: override.To,
}
continue
}

pem, err := ioutil.ReadFile(override.CACertsFile)
if err != nil {
return nil, errors.WithMessage(err, fmt.Sprintf("could not read file '%s' specified for caCertsFile of orderer endpoint override from '%s' to '%s'", override.CACertsFile, override.From, override.To))
logger.Warningf("could not read file '%s' specified for caCertsFile of orderer endpoint override from '%s' to '%s', skipping: %s", override.CACertsFile, override.From, override.To, err)
continue
}

overrideMap[override.From] = &comm.OrdererEndpoint{
Expand Down
26 changes: 7 additions & 19 deletions core/peer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,11 @@ func TestGetOrdererAddressOverrides(t *testing.T) {
peer:
deliveryclient:
addressOverrides:
- from: myaddress
to: youraddress
caCertsFile: testdata/Org1-cert.pem
- from: myaddress0
to: youraddress0
- from: myaddress1
to: youraddress1
caCertsFile: testdata/missing.pem
- from: myaddress2
to: youraddress2
caCertsFile: testdata/Org1-cert.pem`
Expand All @@ -339,22 +341,8 @@ func TestGetOrdererAddressOverrides(t *testing.T) {
}

expected := map[string]*comm.OrdererEndpoint{
"myaddress": {
Address: "youraddress",
PEMs: []byte(`-----BEGIN CERTIFICATE-----
MIIB8TCCAZegAwIBAgIQU59imQ+xl+FmwuiFyUgFezAKBggqhkjOPQQDAjBYMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzENMAsGA1UEChMET3JnMTENMAsGA1UEAxMET3JnMTAeFw0xNzA1MDgw
OTMwMzRaFw0yNzA1MDYwOTMwMzRaMFgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpD
YWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQKEwRPcmcx
MQ0wCwYDVQQDEwRPcmcxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFkpP6EqE
87ghFi25UWLvgPatxDiYKYaVSPvpo/XDJ0+9uUmK/C2r5Bvvxx1t8eTROwN77tEK
r+jbJIxX3ZYQMKNDMEEwDgYDVR0PAQH/BAQDAgGmMA8GA1UdJQQIMAYGBFUdJQAw
DwYDVR0TAQH/BAUwAwEB/zANBgNVHQ4EBgQEAQIDBDAKBggqhkjOPQQDAgNIADBF
AiEA1Xkrpq+wrmfVVuY12dJfMQlSx+v0Q3cYce9BE1i2mioCIAzqyduK/lHPI81b
nWiU9JF9dRQ69dEV9dxd/gzamfFU
-----END CERTIFICATE-----
`),
"myaddress0": {
Address: "youraddress0",
},
"myaddress2": {
Address: "youraddress2",
Expand Down
2 changes: 2 additions & 0 deletions sampleconfig/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ peer:
addressOverrides:
# - from:
# to:
# caCertsFile:
# - from:
# to:
# caCertsFile:

# Type for the local MSP - by default it's of type bccsp
localMspType: bccsp
Expand Down

0 comments on commit 707f763

Please sign in to comment.