rddill-IBM / ZeroToBlockchain

Tutorial for Zero to Blockchain series
342 stars 924 forks source link

[Chapter13] error: error getting orders: {result: "failed", error: "businessNetwork: Card not found: "} #28

Closed diegoduncan21 closed 5 years ago

diegoduncan21 commented 6 years ago

I deployed, tested and completed the demo on ibm kubernetes without problems, but after a while an error appears: error getting orders: {result: "failed", error: "businessNetwork: Card not found: "} I thougth it was because of the free cluster, but after deploying on paid cluster, the error appeared again. Any suuggestion about how to solve this error?

rddill-IBM commented 6 years ago

Not yet. I've recently noticed the same phenomena on my cluster and need to look at the logs to determine why. I'll respond here when I have more insight.

diegoduncan21 commented 6 years ago

Thank you Bob.

rddill-IBM commented 6 years ago

It appears that the ~/.hfc-key-store folder goes missing after some period of time, or some system event, from the cloud foundry part of this app. I'll spend some time on this over the next day or so and respond here.

diegoduncan21 commented 6 years ago

Thanks Bob! Looking forward to hearing from you soon.

Limcooo commented 6 years ago

Hi both, I am running the chapter13 on Mac and when I run ./install-bx-cli.sh I am getting following stuff. Any chance you have encounter something like this?


./install-bx-cli.sh: line 29: showstep: command not found
updating for OSX
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 51.3M  100 51.3M    0     0  5607k      0  0:00:09  0:00:09 --:--:-- 6635k
       =====================================================
       -----> making kubectl executable
       =====================================================
       =====================================================
       -----> moving kubectl to correct location
       =====================================================
       =====================================================
       -----> installing cloud Foundry CLI
       =====================================================
./install-bx-cli.sh: line 8: wget: command not found
sudo: apt-key: command not found
tee: /etc/apt/sources.list.d/cloudfoundry-cli.list: No such file or directory
deb https://packages.cloudfoundry.org/debian stable main
sudo: apt-get: command not found
sudo: apt-get: command not found
       =====================================================
       -----> Installing BM Cloud (Bluemix) CLI
       =====================================================
Unrecognized Linux platform: darwin. Quit installation.
       =====================================================
       -----> Getting list of uninstalled IBM Cloud CLI Packages
       =====================================================
       =====================================================
       -----> Installing packages
       =====================================================
Installing 
FAILED
Incorrect Usage.

NAME:
   install - Install CLI plug-in

USAGE:
   bx plugin install PLUGIN_NAME [-r REPO_NAME] [-v VERSION] [-f]
   bx plugin install LOCAL-PATH/TO/PLUGIN | URL [-f]

If no repository is specified, the command uses the official plug-in repository 'Bluemix'.
If no version is specified, the command selects the latest available version to install.

EXAMPLE:
   bx plugin install http://example.com/downloads/my-plugin
   bx plugin install ~/Downloads/my-plugin
   bx plugin install plugin-echo
   bx plugin install plugin-echo -v 1.0.0
   bx plugin install plugin-echo -r Bluemix -v 1.0.0

OPTIONS:
   -r value  Repo name where the plug-in binary is located
   -v value  Version of the plug-in to be installed
   -f        Force install of plugin without confirmation

When I tried to run line 29 in the file it seems it is working. But when I tried to run line 8 wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -

it's giving me back command not found. Thank you in advance!

diegoduncan21 commented 6 years ago

hi @Limcooo, i think that is better to do a new issue for your problem, because is a different than mine.

diegoduncan21 commented 6 years ago

gently reminder

diegoduncan21 commented 6 years ago

Hi Bob, Any news about the error I reported 15 days ago? I´m experiencing the same problem in other development I created and I have no clue how to fix it. Any help? May I help you in any way?

ChiragETRM commented 6 years ago

Hi Bob! I'm facing the same issue, please help!

ChiragETRM commented 6 years ago

z2b-buyer.js:132 {result: "failed", error: " order ericbornonthecloudinccom1531862807322 add f…ection Card not found: eric@bornonthecloudinc.com"}

rddill-IBM commented 6 years ago

Re the question on the bx-cli install command not working. That script was updated because it was not correctly distinguishing between OSX and Linux. The current script looks like this (you can copy this and paste it into your existing script)

#!/bin/bash

. ../common_OSX.sh

