From ac9ed89d6fa17a0c5fd905907a7da3599f01876b Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Wed, 30 May 2018 15:25:55 -0400 Subject: [PATCH] license: do not parse expiry date if it does not exist (#19565) Basic licenses never expire, so they do not have an expiration date at all according to the Elasticsearch API. When this happens, we should not attempt to parse the date nor show the expiry date in the log. --- x-pack/plugins/xpack_main/server/lib/xpack_info.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/xpack_main/server/lib/xpack_info.js b/x-pack/plugins/xpack_main/server/lib/xpack_info.js index 105f31782a85..c11462955443 100644 --- a/x-pack/plugins/xpack_main/server/lib/xpack_info.js +++ b/x-pack/plugins/xpack_main/server/lib/xpack_info.js @@ -6,7 +6,7 @@ import { createHash } from 'crypto'; import moment from 'moment'; -import { get } from 'lodash'; +import { get, has } from 'lodash'; import { Poller } from '../../../../common/poller'; import { XPackInfoLicense } from './xpack_info_license'; @@ -117,11 +117,17 @@ export class XPackInfo { }); if (this._hasLicenseInfoChanged(response)) { - const licenseInfo = [ + const licenseInfoParts = [ `mode: ${get(response, 'license.mode')}`, `status: ${get(response, 'license.status')}`, - `expiry date: ${moment(get(response, 'license.expiry_date_in_millis'), 'x').format()}` - ].join(' | '); + ]; + + if (has(response, 'license.expiry_date_in_millis')) { + const expiryDate = moment(response.license.expiry_date_in_millis, 'x').format(); + licenseInfoParts.push(`expiry date: ${expiryDate}`); + } + + const licenseInfo = licenseInfoParts.join(' | '); this._log( ['license', 'info', 'xpack'],