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

Use default namespace if it's empty #43

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/cloud-controller-manager/ccm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/rancher/wrangler/pkg/kubeconfig"
"github.com/rancher/wrangler/pkg/signals"
"github.com/rancher/wrangler/pkg/start"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/tools/clientcmd"
cloudprovider "k8s.io/cloud-provider"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -67,6 +68,9 @@ func newCloudProvider(reader io.Reader) (cloudprovider.Interface, error) {
}

namespace := rawConfig.Contexts[rawConfig.CurrentContext].Namespace
if namespace == "" {
namespace = corev1.NamespaceDefault
}

localCfg, err := kubeconfig.GetNonInteractiveClientConfig(os.Getenv("KUBECONFIG")).ClientConfig()
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions pkg/controller/virtualmachineinstance/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func Register(
nodeToVMName: nodeToVMName,
namespace: namespace,
}
logrus.WithFields(logrus.Fields{
"controller": vmiControllerName,
"namespace": namespace,
}).Info("start watching virtual machine instance")
vmis.OnChange(ctx, vmiControllerName, handler.OnVmiChanged)
}

Expand All @@ -63,10 +67,18 @@ func (h *Handler) OnVmiChanged(_ string, vmi *kubevirtv1.VirtualMachineInstance)
// only handle the migration completed vmi
if vmi == nil || vmi.DeletionTimestamp != nil ||
vmi.Annotations == nil || vmi.Namespace != h.namespace || !isMigrationCompleted(vmi) {
logrus.WithFields(logrus.Fields{
"namespace": vmi.Namespace,
"name": vmi.Name,
}).Info("skip processing virtual machine instance")
return vmi, nil
}

if creator := vmi.Labels[builder.LabelKeyVirtualMachineCreator]; creator != virtualmachine.VirtualMachineCreatorNodeDriver {
logrus.WithFields(logrus.Fields{
"namespace": vmi.Namespace,
"name": vmi.Name,
}).Info("skip processing virtual machine instance")
return vmi, nil
}

Expand Down
Loading