-
Notifications
You must be signed in to change notification settings - Fork 66
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
Reflect the VM statuses to the KubeVirtCluster status #272
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,22 +22,13 @@ import ( | |
"regexp" | ||
"time" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/builder" | ||
|
||
"github.com/pkg/errors" | ||
"gopkg.in/yaml.v3" | ||
corev1 "k8s.io/api/core/v1" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
utilerrors "k8s.io/apimachinery/pkg/util/errors" | ||
infrav1 "sigs.k8s.io/cluster-api-provider-kubevirt/api/v1alpha1" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/context" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/infracluster" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/kubevirt" | ||
kubevirthandler "sigs.k8s.io/cluster-api-provider-kubevirt/pkg/kubevirt" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/ssh" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/workloadcluster" | ||
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
capierrors "sigs.k8s.io/cluster-api/errors" | ||
"sigs.k8s.io/cluster-api/util" | ||
|
@@ -46,10 +37,19 @@ import ( | |
"sigs.k8s.io/cluster-api/util/patch" | ||
"sigs.k8s.io/cluster-api/util/predicates" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/builder" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/controller" | ||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
"sigs.k8s.io/controller-runtime/pkg/handler" | ||
|
||
infrav1 "sigs.k8s.io/cluster-api-provider-kubevirt/api/v1alpha1" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/context" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/infracluster" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/kubevirt" | ||
kubevirthandler "sigs.k8s.io/cluster-api-provider-kubevirt/pkg/kubevirt" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/ssh" | ||
"sigs.k8s.io/cluster-api-provider-kubevirt/pkg/workloadcluster" | ||
) | ||
|
||
// KubevirtMachineReconciler reconciles a KubevirtMachine object. | ||
|
@@ -66,6 +66,7 @@ type KubevirtMachineReconciler struct { | |
// +kubebuilder:rbac:groups="",resources=secrets;,verbs=get;list;watch;create;update;patch;delete | ||
// +kubebuilder:rbac:groups=kubevirt.io,resources=virtualmachines;,verbs=get;create;update;patch;delete | ||
// +kubebuilder:rbac:groups=kubevirt.io,resources=virtualmachineinstances;,verbs=get;delete | ||
// +kubebuilder:rbac:groups=cdi.kubevirt.io,resources=datavolumes;,verbs=get;list;watch | ||
|
||
// Reconcile handles KubevirtMachine events. | ||
func (r *KubevirtMachineReconciler) Reconcile(goctx gocontext.Context, req ctrl.Request) (_ ctrl.Result, rerr error) { | ||
|
@@ -277,6 +278,9 @@ func (r *KubevirtMachineReconciler) reconcileNormal(ctx *context.MachineContext) | |
// Mark VMProvisionedCondition to indicate that the VM has successfully started | ||
conditions.MarkTrue(ctx.KubevirtMachine, infrav1.VMProvisionedCondition) | ||
} else { | ||
reason, message := externalMachine.GetVMNotReadyReason() | ||
conditions.MarkFalse(ctx.KubevirtMachine, infrav1.VMProvisionedCondition, reason, clusterv1.ConditionSeverityInfo, message) | ||
|
||
// Waiting for VM to boot | ||
ctx.KubevirtMachine.Status.Ready = false | ||
ctx.Logger.Info("KubeVirt VM is not fully provisioned and running...") | ||
|
@@ -476,7 +480,7 @@ func (r *KubevirtMachineReconciler) reconcileDelete(ctx *context.MachineContext) | |
|
||
// SetupWithManager will add watches for this controller. | ||
func (r *KubevirtMachineReconciler) SetupWithManager(goctx gocontext.Context, mgr ctrl.Manager, options controller.Options) error { | ||
clusterToKubevirtMachines, err := util.ClusterToObjectsMapper(mgr.GetClient(), &infrav1.KubevirtMachineList{}, mgr.GetScheme()) | ||
clusterToKubevirtMachines, err := util.ClusterToTypedObjectsMapper(mgr.GetClient(), &infrav1.KubevirtMachineList{}, mgr.GetScheme()) | ||
Comment on lines
-479
to
+483
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. i'm curious what this change does 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. the // Deprecated: This function is deprecated and will be removed in a future release, use ClusterToTypedObjectsMapper instead.
// The problem with this function is that it uses UnstructuredList to retrieve objects, with the default client configuration
// this will lead to uncached List calls, which is a major performance issue. |
||
if err != nil { | ||
return err | ||
} | ||
|
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, i guess this is needed here too, clusterkubevirtadm/cmd/credentials/credentials.go
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.
@davidvossel - done