From 707f763648146fbbc4eb5171c1fbaf4720492661 Mon Sep 17 00:00:00 2001 From: Jason Yellick Date: Mon, 11 Nov 2019 10:20:54 -0500 Subject: [PATCH] FAB-16544 Homogenize orderer endpoint overrides 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 Change-Id: Ibf3c21489bd81cf0434a3ec457180e1ddf95aa56 --- core/peer/config.go | 10 +++++++++- core/peer/config_test.go | 26 +++++++------------------- sampleconfig/core.yaml | 2 ++ 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/core/peer/config.go b/core/peer/config.go index ec69cc9f996..43a7a31cb34 100644 --- a/core/peer/config.go +++ b/core/peer/config.go @@ -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{ diff --git a/core/peer/config_test.go b/core/peer/config_test.go index 6d269b9e9a9..e3f5a3736a6 100644 --- a/core/peer/config_test.go +++ b/core/peer/config_test.go @@ -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` @@ -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", diff --git a/sampleconfig/core.yaml b/sampleconfig/core.yaml index 2d90200c9ec..232ecb66f54 100644 --- a/sampleconfig/core.yaml +++ b/sampleconfig/core.yaml @@ -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