-
Notifications
You must be signed in to change notification settings - Fork 30
Conversation
If disk size is < 1 Gi in the Storage Tab of CreateVmWizard, the value is reformatted and appended by a lower matching unit. Corresponding PVC is created with a value conforming the format required by Kubernetes.
781ccc1
to
5c5dc94
Compare
Pull Request Test Coverage Report for Build 1858
💛 - Coveralls |
@andybraren , any idea how to better present disk sizes of different units? In most cases, the size in GiB is ok. Anyway, in v2v flow, the disks can be smaller, like 1 KiB. |
@@ -428,6 +430,7 @@ export class StorageTab extends React.Component { | |||
type: POSITIVE_NUMBER, | |||
} | |||
: null, | |||
readValueFormatter: value => (value < 1 ? getValidK8SSize(value, this.props.units, 'Gi', false) : value), |
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.
it probably makes more sense to have this inside the renderConfig
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.
This will be inconstent for ediable fields (showing one size and seeing something different when editing the filed).
the inconsistencies could be resolved for now if we allow this only for STORAGE_TYPE_EXTERNAL_V2V_TEMP
, STORAGE_TYPE_EXTERNAL_V2V_VDDK
types and explicitely say it should not be editable in the 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.
For v2v, it's not editable already.
For other flows, the user is not allowed to enter floating point number to disk size, so effectively the formatting is used in the single relevant case only.
If something, we should handle just the STORAGE_TYPE_EXTERNAL_IMPORT
case, not the two mentioned.
Recently, component edit mode is disabled when renderConfig
is missing. Changing that semantic would lead to further refactoring which I do not think is needed.
IMO, sort of functional readValueFormatter
is good enough. In a follow-up (out of bug-fixing scope) we can merge it with the static addendum
if really needed.
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.
For v2v, it's not editable already
I know, but it could be confusing for someone who looks at this in the future
For other flows, the user is not allowed to enter floating point number to disk size, so effectively the formatting is used in the single relevant case only.
The user can have have templates with custom sizes, that would break this.
If something, we should handle just the STORAGE_TYPE_EXTERNAL_IMPORT case, not the two mentioned.
Recently, component edit mode is disabled when renderConfig is missing. Changing that semantic would lead to further refactoring which I do not think is needed.
IMO, sort of functional readValueFormatter is good enough. In a follow-up (out of bug-fixing scope) we can merge it with the static addendum if really needed.
You are right - I forgot about that one.
So it probably should be (STORAGE_TYPE_EXTERNAL_V2V_TEMP
, STORAGE_TYPE_EXTERNAL_IMPORT
), because there is fixed size for both of them.
We could switch the behaviour in readValueFormatter if one of these two types is detected:
Or rename renderConfig
to renderEditConfig
and create renderValueConfig
for more generic approach. This could be a TODO.
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.
Considering the design suggestion bellow and what is stated here, I have added renderValueConfig
, so far containing just single formatter
optional prop.
Semantics of the renderConfig()
is unchanged but renamed to renderEditConfig()
.
Size-cells of listed storage types contain always unit.
There's a gap in edit-mode - the unit is not rendered. But the user can get this information within the read-mode. Will be improved when moved to PF4 tables.
src/k8s/objects/pvc/pvc.js
Outdated
@@ -12,7 +13,7 @@ export const buildPvc = ({ generateName, namespace, storageType, size, storageCl | |||
volumeMode: 'Filesystem', | |||
resources: { | |||
requests: { | |||
storage: `${size}Gi`, | |||
storage: getValidK8SSize(size, units, 'Gi', true), |
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.
this is overly complicated IMO. I think we should pass the size here with the unit already or pass just the bytes.
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.
We can't hardcode to Gi here since i.e. size equal to 1KiB does not match the required pattern.
We can either convert to a reasonable unit or use bytes in all cases.
As I already use this conversion for rendering, I think it's nice to keep it here as well. Just for better readability and debugging of the result. But I do not strongly insist on keeping it, just like it.
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.
src/k8s/objects/pvc/pvc.js
should be pretty generic. I would rather send size
and unit
from above to here.
And would rather include the conversion here in src/k8s/requests/v2v/importVmware.js
:
const extImportPvcsPromises = storages.filter(isImportStorage).map(storage =>
k8sCreate(
PersistentVolumeClaimModel,
buildPvc({
...storage,
generateName: storage.name,
name: undefined,
namespace,
units,
})
)
);
where it is clear because of the import storage type
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.
ok, moved one layer up
if (!editable && readValueFormatter) { | ||
result = readValueFormatter(result); | ||
} | ||
|
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.
I would rather implement this with addendum approach or combine these approaches altogether (addendum with functional approach). So we don't have two approaches for the similar thing.
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.
Right, it's very similar, the formatter can just do more things than just appending a string.
For flexibility, I am more for the functional approach but refactoring of the addendum
is not feasible for the 2.0.0 scope. Can be done 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.
If implemented using static addendum, the logic would need to be moved to a higher level while affecting other flows and so potentially introducing new bugs. So I decided to go this safer way.
One more idea: we can keep using addendum as it is and optionally assigning a function to it (instead of recent string). The EdditableDraggableTable
would check it's type and act accordingly. But such reusing of single property for two different types introduces more confusion, imo.
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.
Ok, we can leave this for later. Can you please create an issue to unify these two approaches?
Yes better to rewrite it without any magic and use just the functional approach.
src/k8s/request.js
Outdated
k8sCreate, | ||
k8sPatch, | ||
}, | ||
units |
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.
can we pass this as a object for better enhancement. { units }
?
I guess we should have begin with the object parameters to begin with (maybe TODO for refactoring?).
Only this have to be left the same (because of future possibility of passing EnhancedK8sMethods
):
{
k8sCreate,
k8sPatch,
}
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.
Good idea, will do it.
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.
done
@@ -38,6 +38,8 @@ export const startV2VVMWareController = async ({ namespace }, { k8sGet, k8sCreat | |||
: 'V2V VMWare controller deployment not found, so creating one ...' | |||
); | |||
|
|||
// TODO: do not fail if i.e. ServiceAccount already exists | |||
// TODO: notify user if deployment fails |
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.
sidenote: this should be pretty easy to do with the new VM dialog refactoring
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.
Good to know.
I think its a "nice to have" even for 2.0.0 which will not contain the refactoring.
Anyway, it's of lower priority since there is a workaround possible (by deleting role, rolebinding and the service account).
613964b
to
bfb5eac
Compare
@mareklibra Here's a rough mockup of one idea that attaches a unit dropdown to the text field. The dropdown would default to This combined field is used when creating a PVC in the Console - maybe some of that code could be reused? Here's an old screenshot I took from OpenShift Console #1209 (ignore the incorrect units) that shows the combined field in action: |
We are planning to do something like this, but this will be much easier once we convert to pf4 tables - so I think it is postponed until then.
this piece is not really reusable currently - we can work on that once we get merged into |
+1 this sounds reasonable |
Yes, thanks |
To be consistent with the newly introduced `rederValueConfig()`
Let's keep using "Gi" as the base unit. In a later version, we will implement proper unit-selector.
If disk size < 1 Gi in the Storage Tab of CreateVmWizard,
the value is reformatted and appended by a lower matching unit.
Corresponding PVC is created with a value conforming the format
required by Kubernetes.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1708195