Skip to content

Commit

Permalink
Merge branch 'master' into check-plugin-version-on-startup
Browse files Browse the repository at this point in the history
  • Loading branch information
BigFunger committed Sep 15, 2016
2 parents 922c04a + 01b426c commit 5da33ad
Show file tree
Hide file tree
Showing 79 changed files with 1,397 additions and 906 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,28 @@ Kibana is an open source ([Apache Licensed](https://github.com/elastic/kibana/bl
* Run `bin/kibana` on unix, or `bin\kibana.bat` on Windows.
* Visit [http://localhost:5601](http://localhost:5601)


## Upgrade from previous version

* Move any custom configurations in your old kibana.yml to your new one
* Reinstall plugins
* Start or restart Kibana

## Version compatibility with Elasticsearch

Ideally, you should be running Elasticsearch and Kibana with matching version numbers. If your Elasticsearch has an older version number or a newer _major_ number than Kibana, then Kibana will fail to run. If Elasticsearch has a newer minor or patch number than Kibana, then the Kibana Server will log a warning.

_Note: The version numbers below are only examples, meant to illustrate the relationships between different types of version numbers._

| Situation | Example Kibana version | Example ES version | Outcome |
| ------------------------- | -------------------------- |------------------- | ------- |
| Versions are the same. | 5.1.2 | 5.1.2 | 💚 OK |
| ES patch number is newer. | 5.1.__2__ | 5.1.__5__ | ⚠️ Logged warning |
| ES minor number is newer. | 5.__1__.2 | 5.__5__.0 | ⚠️ Logged warning |
| ES major number is newer. | __5__.1.2 | __6__.0.0 | 🚫 Fatal error |
| ES patch number is older. | 5.1.__2__ | 5.1.__0__ | 🚫 Fatal error |
| ES minor number is older. | 5.__1__.2 | 5.__0__.0 | 🚫 Fatal error |
| ES major number is older. | __5__.1.2 | __4__.0.0 | 🚫 Fatal error |

## Quick Start

You're up and running! Fantastic! Kibana is now running on port 5601, so point your browser at http://YOURDOMAIN.com:5601.
Expand Down
Binary file modified docs/images/share-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/share-link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/share-short-link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/sharing-panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/kibana-yml.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ to this Kibana instance.
`kibana.index:`:: *Default: ".kibana"* Kibana uses an index in Elasticsearch to store saved searches, visualizations and
dashboards. Kibana creates a new index if the index doesn’t already exist.
`kibana.defaultAppId:`:: *Default: "discover"* The default application to load.
`kibana.addDataMaxBytes:`:: *Default: 1073741824* The maximum upload size in bytes for the CSV Upload wizard
[[tilemap-settings]]`tilemap.url:`:: *Default: `"https://tiles.elastic.co/v1/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana"`* The URL to the tile
service that Kibana uses to display map tiles in tilemap visualizations.
`tilemap.options.minZoom:`:: *Default: 1* The minimum zoom level.
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
"boom": "2.8.0",
"brace": "0.5.1",
"bunyan": "1.7.1",
"clipboard": "1.5.5",
"commander": "2.8.1",
"css-loader": "0.17.0",
"csv-parse": "1.1.0",
Expand Down Expand Up @@ -181,7 +180,7 @@
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-copy": "0.8.1",
"grunt-esvm": "3.2.4",
"grunt-esvm": "3.2.6",
"grunt-karma": "2.0.0",
"grunt-run": "0.6.0",
"grunt-simple-mocha": "0.4.0",
Expand Down
22 changes: 11 additions & 11 deletions src/cli_plugin/install/__tests__/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('kibana cli', function () {
tempArchiveFile: tempArchiveFilePath,
plugin: 'test-plugin',
version: '5.0.0-SNAPSHOT',
plugins: [ { name: 'foo', path: join(testWorkingPath, 'foo'), version: '5.0.0-SNAPSHOT' } ]
plugins: [ { name: 'foo', path: join(testWorkingPath, 'foo'), kibanaVersion: '5.0.0-SNAPSHOT' } ]
};
const errorStub = sinon.stub();

Expand All @@ -59,7 +59,7 @@ describe('kibana cli', function () {
expect(errorStub.called).to.be(false);
});

it('should throw an error if plugin does contain a version.', function () {
it('should throw an error if plugin is missing a kibana version.', function () {
const errorStub = sinon.stub();

try {
Expand All @@ -69,12 +69,12 @@ describe('kibana cli', function () {
errorStub(err);
}

expect(errorStub.firstCall.args[0]).to.match(/plugin version not found/i);
expect(errorStub.firstCall.args[0]).to.match(/plugin package\.json is missing both a version property/i);
});

it('should throw an error if plugin version does does not match kibana version', function () {
it('should throw an error if plugin kibanaVersion does not match kibana version', function () {
const errorStub = sinon.stub();
settings.plugins[0].version = '1.2.3.4';
settings.plugins[0].kibanaVersion = '1.2.3.4';

try {
assertVersion(settings);
Expand All @@ -83,12 +83,12 @@ describe('kibana cli', function () {
errorStub(err);
}

expect(errorStub.firstCall.args[0]).to.match(/incorrect version/i);
expect(errorStub.firstCall.args[0]).to.match(/incorrect kibana version/i);
});

it('should not throw an error if plugin version matches kibana version', function () {
it('should not throw an error if plugin kibanaVersion matches kibana version', function () {
const errorStub = sinon.stub();
settings.plugins[0].version = '1.0.0';
settings.plugins[0].kibanaVersion = '1.0.0';

try {
assertVersion(settings);
Expand All @@ -102,7 +102,7 @@ describe('kibana cli', function () {

it('should ignore version info after the dash in checks on valid version', function () {
const errorStub = sinon.stub();
settings.plugins[0].version = '1.0.0-foo-bar-version-1.2.3';
settings.plugins[0].kibanaVersion = '1.0.0-foo-bar-version-1.2.3';

try {
assertVersion(settings);
Expand All @@ -116,7 +116,7 @@ describe('kibana cli', function () {

it('should ignore version info after the dash in checks on invalid version', function () {
const errorStub = sinon.stub();
settings.plugins[0].version = '2.0.0-foo-bar-version-1.2.3';
settings.plugins[0].kibanaVersion = '2.0.0-foo-bar-version-1.2.3';

try {
assertVersion(settings);
Expand All @@ -125,7 +125,7 @@ describe('kibana cli', function () {
errorStub(err);
}

expect(errorStub.firstCall.args[0]).to.match(/incorrect version/i);
expect(errorStub.firstCall.args[0]).to.match(/incorrect kibana version/i);
});
});

Expand Down
58 changes: 46 additions & 12 deletions src/cli_plugin/install/__tests__/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,41 @@ describe('kibana cli', function () {

describe('pack', function () {

const testWorkingPath = join(__dirname, '.test.data');
const tempArchiveFilePath = join(testWorkingPath, 'archive.part');
const testPluginPath = join(testWorkingPath, '.installedPlugins');
let testNum = 0;
const workingPathRoot = join(__dirname, '.test.data');
let testWorkingPath;
let tempArchiveFilePath;
let testPluginPath;
let logger;

const settings = {
workingPath: testWorkingPath,
tempArchiveFile: tempArchiveFilePath,
pluginDir: testPluginPath,
plugin: 'test-plugin'
};
let settings;

beforeEach(function () {
//These tests are dependent on the file system, and I had some inconsistent
//behavior with rimraf.sync show up. Until these tests are re-written to not
//depend on the file system, I make sure that each test uses a different
//working directory.
testNum += 1;
testWorkingPath = join(workingPathRoot, testNum + '');
tempArchiveFilePath = join(testWorkingPath, 'archive.part');
testPluginPath = join(testWorkingPath, '.installedPlugins');

settings = {
workingPath: testWorkingPath,
tempArchiveFile: tempArchiveFilePath,
pluginDir: testPluginPath,
plugin: 'test-plugin'
};

logger = new Logger(settings);
sinon.stub(logger, 'log');
sinon.stub(logger, 'error');
rimraf.sync(testWorkingPath);
mkdirp.sync(testWorkingPath);
});

afterEach(function () {
logger.log.restore();
logger.error.restore();
rimraf.sync(testWorkingPath);
rimraf.sync(workingPathRoot);
});

function copyReplyFile(filename) {
Expand Down Expand Up @@ -89,10 +100,33 @@ describe('kibana cli', function () {
expect(settings.plugins[0].name).to.be('test-plugin');
expect(settings.plugins[0].folder).to.be('test-plugin');
expect(settings.plugins[0].version).to.be('1.0.0');
expect(settings.plugins[0].kibanaVersion).to.be('1.0.0');
expect(settings.plugins[0].platform).to.be(undefined);
});
});

it('populate settings.plugin.kibanaVersion', function () {
//kibana.version is defined in this package.json and is different than plugin version
return copyReplyFile('test_plugin_different_version.zip')
.then(() => {
return getPackData(settings, logger);
})
.then(() => {
expect(settings.plugins[0].kibanaVersion).to.be('5.0.1');
});
});

it('populate settings.plugin.kibanaVersion (default to plugin version)', function () {
//kibana.version is not defined in this package.json, defaults to plugin version
return copyReplyFile('test_plugin.zip')
.then(() => {
return getPackData(settings, logger);
})
.then(() => {
expect(settings.plugins[0].kibanaVersion).to.be('1.0.0');
});
});

it('populate settings.plugins with multiple plugins', function () {
return copyReplyFile('test_plugin_many.zip')
.then(() => {
Expand Down
Binary file not shown.
8 changes: 4 additions & 4 deletions src/cli_plugin/install/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export async function rebuildCache(settings, logger) {
}

export function assertVersion(settings) {
if (!settings.plugins[0].version) {
throw new Error (`Plugin version not found. Check package.json in archive`);
if (!settings.plugins[0].kibanaVersion) {
throw new Error (`Plugin package.json is missing both a version property (required) and a kibana.version property (optional).`);
}

const actual = cleanVersion(settings.plugins[0].version);
const actual = cleanVersion(settings.plugins[0].kibanaVersion);
const expected = cleanVersion(settings.version);
if (!versionSatisfies(actual, expected)) {
throw new Error (`Incorrect version in plugin [${settings.plugins[0].name}]. ` +
throw new Error (`Incorrect Kibana version in plugin [${settings.plugins[0].name}]. ` +
`Expected [${expected}]; found [${actual}]`);
}
}
10 changes: 8 additions & 2 deletions src/cli_plugin/install/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ function assertValidPackageName(plugin) {
}
}


/**
* Examine each package.json file to determine the plugin name,
* version, and platform. Mutates the package objects in the packages array
* version, kibanaVersion, and platform. Mutates the package objects
* in the packages array
* @param {object} settings - a plugin installer settings object
* @param {array} packages - array of package objects from listPackages()
*/
Expand All @@ -71,6 +71,12 @@ async function mergePackageData(settings, packages) {
pkg.name = _.get(packageInfo, 'name');
pkg.path = resolve(settings.pluginDir, pkg.name);

// Plugins must specify their version, and by default that version should match
// the version of kibana down to the patch level. If these two versions need
// to diverge, they can specify a kibana.version to indicate the version of
// kibana the plugin is intended to work with.
pkg.kibanaVersion = _.get(packageInfo, 'kibana.version', pkg.version);

const regExp = new RegExp(`${pkg.name}-(.+)`, 'i');
const matches = pkg.folder.match(regExp);
pkg.platform = (matches) ? matches[1] : undefined;
Expand Down
26 changes: 11 additions & 15 deletions src/core_plugins/console/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,7 @@ module.exports = function (kibana) {
let { existsSync } = require('fs');
const { startsWith, endsWith } = require('lodash');

const apps = [
{
title: 'Console',
description: 'JSON aware developer\'s interface to ElasticSearch',
main: 'plugins/console/console',
icon: 'plugins/console/logo.svg',
injectVars: function (server, options) {
const varsToInject = options;
varsToInject.elasticsearchUrl = server.config().get('elasticsearch.url');
return varsToInject;
}
}
];
const apps = [];

if (existsSync(resolve(__dirname, 'public/tests'))) {
apps.push({
Expand Down Expand Up @@ -146,7 +134,7 @@ module.exports = function (kibana) {
payload: {
output: 'stream',
parse: false
},
}
}
});

Expand All @@ -156,7 +144,7 @@ module.exports = function (kibana) {
config: {
...proxyRouteConfig
}
})
});

server.route({
path: '/api/console/api_server',
Expand Down Expand Up @@ -188,6 +176,14 @@ module.exports = function (kibana) {
uiExports: {
apps: apps,

devTools: ['plugins/console/console'],

injectDefaultVars(server, options) {
const varsToInject = options;
varsToInject.elasticsearchUrl = server.config().get('elasticsearch.url');
return varsToInject;
},

noParse: [
join(modules, 'ace' + sep),
join(modules, 'moment_src/moment' + sep),
Expand Down
18 changes: 15 additions & 3 deletions src/core_plugins/console/public/console.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import devTools from 'ui/registry/dev_tools';
import uiRoutes from 'ui/routes';
import template from './index.html';

require('ace');
require('ui-bootstrap-custom');

Expand All @@ -13,6 +17,14 @@ require('./src/directives/sense_help');
require('./src/directives/sense_welcome');
require('./src/directives/sense_navbar');

require('ui/chrome')
.setRootTemplate(require('./index.html'))
.setRootController('sense', 'SenseController');
devTools.register(() => ({
order: 1,
name: 'console',
display: 'Console',
url: '#/dev_tools/console'
}));

uiRoutes.when('/dev_tools/console', {
controller: 'SenseController',
template
});
Loading

0 comments on commit 5da33ad

Please sign in to comment.