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

controller: create storage configmap on reconcile #227

Merged
merged 1 commit into from
Aug 30, 2019

Conversation

danielerez
Copy link
Contributor

@danielerez danielerez commented Aug 20, 2019

Added a new ConfigMap for defining default values for
storage according to the following logic:

  • For a BareMetal infrastructure:
    • volumeMode: Block
    • accessMode: ReadWriteMany
  • For all other deployments:
    • volumeMode: File
    • accessMode: ReadWriteMany

@danielerez
Copy link
Contributor Author

@rthallisey @mareklibra @aglitke @awels @jelkosz @rollandf - please review

Copy link
Contributor

@mareklibra mareklibra left a comment

Choose a reason for hiding this comment

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

This patch is sort of hardcoding the defaults, no matter a ConfigMap is used.

Is automatic detection of StorageClass capabilities still in plan?
The ConfigMap should contain sc-specific defaults if these generic (Filesystem/RWM) can not be used (like for the local storage).

There is no way to hardcode the defaults right for a generic cluster, as recently implemented here.
If detection of SC capabilities will not land shortly, there should be a way how the administrator can change values in this ConfigMap. Via HCO configuration or manually while not-breaking the reconciliation logic.

docs/configmaps.md Outdated Show resolved Hide resolved
Namespace: namespace,
},
Data: map[string]string{
"accessMode": "ReadWriteMany",
Copy link
Contributor

Choose a reason for hiding this comment

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

With this set, no VM created by UI (Wizard) can be started when local SC is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, so I'll add also local-sc.accessMode and local-sc.volumeMode then.

@danielerez danielerez changed the title controller: create storage class configmap on reconcile controller: create storage configmap on reconcile Aug 20, 2019
docs/configmaps.md Outdated Show resolved Hide resolved
pkg/controller/hyperconverged/hyperconverged_controller.go Outdated Show resolved Hide resolved
@danielerez
Copy link
Contributor Author

This patch is sort of hardcoding the defaults, no matter a ConfigMap is used.

Is automatic detection of StorageClass capabilities still in plan?
The ConfigMap should contain sc-specific defaults if these generic (Filesystem/RWM) can not be used (like for the local storage).

There is no way to hardcode the defaults right for a generic cluster, as recently implemented here.
If detection of SC capabilities will not land shortly, there should be a way how the administrator can change values in this ConfigMap. Via HCO configuration or manually while not-breaking the reconciliation logic.

In 'ensureKubeVirtStorageConfig' func we create the ConfigMap only if doesn't exist, so admin should be able to modify it.

@danielerez danielerez force-pushed the storage-configmap branch 2 times, most recently from db8e437 to 86f8412 Compare August 20, 2019 21:31
@djzager
Copy link
Contributor

djzager commented Aug 21, 2019

I would rather the user set a RHHI or Baremetal flag instead of us auto detecting. You can add the flag here.

I'm curious @rthallisey why we are against auto detecting. Originally I would have thought we would want to auto detect where possible.

@danielerez danielerez force-pushed the storage-configmap branch 2 times, most recently from fe23e75 to 2cd7d8c Compare August 21, 2019 16:03
@rthallisey
Copy link

rthallisey commented Aug 21, 2019

I'm curious @rthallisey why we are against auto detecting. Originally I would have thought we would want to auto detect where possible.

My thinking is that I want to avoid having code that checks for OpenShift specific things in tree wherever possible. Having a flag for the user to set isn't too bad of a trade-off IMO.

@djzager
Copy link
Contributor

djzager commented Aug 22, 2019

My thinking is that I want to avoid having code that checks for OpenShift specific things in tree wherever possible. Having a flag for the user to set isn't too bad of a trade-off IMO.

Interesting, if I may offer a different perspective. I would suggest that "we", as the maintainers of the HCO, know best how to install all of the different KubeVirt components and the HyperConverged resource is our API. Every field in our HyperConverged's spec, we accept all of the supported values and support them -- consider a memcached-operator that accepts a version (but only 1, 2, 3, 4) then a user would expect to be able to put any of 1-4 in the spec.version (there could be issues where downgrades are not allowed but you get the idea).

In our current scenario, we have no way of supporting BareMetalPlatform on anything but a bare metal platform...so we would need to have some validation on that field before doing work anyway. We could simply detect the appropriate APIs before doing work without asking the user for anything...that would prevent the user from mucking around with fields and values that we never intend to support (like BareMetalPlatform: true on a non-baremetal cluster).

@danielerez
Copy link
Contributor Author

My thinking is that I want to avoid having code that checks for OpenShift specific things in tree wherever possible. Having a flag for the user to set isn't too bad of a trade-off IMO.

Interesting, if I may offer a different perspective. I would suggest that "we", as the maintainers of the HCO, know best how to install all of the different KubeVirt components and the HyperConverged resource is our API. Every field in our HyperConverged's spec, we accept all of the supported values and support them -- consider a memcached-operator that accepts a version (but only 1, 2, 3, 4) then a user would expect to be able to put any of 1-4 in the spec.version (there could be issues where downgrades are not allowed but you get the idea).

In our current scenario, we have no way of supporting BareMetalPlatform on anything but a bare metal platform...so we would need to have some validation on that field before doing work anyway. We could simply detect the appropriate APIs before doing work without asking the user for anything...that would prevent the user from mucking around with fields and values that we never intend to support (like BareMetalPlatform: true on a non-baremetal cluster).

@rthallisey So what's your take on that then? Should we keep the flag or revert to the previous solution (detect automatically by fetching the infrastructure's platform).

