Skip to content

Conversation

@adoroszlai
Copy link
Contributor

What changes were proposed in this pull request?

Allow rewriting a key via CLI:

  1. with new content via ozone sh key put --expectedGeneration ... command. Generation value needs to be supplied manually.
  2. with existing content via ozone sh key rewrite command. Generation is used from current version of the key. Replication can be specified via usual options. If omitted, replication is toggled between RATIS/3 and EC/3,2 (this is intended as a temporary behavior for easier testing.)

https://issues.apache.org/jira/browse/HDDS-10872

How was this patch tested?

$ ozone sh volume create /vol1
$ ozone sh bucket create --layout OBJECT_STORE /vol1/obs
$ k=/vol1/obs/key
$ ozone sh key put $k share/ozone/lib/rocksdbjni-7.7.3.jar

$ ozone sh key put --expectedGeneration 555 $k share/ozone/lib/rocksdbjni-7.7.3.jar
KEY_NOT_FOUND Generation mismatch during expected rewrite

$ ozone sh key put --expectedGeneration $(ozone sh key info $k | jq -r '.generation') $k /etc/passwd
$ ozone sh key info $k | jq -r '.generation'
15

$ ozone sh key put --expectedGeneration $(ozone sh key info $k | jq -r '.generation') $k share/ozone/lib/rocksdbjni-7.7.3.jar
$ ozone sh key info $k | jq -r '.generation'
21

$ ozone sh key put --expectedGeneration $(ozone sh key info $k | jq -r '.generation') $k /etc/passwd
$ ozone sh key info $k | jq -r '.generation'
25

$ ozone sh key rewrite $k 
$ ozone sh key info $k | jq -r '.generation'
29

$ ozone sh key rewrite $k 
$ ozone sh key info $k | jq -r '.generation'
33

$ ozone sh key rewrite --type EC --replication rs-3-2-1024k $k 
$ ozone sh key rewrite --type EC --replication rs-3-2-1024k $k 
Replication unchanged: EC{rs-3-2-1024k}

$ ozone sh key put --expectedGeneration 555 /vol1/obs/no-such-key share/ozone/lib/rocksdbjni-7.7.3.jar
KEY_NOT_FOUND Key not found during expected rewrite

@adoroszlai adoroszlai self-assigned this May 17, 2024
Copy link
Contributor

@sodonnel sodonnel left a comment

Choose a reason for hiding this comment

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

This is a nice addition that will help with debugging and testing.

@adoroszlai adoroszlai merged commit 771c418 into apache:HDDS-10656-atomic-key-overwrite May 18, 2024
@adoroszlai
Copy link
Contributor Author

Thanks @sodonnel for the review.

@adoroszlai adoroszlai deleted the HDDS-10872 branch May 18, 2024 13:05
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