Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-network-k8s: Improve prereqs logic #1241

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions test-network-k8s/scripts/prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,43 @@ function check_prereqs() {
exit 1
fi

# Use the local fabric binaries if available. If not, go get them.
# Define the sed expression to extract the version number
VERSION_SED_EXPR='s/^ Version: v\?\(.*\)$/\1/p'

# Use the fabric peer and ca containers to check fabric image versions
# NOTE: About extracting the version number:
# In older versions, the prefix 'v' was not included in the version string,
# but in recent versions, 'v' has been added.
# The following commands remove the optional 'v' to standardize the format.
FABRIC_IMAGE_VERSION=$(${CONTAINER_CLI} run --rm ${FABRIC_PEER_IMAGE} peer version | sed -ne "$VERSION_SED_EXPR")
FABRIC_CA_IMAGE_VERSION=$(${CONTAINER_CLI} run --rm ${FABRIC_CONTAINER_REGISTRY}/fabric-ca:$FABRIC_CA_VERSION fabric-ca-server version | sed -ne "$VERSION_SED_EXPR")
echo "Fabric image versions: Peer ($FABRIC_IMAGE_VERSION), CA ($FABRIC_CA_IMAGE_VERSION)"
if [ -z "$FABRIC_IMAGE_VERSION" ] || [ -z "$FABRIC_CA_IMAGE_VERSION" ]; then
echo "It seems some of the specified Fabric images are not available."
exit 1
fi

# Use the local fabric binaries if available. If not, go get them.
bin/peer version &> /dev/null
if [[ $? -ne 0 ]]; then
echo "Downloading LATEST Fabric binaries and config"
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/bootstrap.sh \
| bash -s -- -s -d
echo "Downloading Fabric binaries and config"
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh \
| bash -s -- -f ${FABRIC_IMAGE_VERSION} -c ${FABRIC_CA_IMAGE_VERSION} binary

# remove sample config files extracted by the installation script
rm config/configtx.yaml
rm config/core.yaml
rm config/orderer.yaml
fi

# Check if the binaries match your docker images
FABRIC_LOCAL_VERSION=$(bin/peer version | sed -ne "$VERSION_SED_EXPR")
FABRIC_CA_LOCAL_VERSION=$(bin/fabric-ca-client version | sed -ne "$VERSION_SED_EXPR")
echo "Fabric binary versions: Peer ($FABRIC_LOCAL_VERSION), CA ($FABRIC_CA_LOCAL_VERSION)"
if [ "$FABRIC_LOCAL_VERSION" != "$FABRIC_IMAGE_VERSION" ] || [ "$FABRIC_CA_LOCAL_VERSION" != "$FABRIC_CA_IMAGE_VERSION" ]; then
echo "WARN: Local fabric binaries and docker images are out of sync. This may cause problems."
fi

export PATH=bin:$PATH

# Double-check that the binary transfer was OK
Expand Down
2 changes: 1 addition & 1 deletion test-network/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function checkPrereqs() {
infoln "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION"

if [ "$LOCAL_VERSION" != "$DOCKER_IMAGE_VERSION" ]; then
warnln "Local fabric binaries and docker images are out of sync. This may cause problems."
warnln "Local fabric binaries and docker images are out of sync. This may cause problems."
fi

for UNSUPPORTED_VERSION in $NONWORKING_VERSIONS; do
Expand Down
Loading