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

[CHEF-11758] Add support for config verification of backup in HA restore command #8661

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rensycthomas
Copy link
Collaborator

@rensycthomas rensycthomas commented Nov 26, 2024

🔩 Description:

Add support for config verification of backup in HA restore command

Jira ID - https://progresssoftware.atlassian.net/browse/CHEF-11758

⛓️ Related Resources

👍 Definition of Done

👟 How to Build and Test the Change

✅ Checklist

All PRs must tick these:

With occasional exceptions, all PRs from Progress employees must tick these:

  • Is the code clear? (complicated code or lots of comments--subdivide and use well-named methods, meaningful variable names, etc.)
  • Consistency checked? (user notifications, user prompts, visual patterns, code patterns, variable names)
  • Repeated code blocks eliminated? (adapt and reuse existing components, blocks, functions, etc.)
  • Spelling, grammar, typos checked? (at a minimum use make spell in any component directory)
  • Code well-formatted? (indents, line breaks, etc. improve rather than hinder readability)

All PRs from Progress employees should tick these if appropriate:

  • Tests added/updated? (all new code needs new tests)
  • Docs added/updated? (all customer-facing changes)

Please add a note next to any checkbox above if you are NOT ticking it.

📷 Screenshots, if applicable

  1. Error message when backup path in automate node does not match with the backup path configured in opensearch node
    Fs_Automate_Opensearch_Error

  2. Error message when backup path in automate node does not match with the indices of snapshots
    Fs_Automate_Snapshots_Error

  3. Error message when indices of all the snapshots are not the same
    S3_Snapshot_Indices_Error

  4. Success message
    Success

Copy link

netlify bot commented Nov 26, 2024

👷 Deploy Preview for chef-automate processing.

Name Link
🔨 Latest commit 6c05d6f
🔍 Latest deploy log https://app.netlify.com/sites/chef-automate/deploys/67519a594b819c00086f8e64

@rensycthomas rensycthomas changed the title Add support for config verification of backup in HA restore command [CHEF-11758] Add support for config verification of backup in HA restore command Nov 26, 2024
@rensycthomas rensycthomas force-pushed the rt/CHEF-11758_verify_restore_config branch 2 times, most recently from 220baac to b9d365f Compare November 26, 2024 16:02
Comment on lines 1521 to 1527
if osSnapshot.Es6Compliance.Type == backupLocation && osSnapshot.Es6Erchef.Type == backupLocation && osSnapshot.Es6EventFeed.Type == backupLocation && osSnapshot.Es6Ingest.Type == backupLocation {
complianceServicePath = getSnapshotPathDetails(osSnapshot.Es6Compliance.Settings.Location)
erchefServicePath = getSnapshotPathDetails(osSnapshot.Es6Erchef.Settings.Location)
eventFeedServicePath = getSnapshotPathDetails(osSnapshot.Es6EventFeed.Settings.Location)
ingestServicePath = getSnapshotPathDetails(osSnapshot.Es6Ingest.Settings.Location)
if complianceServicePath == erchefServicePath && erchefServicePath == eventFeedServicePath && erchefServicePath == ingestServicePath {
allowRestore = true
snapshotEs6ServicePath = complianceServicePath
}
} else {
err := fmt.Errorf("discrepancy in the backup types. Backup path of all indices should be %s. Refer `https://docs.chef.io/automate/ha_backup_restore_file_system/#troubleshooting` to do a clean up of the snapshot repo", backupLocation)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This piece of code is repeated and probably can be made common in the conditions

}

func getSnapshotPathDetails(snapshotPath string) string {
parts := strings.Split(snapshotPath, "/automate-elasticsearch-data")
Copy link
Collaborator

@vivekshankar1 vivekshankar1 Dec 4, 2024

Choose a reason for hiding this comment

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

please handle the situation here if lets say parts length is zero

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

path := ""
switch backupLocation {
case "fs":
if ele.Global.V1.External.Opensearch.Backup.Fs != nil &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you handle here and below conditions if ele.Global.V1.External and ele.Global.V1.External.Opensearch and ele.Global.V1.External.Opensearch.Backup is not nil

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@rensycthomas rensycthomas force-pushed the rt/CHEF-11758_verify_restore_config branch from 522b500 to 6c05d6f Compare December 5, 2024 12:19

Quality Gate failed Quality Gate failed

Failed conditions
6 New issues
11.3% Coverage on New Code (required ≥ 80%)
15.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants