Skip to content

Commit c49b6cc

Browse files
authored
Add CLI DR restore command for online mode (#571)
1 parent 1cfab18 commit c49b6cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1517
-114
lines changed

.github/actions/e2e/action.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ inputs:
1010
snapshot-license-id:
1111
description: 'snapshot-enabled license id to use for e2e tests'
1212
required: true
13+
snapshot-license:
14+
description: 'snapshot-enabled license (b64) to use for e2e tests'
15+
required: true
1316
license-id:
1417
description: 'license id to use for e2e tests'
1518
required: true
@@ -22,6 +25,12 @@ inputs:
2225
testim-branch:
2326
description: 'testim branch'
2427
required: true
28+
dr-aws-access-key-id:
29+
description: 'Disaster Recovery AWS Access Key ID'
30+
required: true
31+
dr-aws-secret-access-key:
32+
description: 'Disaster Recovery AWS Secret Access Key'
33+
required: true
2534

2635
runs:
2736
using: composite
@@ -80,8 +89,15 @@ runs:
8089
export AIRGAP_LICENSE_ID=${{ inputs.airgap-license-id }}
8190
export SNAPSHOT_LICENSE_ID=${{ inputs.snapshot-license-id }}
8291
echo "${{ inputs.license }}" | base64 --decode > e2e/license.yaml
92+
echo "${{ inputs.snapshot-license }}" | base64 --decode > e2e/snapshot-license.yaml
8393
export TESTIM_ACCESS_TOKEN=${{ inputs.testim-access-token }}
8494
export TESTIM_BRANCH=${{ inputs.testim-branch }}
95+
export DR_AWS_S3_ENDPOINT=https://s3.amazonaws.com
96+
export DR_AWS_S3_REGION=us-east-1
97+
export DR_AWS_S3_BUCKET=kots-testim-snapshots
98+
export DR_AWS_S3_PREFIX=${{ inputs.test-name }}-${{ github.run_id }}
99+
export DR_AWS_ACCESS_KEY_ID=${{ inputs.dr-aws-access-key-id }}
100+
export DR_AWS_SECRET_ACCESS_KEY=${{ inputs.dr-aws-secret-access-key }}
85101
make e2e-test TEST_NAME=${{ inputs.test-name }}
86102
- name: Upload Host Support Bundle
87103
uses: actions/upload-artifact@v4
@@ -95,6 +111,29 @@ runs:
95111
with:
96112
name: ${{ github.job }}-support-bundle-cluster.tar.gz
97113
path: ./e2e/support-bundle-cluster.tar.gz
114+
- name: Upload Playwright Report
115+
id: upload-playwright-report
116+
uses: actions/upload-artifact@v4
117+
if: ${{ failure() }}
118+
with:
119+
name: ${{ github.job }}-playwright-report.tar.gz
120+
path: ./e2e/playwright-report.tar.gz
121+
- name: Print instructions to view Playwright report
122+
if: ${{ failure() && steps.upload-playwright-report.outputs.artifact-url != '' }}
123+
run: |
124+
echo -e "\e[1;33m┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐\e[0m"
125+
echo -e "\e[1;33m To view the Playwright test report: \e[0m"
126+
echo -e "\e[1;33m \e[0m"
127+
echo -e "\e[1;33m 1- Download & extract the report from: \e[0m"
128+
echo -e "\e[1;33m \e[0m"
129+
echo -e "\e[1;34m ${{ steps.upload-playwright-report.outputs.artifact-url }} \e[0m"
130+
echo -e "\e[1;33m \e[0m"
131+
echo -e "\e[1;33m 2- From inside the extracted directory, run: \e[0m"
132+
echo -e "\e[1;33m \e[0m"
133+
echo -e "\e[1;32m npx playwright show-report . \e[0m"
134+
echo -e "\e[1;33m \e[0m"
135+
echo -e "\e[1;33m└──────────────────────────────────────────────────────────────────────────────────────────────────────┘\e[0m"
136+
shell: bash
98137
# - name: Setup upterm session (ssh)
99138
# uses: lhotari/action-upterm@v1
100139
# if: always()

.github/workflows/pull-request.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ jobs:
186186
- TestSingleNodeAirgapUpgradeUbuntuJammy
187187
- TestInstallSnapshotFromReplicatedApp
188188
- TestMultiNodeAirgapUpgradeUbuntuJammy
189+
- TestSingleNodeDisasterRecovery
189190
steps:
190191
- name: Checkout
191192
uses: actions/checkout@v4
@@ -200,11 +201,13 @@ jobs:
200201
test-name: '${{ matrix.tests }}'
201202
airgap-license-id: ${{ secrets.STAGING_EMBEDDED_CLUSTER_AIRGAP_LICENSE_ID }}
202203
snapshot-license-id: ${{ secrets.STAGING_EMBEDDED_CLUSTER_SNAPSHOT_LICENSE_ID }}
204+
snapshot-license: ${{ secrets.STAGING_EMBEDDED_CLUSTER_SNAPSHOT_LICENSE }}
203205
license-id: ${{ secrets.STAGING_EMBEDDED_CLUSTER_LICENSE_ID }}
204206
license: ${{ secrets.STAGING_EMBEDDED_CLUSTER_LICENSE }}
205207
testim-access-token: ${{ secrets.TESTIM_ACCESS_TOKEN }}
206208
testim-branch: ${{ github.head_ref == 'main' && 'master' || github.head_ref }}
207-
209+
dr-aws-access-key-id: ${{ secrets.TESTIM_AWS_ACCESS_KEY_ID }}
210+
dr-aws-secret-access-key: ${{ secrets.TESTIM_AWS_SECRET_ACCESS_KEY }}
208211

209212
# this job will validate that all the tests passed
210213
# it is used for the github branch protection rule

.github/workflows/release-dev.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ jobs:
139139
- TestSingleNodeAirgapUpgradeUbuntuJammy
140140
- TestInstallSnapshotFromReplicatedApp
141141
- TestMultiNodeAirgapUpgradeUbuntuJammy
142+
- TestSingleNodeDisasterRecovery
142143
steps:
143144
- name: Checkout
144145
uses: actions/checkout@v4
@@ -152,7 +153,10 @@ jobs:
152153
test-name: '${{ matrix.tests }}'
153154
airgap-license-id: ${{ secrets.STAGING_EMBEDDED_CLUSTER_AIRGAP_LICENSE_ID }}
154155
snapshot-license-id: ${{ secrets.STAGING_EMBEDDED_CLUSTER_SNAPSHOT_LICENSE_ID }}
156+
snapshot-license: ${{ secrets.STAGING_EMBEDDED_CLUSTER_SNAPSHOT_LICENSE }}
155157
license-id: ${{ secrets.STAGING_EMBEDDED_CLUSTER_LICENSE_ID }}
156158
license: ${{ secrets.STAGING_EMBEDDED_CLUSTER_LICENSE }}
157159
testim-access-token: ${{ secrets.TESTIM_ACCESS_TOKEN }}
158160
testim-branch: 'master'
161+
dr-aws-access-key-id: ${{ secrets.TESTIM_AWS_ACCESS_KEY_ID }}
162+
dr-aws-secret-access-key: ${{ secrets.TESTIM_AWS_SECRET_ACCESS_KEY }}

cmd/embedded-cluster/install.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/replicatedhq/embedded-cluster/pkg/prompts"
2323
"github.com/replicatedhq/embedded-cluster/pkg/release"
2424
"github.com/replicatedhq/embedded-cluster/pkg/spinner"
25+
"github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
2526
)
2627

