Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCR] Update auto-follow pattern serialization #26885

Merged
merged 4 commits into from
Dec 11, 2018

Conversation

sebelga
Copy link
Contributor

@sebelga sebelga commented Dec 10, 2018

ES has made a breaking change in the auto-follow pattern API: elastic/elasticsearch#36203

This PR update the server serialization and Redux state to support it.

Note: The API integration tests have been disabled as something has changed and an auto-follow pattern cannot be created anymore if the cluster has a BASIC license.

@sebelga sebelga requested a review from cjcenizal December 10, 2018 12:35
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, code LGTM!

@@ -21,3 +21,12 @@ export const object = {
return Object.keys(obj).map(k => ({ ...obj[k], __id__: k }));
},
};

export const array = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of exporting an arrayToObject function instead? With named exports I tend to see the module itself take the place of a namespacing object, like the array object in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -16,7 +17,7 @@ const success = action => `${action}_SUCCESS`;
export const reducer = (state = initialState, action) => {
switch (action.type) {
case success(t.AUTO_FOLLOW_PATTERN_LOAD): {
return { ...state, byId: action.payload };
return { ...state, byId: array.toObject(action.payload.patterns, 'name') };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though personally, I don't think this single use of this logic merits extraction into a utility. As a reader of the code, I'd rather see the function defined in this file, e.g. as a mapPatternsToNames function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until we need it somewhere else, we'll need it in Follower Indices soon.

@@ -48,7 +50,7 @@ export const registerAutoFollowPatternRoutes = (server) => {
});

/**
* Returns a list of all Auto follow patterns
* Save an auto follow patterns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo: "an auto follow patterns" should be "an auto-follow pattern" (singular) or just "auto-follow patterns" (plural).

/**
* There is currently a bug in the ES API, instead of returning the auto-follow pattern, it returns
* an array with a single element. Until it is fixed, we take care of it here.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the convo today we might want to rephrase this comment to identify it as a design quirk rather than a bug?

Copy link
Contributor Author

@sebelga sebelga Dec 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove the comment from what we discussed with the ES team. It's by design indeed :)

@cjcenizal cjcenizal added Feature:CCR and Remote Clusters es-management Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more labels Dec 11, 2018
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@sebelga sebelga merged commit ab13658 into elastic:feature/ccr Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:CCR and Remote Clusters Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants