-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add snapshots support #76
Conversation
network.host: 0.0.0.0 | ||
|
||
# You need to create this folder in order to run snapshots | ||
path.repo: ["/tmp/snapshots"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we pass this variable to ES with the environment instead of having to build a whole new Docker image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, does not work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is due to the fact that the value is an array. Could you try to use YAML objects for environment variables? Like this:
services:
kuzzle:
# ...
elasticsearch:
image: yourImage
environments:
path.repo:
- /tmp/snapshots
# ...
or using regular YAML array of string:
services:
kuzzle:
# ...
elasticsearch:
image: yourImage
environments:
- 'path.repo=["/tmp/snapshots"]'
# ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double quote in the second snippet are required for YAML parsing (#76 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try that, get back to you if it works or not 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexandrebouthinon both of the options you proposed weren't successful. Only option I see is to keep it that way :x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I thought it was a parsing and type inference problem. That's good for me then 🙂
src/commands/es/snapshots/restore.ts
Outdated
async getIndices(esClient: Client) { | ||
const beforeResponse = await esClient.cat.indices({ format: 'json' }) | ||
|
||
const indices: string[] = beforeResponse.body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type is automatically inferred here
const indices: string[] = beforeResponse.body | |
const indices = beforeResponse.body |
src/commands/es/snapshots/restore.ts
Outdated
|
||
const response = await esClient.snapshot.restore(esRequest) | ||
|
||
const indicesAfterRestore = await this.getIndices(esClient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should call the method only one time and store the result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, i did that because i wasn't sure indices where put in open state after a restore leading to closed indice. but I checked in the doc
The restore operation must be performed on a functioning cluster. However, an existing index can be only restored if it’s closed and has the same number of shards as the index in the snapshot. The restore operation automatically opens restored indices if they were closed and creates new indices if they didn’t exist in the cluster.
So we can safely remove this call indeed.
src/commands/es/snapshots/restore.ts
Outdated
await esClient.indices.open({ index }) | ||
} | ||
|
||
this.logOk(`Success ${JSON.stringify(response.body)}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this. Can't we have a better message or at least an indented JSON?
tsconfig.json
Outdated
"strict": true, | ||
"target": "es2017", | ||
"esModuleInterop": true | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need this line anymore
src/commands/es/snapshots/dump.ts
Outdated
|
||
import { Kommand } from '../../../common' | ||
|
||
export default class ESDump extends Kommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking
export default class ESDump extends Kommand { | |
export default class EsSnapshotsDump extends Kommand { |
|
||
import { Kommand } from '../../../common' | ||
|
||
export default class EsCreateSnapshot extends Kommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking
export default class EsCreateSnapshot extends Kommand { | |
export default class EsSnapshotsCreateRepository extends Kommand { |
src/commands/es/snapshots/list.ts
Outdated
|
||
import { Kommand } from '../../../common' | ||
|
||
export default class ESlistSnapshot extends Kommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking
export default class ESlistSnapshot extends Kommand { | |
export default class EsSnapshotsList extends Kommand { |
src/commands/es/snapshots/restore.ts
Outdated
} | ||
|
||
const response = await esClient.snapshot.restore(esRequest) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to open the indices again and you should do that in a finally
block to ensure they don't stay closed
network.host: 0.0.0.0 | ||
|
||
# You need to create this folder in order to run snapshots | ||
path.repo: ["/tmp/snapshots"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is due to the fact that the value is an array. Could you try to use YAML objects for environment variables? Like this:
services:
kuzzle:
# ...
elasticsearch:
image: yourImage
environments:
path.repo:
- /tmp/snapshots
# ...
or using regular YAML array of string:
services:
kuzzle:
# ...
elasticsearch:
image: yourImage
environments:
- 'path.repo=["/tmp/snapshots"]'
# ...
network.host: 0.0.0.0 | ||
|
||
# You need to create this folder in order to run snapshots | ||
path.repo: ["/tmp/snapshots"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double quote in the second snippet are required for YAML parsing (#76 (comment))
src/commands/es/snapshots/dump.ts
Outdated
|
||
import { Kommand } from '../../../common' | ||
|
||
export default class EsSnapshotsDump extends Kommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should use the term "dump" in this module since they are not dumps but snapshots which is quite different
export default class EsSnapshotsDump extends Kommand { | |
export default class EsSnapshots extends Kommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the command should be called create
to follow ES terminology: https://www.elastic.co/guide/en/elasticsearch/reference/current/snapshot-restore.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a little confusing to just call it EsSnapshots
Since in this "snapshots" module we can create 2 types of thing
- Repository (the holder of snapshots)
- Snapshot (data)
I prefer option EsSnapshotsCreate
since we have an EsSnapshotsCreateRepository
@alexandrebouthinon wdyt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also, shall we rename the Kommand -> es:snapshots:create ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree with you for the naming, we might as well stick to the Elasticsearch documentation 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last nitpicking I'm sorry 😅
The commands should be under the name snapshot
and not snapshots
since that's the name of a "module"
# [0.17.0](https://github.com/kuzzleio/kourou/releases/tag/0.17.0) (2020-11-10) #### New features - [ [#76](#76) ] Add snapshots support ([rolljee](https://github.com/rolljee)) #### Enhancement - [ [#78](#78) ] Fix app:scaffold and improve api action hook help ([Aschen](https://github.com/Aschen)) ---
🎉 This PR is included in version 1.0.0-beta.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
What does this PR do?
This PR adds the snapshots module to kourou.
Close #70
How should this be manually tested?
git clone
npm install
./bin/run es:snapshots:<command> <args> --<flags>