Skip to content

Commit

Permalink
fixing crash when zero replicas configured in a phase for policy (#34480
Browse files Browse the repository at this point in the history
) (#34496)
  • Loading branch information
bmcconaghy authored Apr 4, 2019
1 parent 407f1ba commit c74188a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
) {
Expand Down

0 comments on commit c74188a

Please sign in to comment.