2728
// ErrNothingElseToAdd is an error returned when there is nothing else to add to the
@@ -92,14 +93,18 @@ func runPostInstall() error {
9293
return installAndEnableLocalArtifactMirror()
9394
}
9495

95-
// runHostPreflights run the host preflights we found embedded in the binary
96+
// RunHostPreflights runs the host preflights we found embedded in the binary
9697
// on all configured hosts. We attempt to read HostPreflights from all the
9798
// embedded Helm Charts and from the Kots Application Release files.
98-
func runHostPreflights(c *cli.Context) error {
99+
func RunHostPreflights(c *cli.Context) error {
99100
hpf, err := addons.NewApplier().HostPreflights()
100101
if err != nil {
101102
return fmt.Errorf("unable to read host preflights: %w", err)
102103
}
104+
return runHostPreflights(c, hpf)
105+
}
106+
107+
func runHostPreflights(c *cli.Context, hpf *v1beta2.HostPreflightSpec) error {
103108
if len(hpf.Collectors) == 0 && len(hpf.Analyzers) == 0 {
104109
return nil
105110
}
@@ -468,7 +473,7 @@ var installCommand = &cli.Command{
468473
return err
469474
}
470475
logrus.Debugf("running host preflights")
471-
if err := runHostPreflights(c); err != nil {
476+
if err := RunHostPreflights(c); err != nil {
472477
err := fmt.Errorf("unable to finish preflight checks: %w", err)
473478
metrics.ReportApplyFinished(c, err)
474479
return err

cmd/embedded-cluster/join.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ var joinCommand = &cli.Command{
152152
return err
153153
}
154154

155-
if err := runHostPreflights(c); err != nil {
155+
if err := RunHostPreflights(c); err != nil {
156156
err := fmt.Errorf("unable to run host preflights locally: %w", err)
157157
metrics.ReportJoinFailed(c.Context, jcmd.MetricsBaseURL, jcmd.ClusterID, err)
158158
return err

cmd/embedded-cluster/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func main() {
3535
resetCommand,
3636
materializeCommand,
3737
updateCommand,
38+
restoreCommand,
3839
},
3940
}
4041
if err := app.RunContext(ctx, os.Args); err != nil {

0 commit comments

Comments
 (0)