scripts/autoscale.js
function handleUpdate(provider, bigIp, masterIid, masterBadOrNew, options) {
        logger.info('Cluster action UPDATE');

        if (this.instance.isMaster && !masterBadOrNew) {
            return checkForDisconnectedDevices.call(this, bigIp);
        } else if (!this.instance.isMaster) {
            // We're not the master, make sure the master file is not on our disk
            if (fs.existsSync(MASTER_FILE_PATH)) {
                fs.unlinkSync(MASTER_FILE_PATH);
            }

            // If there is a new master, join the cluster
            if (masterBadOrNew && masterIid) {
                return joinCluster.call(this, provider, bigIp, masterIid, options);
            } else if (masterIid) {
                // Double check that we are clustered
                return bigIp.list('/tm/cm/trust-domain/Root')
                    .then((response) => {
                        if (!response || response.status === 'standalone') {
                            logger.info('This instance is not in cluster. Requesting join.');
                            return joinCluster.call(this, provider, bigIp, masterIid, options);
                        }
                        return q();
                    })
                    .catch((err) => {
                        throw err;
                    });
            }
        }
        return q();
    }
function handleUpdate(provider, bigIp, masterIid, masterBadOrNew, options) {
        logger.info('Cluster action UPDATE');

        if (this.instance.isMaster && !masterBadOrNew) {
            return checkForDisconnectedDevices.call(this, bigIp);
        } else if (!this.instance.isMaster) {
            // We're not the master, make sure the master file is not on our disk
            if (fs.existsSync(MASTER_FILE_PATH)) {
                fs.unlinkSync(MASTER_FILE_PATH);
            }

            // If there is a new master, join the cluster
            if (masterBadOrNew && masterIid) {
                return joinCluster.call(this, provider, bigIp, masterIid, options);
            } else if (masterIid) {
                // Double check that we are clustered
                return bigIp.list('/tm/cm/trust-domain/Root')
                    .then((response) => {
                        if (!response || response.status === 'standalone') {
                            logger.info('This instance is not in cluster. Requesting join.');
                            return joinCluster.call(this, provider, bigIp, masterIid, options);
                        }
                        return q();
                    })
                    .catch((err) => {
                        throw err;
                    });
            }
        }
        return q();
    }
Handles --cluster-action update

Called with this bound to the caller