fixing crash when zero replicas configured in a phase for policy (#34480) (#34497)

This commit is contained in:
Bill McConaghy 2019-04-04 06:08:51 -04:00 committed by GitHub
parent d6e89c2a26
commit 2fe8267992
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -124,7 +124,7 @@ export const splitSizeAndUnits = field => {
export const isNumber = value => typeof value === 'number';
export const isEmptyObject = (obj) => {
return Object.entries(obj).length === 0 && obj.constructor === Object;
return !obj || (Object.entries(obj).length === 0 && obj.constructor === Object);
};
export const phaseFromES = (phase, phaseName, defaultEmptyPolicy) => {
@ -275,7 +275,7 @@ export const phaseToES = (phase, originalEsPhase) => {
}
if (esPhase.actions.allocate
&& !esPhase.actions.allocate.require
&& !esPhase.actions.allocate.number_of_replicas
&& !isNumber(esPhase.actions.allocate.number_of_replicas)
&& isEmptyObject(esPhase.actions.allocate.include)
&& isEmptyObject(esPhase.actions.allocate.exclude)
) {