-
Notifications
You must be signed in to change notification settings - Fork 590
HDDS-7526. Avoid overwriting replication config on existing bucket when quota is set #4013
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
Conversation
…en quota is set. Fixed checkstyle error.
…en quota is set. Fixed checkstyle error.
aswinshakil
left a 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.
Thanks for working on this @SaketaChalamchala I have a minor comment inline.
| if (defaultReplicationConfig != null) { | ||
| // Resetting the default replication config. | ||
| bucketInfoBuilder.setDefaultReplicationConfig(defaultReplicationConfig); | ||
| } else { |
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.
Nit: We can change this to else if statement.
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.
Thanks for the review @aswinshakil . Addressed the comment.
aswinshakil
left a 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.
| * Returns true if defaultReplicationConfig has been set | ||
| * to a non default value. | ||
| */ | ||
| public boolean hasDefaultReplicationConfig() { |
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.
Do we actually need this method in this case? In #3975 the problem was a little different. The values there were longs, which in Java cannot be null and default to zero. Therefore it was impossible to tell if zero was passed or it was just the default value. The value here is an object and can be null, so maybe its enought to check it for non null?
In OMBucketSetProperty, we have:
if (defaultReplicationConfig != null) {
// Resetting the default replication config.
bucketInfoBuilder.setDefaultReplicationConfig(defaultReplicationConfig);
} else if (dbBucketInfo.getDefaultReplicationConfig() != null) {
// Retaining existing default replication config
bucketInfoBuilder.setDefaultReplicationConfig(
dbBucketInfo.getDefaultReplicationConfig());
}
So we don't use this method there.
One thing that comes to mind - is it possible to remove a default rep config from a bucket, so it would then use the server default? Would we be able to? Is it a valid thing to be able to do?
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.
Thanks for the review @sodonnel. You're right, hasDefaultReplicationConfig() is not needed in OmBucketArgs. BucketArgs object already has a hasDefaultReplicationConfig() that we can use to indicate if the replication config is set.
If the replication config needs to be "reset" i.e., removed from bucket args, would it make sense to reuse null default replication config to indicate both "to retain existing replication config" and "to reset to server default"? Would another non null indicator be useful make the distinction?
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.
If we use null for "don't overwrite" and also "clear" I am not sure how we can make the distinction.
To clear the replicationConfig, I think you will need:
- A new parameter on OMBucketArgs - reset or clearReplicationConfig
- Adjust RpcClient.setReplicationConfig, so that if a null ReplicationConfig is passed into it, it sets the new flag on OMBucketArgs.
- Handle the new flag in the code where it saves the bucket args.
- Change SetReplicationConfigHandler to either accept a "--reset" flag to indicate it need to clear the repConfig, or a new handler ResetReplicationConfigHandler to do the same, passing a null as ReplicationConfig to
bucket.setReplicationConfig(...)
We can be fairly sure someone will come asking to clear the replicationConfig on a bucket some day, so it would be good to fix this. However I would do it in another Jira than this one, as I think this one is good now.
What changes were proposed in this pull request?
Setting Quotas on an existing bucket overwrites the replication config to RATIS ONE. These are the first options for ReplicationType & ReplicationFactor enums in hdds.proto which are picked up by default.
Proposed change is similar to #3975 . Add
hasDefaultReplicationConfigin OmBucketArgs.java to indicate if Replication Config is passed by the client. If not, avoid setting replication config in protobuf fields.if replication config is not explicitly passed, retain replication config of existing bucket when setting bucket properties in OMBucketSetPropertyRequest.java
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-7526
How was this patch tested?
Added Unit Tests to verify that Replication Config is set correctly in OmBucketArgs and that existing default/non-default replication config is retained when replication config is not set explicitly by the client