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

APPS-1268 Validate backup/restore namespace exists #244

Open
wants to merge 4 commits into
base: v2
Choose a base branch
from

Conversation

korotkov-aerospike
Copy link
Contributor

No description provided.

@korotkov-aerospike korotkov-aerospike marked this pull request as ready for review October 23, 2024 11:07
return nil, err
}
if !ok {
return nil, fmt.Errorf("cluster does not have all require namespace")
Copy link
Member

Choose a reason for hiding this comment

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

return nil, fmt.Errorf("cluster does not have the namespace %s configured", namespace)

@@ -33,6 +33,14 @@ func (b *BackupGo) BackupRun(
namespace string,
path string,
) (BackupHandler, error) {
ok, err := clusterHasRequiredNamespace(namespace, client.AerospikeClient())
Copy link
Member

Choose a reason for hiding this comment

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

Won't it be better to validate the namespace either at startup or when modified using an API endpoint?

@@ -16,6 +16,22 @@ import (

const namespaceInfo = "namespaces"

// clusterHasRequiredNamespace checks if given namespace exists in cluster.
func clusterHasRequiredNamespace(namespace string, client backup.AerospikeClient) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Did you consider verifying the namespace on a restore operation?

@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 18.18182% with 36 lines in your changes missing coverage. Please review.

Project coverage is 27.37%. Comparing base (f35916d) to head (5b58800).

Files with missing lines Patch % Lines
pkg/service/restore_data.go 11.11% 14 Missing and 2 partials ⚠️
pkg/util/utils.go 0.00% 12 Missing ⚠️
pkg/dto/backup_routine.go 40.00% 2 Missing and 1 partial ⚠️
pkg/dto/config.go 57.14% 2 Missing and 1 partial ⚠️
pkg/service/config_applier.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2     #244      +/-   ##
==========================================
- Coverage   27.75%   27.37%   -0.39%     
==========================================
  Files          39       39              
  Lines        2104     2137      +33     
==========================================
+ Hits          584      585       +1     
- Misses       1437     1465      +28     
- Partials       83       87       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@korotkov-aerospike
Copy link
Contributor Author

I've introduced nsValidator component that does the info request and validates namespaces.
If aerospike is unavailable, validation is skipped.
I do it when the config is updated, or routine or cluster. It had added a bit of complexity, but I think it's worth it.

@korotkov-aerospike korotkov-aerospike changed the title APPS-1268 Validate namespace exists before backup APPS-1268 Validate backup/restore namespace exists Oct 23, 2024
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.

3 participants