function install_CLI ()
{
    showStep "installing cloud Foundry CLI"
    wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
    echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
    sudo apt-get update
    sudo apt-get install cf-cli

    showStep "Installing BM Cloud (Bluemix) CLI"
    curl -fsSL https://clis.ng.bluemix.net/install/linux | sh

    showStep "Getting list of uninstalled IBM Cloud CLI Packages"
    PACKAGE_LIST=($(bluemix plugin repo-plugins -r Bluemix | grep "Not Installed" | awk '{print $3}'))

    showStep "Installing packages"
    for ((i=${#PACKAGE_LIST[@]}; i > 0; i--)); 
    do 
        echo "Installing ${PACKAGE_LIST[$i]}"; 
        bx plugin install ${PACKAGE_LIST[$i]} -r Bluemix;
    done
}

function install_kubectl
{
    showstep "Retrieving Ubuntu or OSX kubectl"
        if [[ $OS == "Darwin" ]]; then
        echo "updating for OSX"
        curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/darwin/amd64/kubectl
    else
        echo "updating for Linux"
        curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
    fi

    showStep "making kubectl executable"
    sudo chmod +x kubectl

    showStep "moving kubectl to correct location"
    sudo mv ./kubectl /usr/local/bin/kubectl
}

install_kubectl
install_CLI
ChiragETRM commented 6 years ago

Hi Bob,

Thanks for this. Testing this script and will get back to you shortly! Highly appreciate your help!

Chirag

rddill-IBM commented 6 years ago

I am rebuilding this on a paid cluster and will test shortly. My free cluster expired, so I have to test on a paid cluster. I have found some errors in the scripts I'm using from the ibm-container-service repo. I don't believe that they affect the issue we've all encountered.

The root cause seems to be that the wallet is disappearing and the wallet is, I believe, in the cloud foundry space not in the cluster. If so, then when the cloud foundry app restarts, that wallet goes away. I'm guessing right now because of my own inability to test. For those of you who can test, the wallet should be in .hfc-key-store. If that folder on your cloud foundry system is empty except for the network and business network ids, then the cloud foundry app was reset. This clearing and reset action is performed by the init.sh script which is run each time the cloud foundry app restarts.

If that is the root cause, then we can remedy it quickly by replacing the init.sh script at the end of it's execution with a new script which does not perform the delete and copy functions.

ChiragETRM commented 6 years ago

Hi Bob,

I retried copying the above script and running through the steps to install the network on Bluemix/Kubernetes. However, i get the following error at the end of the kubernetes-deploy.sh command:

   =====================================================
   -----> Please enter your root password for this O/S now
   =====================================================

cp: cannot stat 'controller/restapi/features/composer/creds/-priv': No such file or directory

ChiragETRM commented 6 years ago

On copying the peer admin card to chpater 13 and then pressing "any key" to continue the deployment, the peeradmin card gets wiped off from the chapter 13 folder.

rddill-IBM commented 6 years ago

that's correct. once the script has completed it's work with the peerAdmin.card. it deletes it to avoid having confusing data in your system.

rddill-IBM commented 5 years ago

This appears to be the result of the nodejs app being restarted in the cloud. When this happens, the local card store is emptied. Working on a fix for it, will close this issue when fix is posted.

rddill-IBM commented 5 years ago

As mentioned in my previous post, this error is caused by the lack of persistence across nodejs restarts. To resolve this, I've added a cloudant database (couchdb when running locally) to hold member information.

The approach in this demo is a useful guide for more production oriented approaches, but is not what I would do in production, specifically because all of the data in this single table is held unencrypted. To use this approach yourself, retrieve the events branch (c13-database has been merged into events) https://github.com/rddill-IBM/ZeroToBlockchain/tree/events and then create, if you don't already have it, a cloudant database in the cloud and, for local testing, a couchdb database on your local operating system. Update the env.json file with your credentials for both local and cloud databases.

The autoload process has been removed from the web pages and is now automatically invoked via a 3 second timeout request in index.js. In real life, we would require members to maintain their own userid-password combinations and hold only a hash of the password in the database. In any system, we'd need to keep a copy of the .composer/client-data material in a secured, encrypted backup which would be restored each time the system restarts. I've short-cut that approach by storing all of the above information in the couchdb/cloudant database.

Please note that this approach does not preserve any members which you create using the admin console. It only preserves the members created during the autoload process, all of whom are in the memberlist.json file in the startup folder. I'll leave that as an exercise for anyone who is interested.