Skip to content

Commit 03aefcb

Browse files
committed
first commit
1 parent a92b26c commit 03aefcb

File tree

11 files changed

+878
-189
lines changed

11 files changed

+878
-189
lines changed

felix/bpf/proxy/proxy_test.go

+77
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,83 @@ var _ = Describe("BPF Proxy", func() {
610610
})
611611
})
612612
})
613+
614+
Context("with terminating workloads", func() {
615+
var (
616+
p proxy.Proxy
617+
dp *mockSyncer
618+
k8s *fake.Clientset
619+
)
620+
621+
BeforeEach(func() {
622+
By("creating proxy with fake client and mock syncer", func() {
623+
var err error
624+
625+
k8s = fake.NewSimpleClientset(testSvc, testSvcEpsSlice)
626+
syncStop = make(chan struct{})
627+
dp = newMockSyncer(syncStop)
628+
629+
opts := []proxy.Option{proxy.WithImmediateSync()}
630+
631+
p, err = proxy.New(k8s, dp, "test-node", opts...)
632+
Expect(err).NotTo(HaveOccurred())
633+
})
634+
})
635+
636+
AfterEach(func() {
637+
By("stopping the proxy", func() {
638+
close(syncStop)
639+
p.Stop()
640+
})
641+
})
642+
643+
It("should see IsReady=false and IsTerminating=true", func() {
644+
By("getting the initial sync")
645+
646+
dp.checkState(func(s proxy.DPSyncerState) {
647+
Expect(len(s.SvcMap)).To(Equal(1))
648+
Expect(len(s.EpsMap)).To(Equal(1))
649+
650+
})
651+
652+
By("placing one endpoint to terminating state")
653+
654+
falsePtr := new(bool)
655+
*falsePtr = false
656+
657+
truePtr := new(bool)
658+
*truePtr = true
659+
660+
testSvcEpsSlice.Endpoints[0].Conditions.Ready = falsePtr
661+
testSvcEpsSlice.Endpoints[0].Conditions.Terminating = truePtr
662+
err := k8s.Tracker().Update(discovery.SchemeGroupVersion.WithResource("endpointslices"),
663+
testSvcEpsSlice, "default")
664+
Expect(err).NotTo(HaveOccurred())
665+
666+
dp.checkState(func(s proxy.DPSyncerState) {
667+
Expect(len(s.SvcMap)).To(Equal(1))
668+
Expect(len(s.EpsMap)).To(Equal(1))
669+
670+
var key k8sp.ServicePortName
671+
672+
for key = range s.EpsMap {
673+
}
674+
675+
isReady := 0
676+
isTerminating := 0
677+
for _, ep := range s.EpsMap[key] {
678+
if ep.IsReady() {
679+
isReady++
680+
}
681+
if ep.IsTerminating() {
682+
isTerminating++
683+
}
684+
}
685+
Expect(isReady).To(Equal(1))
686+
Expect(isTerminating).To(Equal(1))
687+
})
688+
})
689+
})
613690
})
614691

615692
type mockSyncer struct {

felix/calc/calc_graph.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package calc
1616

1717
import (
1818
"github.com/prometheus/client_golang/prometheus"
19+
"github.com/sirupsen/logrus"
1920
log "github.com/sirupsen/logrus"
2021

2122
v3 "github.com/projectcalico/api/pkg/apis/projectcalico/v3"
@@ -378,7 +379,8 @@ func NewCalculationGraph(callbacks PipelineCallbacks, conf *config.Config, liveC
378379
hostIPPassthru.RegisterWith(allUpdDispatcher)
379380
cg.hostIPPassthru = hostIPPassthru
380381

381-
if conf.BPFEnabled || conf.Encapsulation.VXLANEnabled || conf.Encapsulation.VXLANEnabledV6 || conf.WireguardEnabled || conf.WireguardEnabledV6 {
382+
if conf.BPFEnabled || conf.Encapsulation.VXLANEnabled || conf.Encapsulation.VXLANEnabledV6 ||
383+
conf.WireguardEnabled || conf.WireguardEnabledV6 || conf.Encapsulation.IPIPEnabled {
382384
// Calculate simple node-ownership routes.
383385
// ...
384386
// Dispatcher (all updates)
@@ -391,6 +393,7 @@ func NewCalculationGraph(callbacks PipelineCallbacks, conf *config.Config, liveC
391393
// |
392394
// <dataplane>
393395
//
396+
logrus.Info("Marmar")
394397
l3RR := NewL3RouteResolver(hostname, callbacks, conf.UseNodeResourceUpdates(), conf.RouteSource)
395398
l3RR.RegisterWith(allUpdDispatcher, localEndpointDispatcher)
396399
l3RR.OnAlive = liveCallback

felix/dataplane/linux/bpf_ep_mgr.go

+1
Original file line numberDiff line numberDiff line change
@@ -3405,6 +3405,7 @@ func (m *bpfEndpointManager) loadPolicyProgram(
34053405
log.WithFields(log.Fields{
34063406
"progName": progName,
34073407
"ipFamily": ipFamily,
3408+
"rules": rules,
34083409
}).Debug("Generating policy program...")
34093410

34103411
ipsetsMapFD := m.v4.IpsetsMap.MapFD()

felix/dataplane/linux/int_dataplane.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,29 @@ func NewIntDataplaneDriver(config Config) *InternalDataplane {
804804
dp.RegisterManager(newFloatingIPManager(natTableV4, ruleRenderer, 4, config.FloatingIPsEnabled))
805805
dp.RegisterManager(newMasqManager(ipSetsV4, natTableV4, ruleRenderer, config.MaxIPSetSize, 4))
806806
if config.RulesConfig.IPIPEnabled {
807+
var routeTableIPIP routetable.RouteTableInterface
808+
if !config.RouteSyncDisabled {
809+
log.Debug("RouteSyncDisabled is false.")
810+
routeTableIPIP = routetable.New(
811+
[]string{"^tunl0$"}, 4, config.NetlinkTimeout,
812+
config.DeviceRouteSourceAddress, config.DeviceRouteProtocol, config.RemoveExternalRoutes,
813+
unix.RT_TABLE_MAIN, dp.loopSummarizer, featureDetector, routetable.WithLivenessCB(dp.reportHealth),
814+
routetable.WithRouteCleanupGracePeriod(routeCleanupGracePeriod))
815+
} else {
816+
log.Info("RouteSyncDisabled is true, using DummyTable.")
817+
routeTableIPIP = &routetable.DummyTable{}
818+
}
819+
807820
// Add a manager to keep the all-hosts IP set up to date.
808-
dp.ipipManager = newIPIPManager(ipSetsV4, config.MaxIPSetSize, config.ExternalNodesCidrs)
821+
dp.ipipManager = newIPIPManager(
822+
ipSetsV4,
823+
"tunl0",
824+
routeTableIPIP,
825+
config,
826+
dp.loopSummarizer,
827+
4,
828+
featureDetector,
829+
)
809830
dp.RegisterManager(dp.ipipManager) // IPv4-only
810831
} else {
811832
// Only clean up IPIP addresses if IPIP is implicitly disabled (no IPIP pools and not explicitly set in FelixConfig)

0 commit comments

Comments
 (0)