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.
This commit is contained in:
Court Ewing 2018-05-30 15:25:55 -04:00 committed by GitHub
parent 863707edf8
commit ac9ed89d6f
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'],