Data: map[string]string{
"accessMode": "ReadWriteMany",
"volumeMode": volumeMode,
"local-sc.accessMode": "ReadWriteOnce",
Copy link
Contributor

Choose a reason for hiding this comment

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

@danielerez , this assumes that the target cluster has a storage class called local-sc. It's up to cluster's admin how (s)he calls it and what particular SC is behind that name.

We can either

  • autodetect
  • or provide a way for manual intervention

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The admin can change it by modifying the ConfigMap (reconcile won't change it once already created). @rthallisey do we want to add the local class name to HyperConvergedSpec as well or is it too specific?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mareklibra @rthallisey Added 'LocalStorageClassName' key to HyperConverged spec, so it could be configured on deployment.

@rthallisey
Copy link

Interesting, if I may offer a different perspective. I would suggest that "we", as the maintainers of the HCO, know best how to install all of the different KubeVirt components and the HyperConverged resource is our API. Every field in our HyperConverged's spec, we accept all of the supported values and support them -- consider a memcached-operator that accepts a version (but only 1, 2, 3, 4) then a user would expect to be able to put any of 1-4 in the spec.version (there could be issues where downgrades are not allowed but you get the idea).

In our current scenario, we have no way of supporting BareMetalPlatform on anything but a bare metal platform...so we would need to have some validation on that field before doing work anyway. We could simply detect the appropriate APIs before doing work without asking the user for anything...that would prevent the user from mucking around with fields and values that we never intend to support (like BareMetalPlatform: true on a non-baremetal cluster).

I understand the argument of "we can detect the configuration so we should", but I'm concerned about the cost of this UX. If we consume an openshift API apiconfigv1.Infrastructure{}, I think it 1) limits our adoption in the community 2) opens the door to making more assumptions about the underlying platform. We are the HCO maintainers and we understand how to deliver the HCO, but we don't provision the cluster or the infra. I think we're reaching a little for a small gain in UX. For example, I could see infra detection like this added to the OCS operator because it is an infra-operator.

I do think there is an argument to be made about adding something to our API. Adding this option requires we support and CRD changes in the future. It is a True/False bool so I don't think it will be hard, but No API is the best API.

@rthallisey
Copy link

ci test please

@djzager
Copy link
Contributor

djzager commented Aug 27, 2019

I understand the argument of "we can detect the configuration so we should", but I'm concerned about the cost of this UX. If we consume an openshift API apiconfigv1.Infrastructure{}, I think it 1) limits our adoption in the community 2) opens the door to making more assumptions about the underlying platform.

I think we should only be attempting to consume APIs that are available. That is, if some API (like apiconfigv1.Infrastructure{}) is available, sure then use it or make some other decisions based on that information but I agree with you that we absolutely should not assume it's there (or require it). Consider the hypothetical scenario where we don't add a bunch of cluster networking components to a cluster but make decisions based on what is available...this to me seems like something we would want to be able to handle without exposing a new field on the HyperConverged resource.

I am in absolute agreement with you that we should not be making assumptions about the underlying platform or requiring some special OpenShift API, but I think it is correct for us to discover the APIs we want, handling their presence or absence and I don't believe this to be unique to what is now only OpenShift APIs (in the future I see it being some special API provided by another operator that we don't want to require).

@danielerez danielerez force-pushed the storage-configmap branch 7 times, most recently from 7194c83 to 21bd5db Compare August 27, 2019 20:55
@danielerez
Copy link
Contributor Author

/test hco-e2e-aws

@rthallisey
Copy link

/retest

@rthallisey
Copy link

@djzager and I talked offline. I'm advocating we don't include any openshift libraries or code. Specifically, that means nothing that ties us down to having to ask ourselves "if OpenShift, do this. Otherwise, do that". Having a flag with no validation is the safest way to do this, so we're going with a flag.

Copy link

@rthallisey rthallisey left a comment

Choose a reason for hiding this comment

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

One last nit then this LG2M

@@ -17,6 +17,12 @@ type HyperConvergedSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html

// BareMetalPlatform indicates whether the infrastructure is baremetal.
BareMetalPlatform bool `json:"BareMetalPlatform,omitempty"`

Choose a reason for hiding this comment

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

We should expose this flag on the HCO's CR by default. Add to the template CSV then run /hack/build-manifests.sh

--- a/templates/olm-catalog/kubevirt-hyperconverged/VERSION/kubevirt-hyperconverged-operator.VERSION.clusterserviceversion.yaml.in
+++ b/templates/olm-catalog/kubevirt-hyperconverged/VERSION/kubevirt-hyperconverged-operator.VERSION.clusterserviceversion.yaml.in
@@ -10,6 +10,9 @@ metadata:
           "metadata": {
             "name": "kubevirt-hyperconverged",
             "namespace": "kubevirt-hyperconverged"
+          },
+          "spec": {
+            "BareMetalPlatform": "false",
           }{{if .Converged}}
         },
         {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

BareMetalPlatform bool `json:"BareMetalPlatform,omitempty"`

// LocalStorageClassName the name of the local storage class.
LocalStorageClassName string `json:"LocalStorageClassName,omitempty"`

Choose a reason for hiding this comment

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

We'll leave LocalStorageClassName off the default CR. I think this string should be exposed primarily in the docs.

@rthallisey
Copy link

rthallisey commented Aug 28, 2019

@danielerez Let's try to get this in tomorrow.

Added a new ConfigMap for defining default values for
storage according to the following logic:

* For a BareMetal infrastructure:
- volumeMode: Block
- accessMode: ReadWriteMany
* For all other deployments:
- volumeMode: File
- accessMode: ReadWriteMany

Change-Id: Iea3cc601c66970c86ea21575c38db0487a18228f
Signed-off-by: Daniel Erez <derez@redhat.com>
@rthallisey rthallisey merged commit 132a898 into kubevirt:master Aug 30, 2019
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.

None yet

4 participants