-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add support for volumeAttributesClassName on persistent storage #11210
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
Closed
venkatesh2090
wants to merge
8
commits into
strimzi:main
from
venkatesh2090:add-support-for-volumeattributeclassname
Closed
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cf46f33
Add volumeAttributesClass and map to PVC
venkatesh2090 6ea010f
ignore volume attributes on storage diff
venkatesh2090 f2956c6
fix javadoc
venkatesh2090 9882466
Check if VACs have changed in diff
venkatesh2090 db66f4a
Null check before equals
venkatesh2090 56e1763
Address comments
venkatesh2090 ed4f241
Remove volumeAttributesClassChanged and add the field to ignorable paths
venkatesh2090 4edae04
Add storage with VAC to test param
venkatesh2090 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
import io.strimzi.operator.common.model.AbstractJsonDiff; | ||
|
||
import java.util.HashSet; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Collectors; | ||
|
@@ -36,6 +37,7 @@ public class StorageDiff extends AbstractJsonDiff { | |
private final boolean volumesAddedOrRemoved; | ||
private final boolean tooManyKRaftMetadataVolumes; | ||
private final boolean duplicateVolumeIds; | ||
private final boolean volumeAttributesClassChanged; | ||
|
||
/** | ||
* Diffs the storage for allowed or not allowed changes. Examples of allowed changes is increasing volume size or | ||
|
@@ -70,6 +72,7 @@ private StorageDiff(Reconciliation reconciliation, Storage current, Storage desi | |
boolean volumesAddedOrRemoved = false; | ||
boolean tooManyKRaftMetadataVolumes = false; | ||
boolean duplicateVolumeIds = false; | ||
boolean volumeAttributesClassChanged = false; | ||
|
||
if (current instanceof JbodStorage currentJbodStorage && desired instanceof JbodStorage desiredJbodStorage) { | ||
Set<Integer> volumeIds = new HashSet<>(); | ||
|
@@ -99,6 +102,7 @@ private StorageDiff(Reconciliation reconciliation, Storage current, Storage desi | |
changesType |= diff.changesType(); | ||
shrinkSize |= diff.shrinkSize(); | ||
isEmpty &= diff.isEmpty(); | ||
volumeAttributesClassChanged |= diff.volumeAttributesClassChanged(); | ||
} | ||
} else { | ||
JsonNode source = PATCH_MAPPER.valueToTree(current == null ? "{}" : current); | ||
|
@@ -115,16 +119,25 @@ private StorageDiff(Reconciliation reconciliation, Storage current, Storage desi | |
continue; | ||
} | ||
|
||
// It might be possible to increase the volume size, but never to shrink volumes | ||
// When size changes, we need to detect whether it is shrinking or increasing | ||
if (pathValue.endsWith("/size") && desired.getType().equals(current.getType()) && current instanceof PersistentClaimStorage persistentCurrent && desired instanceof PersistentClaimStorage persistentDesired) { | ||
if (current instanceof PersistentClaimStorage persistentCurrent && desired instanceof PersistentClaimStorage persistentDesired | ||
&& desired.getType().equals(current.getType())) { | ||
// It might be possible to increase the volume size, but never to shrink volumes | ||
// When size changes, we need to detect whether it is shrinking or increasing | ||
if (pathValue.endsWith("/size")) { | ||
|
||
long currentSize = StorageUtils.convertToMillibytes(persistentCurrent.getSize()); | ||
long desiredSize = StorageUtils.convertToMillibytes(persistentDesired.getSize()); | ||
long currentSize = StorageUtils.convertToMillibytes(persistentCurrent.getSize()); | ||
long desiredSize = StorageUtils.convertToMillibytes(persistentDesired.getSize()); | ||
|
||
if (currentSize > desiredSize) { | ||
shrinkSize = true; | ||
} else { | ||
if (currentSize > desiredSize) { | ||
shrinkSize = true; | ||
} else { | ||
continue; | ||
} | ||
} | ||
|
||
if (pathValue.endsWith("/volumeAttributesClass") && | ||
!Objects.equals(persistentCurrent.getVolumeAttributesClass(), persistentDesired.getVolumeAttributesClass())) { | ||
volumeAttributesClassChanged = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't here be check that it's really different in comparison current/desired? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. I didn't think about that. Will change |
||
continue; | ||
} | ||
} | ||
|
@@ -148,6 +161,7 @@ private StorageDiff(Reconciliation reconciliation, Storage current, Storage desi | |
this.volumesAddedOrRemoved = volumesAddedOrRemoved; | ||
this.tooManyKRaftMetadataVolumes = tooManyKRaftMetadataVolumes; | ||
this.duplicateVolumeIds = duplicateVolumeIds; | ||
this.volumeAttributesClassChanged = volumeAttributesClassChanged; | ||
} | ||
|
||
/** | ||
|
@@ -214,6 +228,15 @@ protected boolean shrinkSize() { | |
return shrinkSize; | ||
} | ||
|
||
/** | ||
* Returns true if there's a difference in {@code /volumeAttributesClass} | ||
* | ||
* @return true when the volumeAttributesClass changes | ||
*/ | ||
protected boolean volumeAttributesClassChanged() { | ||
return volumeAttributesClassChanged; | ||
} | ||
|
||
/** | ||
* Returns true if some JBOD volumes were added or removed | ||
* | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 really need to know it changed? Isn't it sufficient to ignore the change? We do not seem to use this anywhere in the production code.
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.
Yeah. It is only being used in tests. Can remove it and the related tests. I'll just add some
KafkaAssemblyOperator
tests as wellThere 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.
I think the tests for the StorageDiff can just test that it does not report any issues when the volume class atrributes change, or?
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.
Oh right... Didn't think this through before replying. Thanks