Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Commit 0bb6d88

Browse files
authored
Create a support folder with diagnostics and reattach-pv (elastic#4246)
1 parent e317c8d commit 0bb6d88

File tree

10 files changed

+61
-59
lines changed

10 files changed

+61
-59
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ clean:
126126

127127
reattach-pv:
128128
# just check that reattach-pv still compiles
129-
go build -o /dev/null hack/reattach-pv/main.go
129+
go build -o /dev/null support/reattach-pv/main.go
130130

131131
compile-all:
132132
@ go build ./...

hack/diagnostics/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This resource has been moved to a [new location](../../support/diagnostics/) within the top level [support](../../support) folder.

hack/reattach-pv/README.md

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1 @@
1-
# Reattach-PV
2-
3-
This tool can be used to recreate an Elasticsearch cluster by reusing orphaned PersistentVolumes that used to belong to that cluster before it was deleted.
4-
5-
**Warning**: to be used at your own risk. This tool has not been tested extensively with multiple Kubernetes distributions and PersistentVolume providers. You should backup the data in the underlying storage system before attempting to use this tool. Also make sure you perform a dry-run first.
6-
7-
## Expectations
8-
9-
This tool can only be used when the following conditions are met:
10-
11-
* The Elasticsearch resource to re-create does not exist in Kubernetes.
12-
* All PersistentVolumeClaims of the previous cluster do not exist anymore.
13-
* All PersistentVolumes of the previous cluster still exist with the status `Released`.
14-
* The Elasticsearch resource to re-create has the exact same specs as the deleted one. Same cluster name, same node sets, same count, etc.
15-
* The current default kubectl context targets the desired Kubernetes cluster.
16-
17-
## Usage
18-
19-
```
20-
Recreate an Elasticsearch cluster by reattaching existing released PersistentVolumes
21-
22-
Usage:
23-
reattach-pv [flags]
24-
25-
Flags:
26-
--dry-run do not apply any Kubernetes resource change
27-
--elasticsearch-manifest string path pointing to the Elasticsearch yaml manifest
28-
-h, --help help for reattach-pv
29-
```
30-
31-
Example:
32-
33-
```
34-
# build the binary with a recent Go version
35-
go build
36-
# perform a dry run first
37-
./reattach-pv --elasticsearch-manifest elasticsearch.yml --dry-run
38-
# then, execute again without the dry-run flag
39-
./reattach-pv --elasticsearch-manifest elasticsearch.yml
40-
```
41-
42-
## How it works
43-
44-
This tool basically does the following:
45-
46-
* Ensure the Elasticsearch resource and the corresponding PersistentVolumeClaims do not exist in the APIServer.
47-
* Generate the list of PersistentVolumeClaims that would normally be created for this Elasticsearch cluster.
48-
* Retrieve the list of existing Released PersistentVolumes. Match their `claimRef` to the generated PersistentVolumeClaims, based on their name.
49-
* Create the expected PersistentVolumeClaims, with a status set to `Bound`.
50-
* Update the existing PersistentVolumes to reference the newly created PersistentVolumeClaims.
51-
* Create the Elasticsearch resource. The created PersistentVolumeClaims will automatically be used for the Elasticsearch Pods, since they have the correct name convention.
52-
53-
## Limitations
54-
55-
* PersistentVolumsClaims are not created the exact same way they would normally be created by the StatefulSet controller. Especially, they don't have the usual annotations and labels.
56-
* PersistentVolumeClaims are not created with an OwnerReference pointing to the Elasticsearch resource, because they are created before that resource. Therefore, they will not be automatically removed upon Elasticsearch resource deletion.
1+
This resource has been moved to a [new location](../../support/reattach-pv/) within the top level [support](../../support) folder.
File renamed without changes.

support/reattach-pv/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Reattach-PV
2+
3+
This tool can be used to recreate an Elasticsearch cluster by reusing orphaned PersistentVolumes that used to belong to that cluster before it was deleted.
4+
5+
**Warning**: to be used at your own risk. This tool has not been tested extensively with multiple Kubernetes distributions and PersistentVolume providers. You should backup the data in the underlying storage system before attempting to use this tool. Also make sure you perform a dry-run first.
6+
7+
## Expectations
8+
9+
This tool can only be used when the following conditions are met:
10+
11+
* The Elasticsearch resource to re-create does not exist in Kubernetes.
12+
* All PersistentVolumeClaims of the previous cluster do not exist anymore.
13+
* All PersistentVolumes of the previous cluster still exist with the status `Released`.
14+
* The Elasticsearch resource to re-create has the exact same specs as the deleted one. Same cluster name, same node sets, same count, etc.
15+
* The current default kubectl context targets the desired Kubernetes cluster.
16+
17+
## Usage
18+
19+
```
20+
Recreate an Elasticsearch cluster by reattaching existing released PersistentVolumes
21+
22+
Usage:
23+
reattach-pv [flags]
24+
25+
Flags:
26+
--dry-run do not apply any Kubernetes resource change
27+
--elasticsearch-manifest string path pointing to the Elasticsearch yaml manifest
28+
-h, --help help for reattach-pv
29+
```
30+
31+
Example:
32+
33+
```
34+
# build the binary with a recent Go version
35+
go build
36+
# perform a dry run first
37+
./reattach-pv --elasticsearch-manifest elasticsearch.yml --dry-run
38+
# then, execute again without the dry-run flag
39+
./reattach-pv --elasticsearch-manifest elasticsearch.yml
40+
```
41+
42+
## How it works
43+
44+
This tool basically does the following:
45+
46+
* Ensure the Elasticsearch resource and the corresponding PersistentVolumeClaims do not exist in the APIServer.
47+
* Generate the list of PersistentVolumeClaims that would normally be created for this Elasticsearch cluster.
48+
* Retrieve the list of existing Released PersistentVolumes. Match their `claimRef` to the generated PersistentVolumeClaims, based on their name.
49+
* Create the expected PersistentVolumeClaims, with a status set to `Bound`.
50+
* Update the existing PersistentVolumes to reference the newly created PersistentVolumeClaims.
51+
* Create the Elasticsearch resource. The created PersistentVolumeClaims will automatically be used for the Elasticsearch Pods, since they have the correct name convention.
52+
53+
## Limitations
54+
55+
* PersistentVolumsClaims are not created the exact same way they would normally be created by the StatefulSet controller. Especially, they don't have the usual annotations and labels.
56+
* PersistentVolumeClaims are not created with an OwnerReference pointing to the Elasticsearch resource, because they are created before that resource. Therefore, they will not be automatically removed upon Elasticsearch resource deletion.
File renamed without changes.

test/e2e/cmd/run/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,9 @@ func (h *helper) dumpEventLog() {
721721
func (h *helper) dumpK8sData() {
722722
operatorNs := h.testContext.Operator.Namespace
723723
managedNs := strings.Join(h.testContext.Operator.ManagedNamespaces, ",")
724-
cmd := exec.Command("hack/diagnostics/eck-dump.sh", "-N", operatorNs, "-n", managedNs, "-o", h.testContext.TestRun, "-z")
724+
cmd := exec.Command("support/diagnostics/eck-dump.sh", "-N", operatorNs, "-n", managedNs, "-o", h.testContext.TestRun, "-z")
725725
err := cmd.Run()
726726
if err != nil {
727-
log.Error(err, "Failed to run hack/diagnostics/eck-dump.sh")
727+
log.Error(err, "Failed to run support/diagnostics/eck-dump.sh")
728728
}
729729
}

0 commit comments

Comments
 (0)