Skip to content

Commit

Permalink
fix node ip
Browse files Browse the repository at this point in the history
  • Loading branch information
aleoli authored and adamjensenbot committed Sep 3, 2024
1 parent f013cb6 commit 4b330af
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/virtualKubelet/liqoNodeProvider/nodeProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type LiqoNodeProvider struct {
lastAppliedTaints []corev1.Taint

nodeName string
nodeIP string
foreignClusterID liqov1beta1.ClusterID
tenantNamespace string
resyncPeriod time.Duration
Expand Down
7 changes: 7 additions & 0 deletions pkg/virtualKubelet/liqoNodeProvider/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ import (
"github.com/liqotech/liqo/pkg/utils/slice"
)

func (p *LiqoNodeProvider) reconcileNodeFromNode(_ watch.Event) error {
// enforce the node to be the same as the one we are managing
return p.updateNode()
}

func (p *LiqoNodeProvider) reconcileNodeFromVirtualNode(event watch.Event) error {
ctx := context.Background()
var virtualNode offloadingv1beta1.VirtualNode
Expand Down Expand Up @@ -163,6 +168,8 @@ func (p *LiqoNodeProvider) updateNode() error {
deleteCondition(p.node, v1.NodeNetworkUnavailable)
}

p.node.Status.Addresses = []v1.NodeAddress{{Type: v1.NodeInternalIP, Address: p.nodeIP}}

p.onNodeChangeCallback(p.node.DeepCopy())
return nil
}
Expand Down
12 changes: 10 additions & 2 deletions pkg/virtualKubelet/liqoNodeProvider/resourceWatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,26 @@ import (
"github.com/liqotech/liqo/pkg/consts"
)

// StartProvider starts the provider with its infromers on Liqo resources.
// StartProvider starts the provider with its informers on Liqo resources.
// These informers on sharing and network resources will be used to accordingly
// update the virtual node.
func (p *LiqoNodeProvider) StartProvider(ctx context.Context) (ready chan struct{}) {
namespace := p.tenantNamespace

nodeInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(
p.dynClient, p.resyncPeriod, corev1.NamespaceAll, func(opt *metav1.ListOptions) {
opt.FieldSelector = "metadata.name=" + p.nodeName
})
nodeInformer := nodeInformerFactory.ForResource(corev1.SchemeGroupVersion.WithResource("nodes")).Informer()
_, err := nodeInformer.AddEventHandler(getEventHandler(p.reconcileNodeFromNode))
runtime.Must(err)

virtualNodeInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(
p.dynClient, p.resyncPeriod, namespace, func(opt *metav1.ListOptions) {
opt.FieldSelector = "metadata.name=" + p.nodeName
})
virtualNodeInformer := virtualNodeInformerFactory.ForResource(offloadingv1beta1.VirtualNodeGroupVersionResource).Informer()
_, err := virtualNodeInformer.AddEventHandler(getEventHandler(p.reconcileNodeFromVirtualNode))
_, err = virtualNodeInformer.AddEventHandler(getEventHandler(p.reconcileNodeFromVirtualNode))
runtime.Must(err)

var fcInformerFactory dynamicinformer.DynamicSharedInformerFactory
Expand Down
1 change: 1 addition & 0 deletions pkg/virtualKubelet/liqoNodeProvider/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func NewLiqoNodeProvider(cfg *InitConfig) *LiqoNodeProvider {
checkNetworkStatus: cfg.CheckNetworkStatus,

nodeName: cfg.NodeName,
nodeIP: cfg.InternalIP,
foreignClusterID: cfg.RemoteClusterID,
tenantNamespace: cfg.Namespace,
}
Expand Down

0 comments on commit 4b330af

Please sign in to comment.