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

docker monitor fails in caliper 0.5.0 when referencing a remote docker container #1493

Open
davidkel opened this issue Mar 22, 2023 · 0 comments
Labels
bug Something isn't working component/core Related to the core code-base

Comments

@davidkel
Copy link
Contributor

The following error is received

could not start monitors: typererror: cannot read properties of undefined {hasOwnproperty}

if you specify an entry for docker monitoring such as

monitors:
  resource:
  - module: docker
    options:
      interval: 5
      containers:
      - peer0.org1.example.com
      - peer1.org1.example.com
      - orderer.example.com
      - orderer2.example.com
      - http://10.0.0.252:9051/peer0.org2.example.com

This is due to this line in the monitor-docker.js https://github.com/hyperledger/caliper/blob/943ab2a22872639f39ccb36f8baf94b2863e21c6/packages/caliper-core/lib/manager/monitors/monitor-docker.js#L75

which is

    async findContainers() {
        this.containers = [];
        let filterName = {};
        // Split docker items that are local or remote
        if (this.options.hasOwnProperty('containers')) {
            for (let key in this.options.containers) {
                let container = this.options.containers[key];
                if (container.indexOf('http://') === 0) {
                    // Is remote
                    let remote = URL.parse(container, true);
                    if (remote.hostname === null || remote.port === null || remote.pathname === '/') {
                        Logger.warn('unrecognized host, ' + container);
                    } else if (filterName.remote.hasOwnProperty(remote.hostname)) {  <---- BUG HERE
                        filterName[remote.hostname].containers.push(remote.pathname);
                    } else {
                        filterName[remote.hostname] = { port: remote.port, containers: [remote.pathname] };
                    }
                } else {
                    // Is local
                    if (filterName.hasOwnProperty('localhost')) {
                        filterName.localhost.containers.push(container);
                    } else {
                        filterName.localhost = { containers: [container] };
                    }
                }
            }
        }

We see that there is no property remote on filterName. It should be a simple fix just to remove the .remote part

@davidkel davidkel added bug Something isn't working component/core Related to the core code-base labels Mar 22, 2023
@ghost ghost mentioned this issue May 17, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component/core Related to the core code-base
Projects
None yet
Development

No branches or pull requests

1 participant