license: do not parse expiry date if it does not exist (#19565) (#19575)

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.
This commit is contained in:
Court Ewing 2018-05-30 16:43:49 -04:00 committed by GitHub
parent b0e3e1fdf0
commit 607d58615c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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'],