Skip to content

Commit e466bc4

Browse files
committed
nrt: cache: add support for dedicated informer
Add an option to create and use a separate informer to get unfiltered pod listing from the apiserver. Due to mismatched view with respect to the kubelet, the plugin needs access to pod in terminal phase which are not deleted to make sure the reconciliation is done correctly. xref: #598 xref: kubernetes/kubernetes#119423 Signed-off-by: Francesco Romani <[email protected]>
1 parent 9f8a417 commit e466bc4

18 files changed

+437
-169
lines changed

apis/config/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ const (
176176
CacheResyncOnlyExclusiveResources CacheResyncMethod = "OnlyExclusiveResources"
177177
)
178178

179+
// CacheInformerMode is a "string" type
180+
type CacheInformerMode string
181+
182+
const (
183+
CacheInformerShared CacheInformerMode = "Shared"
184+
CacheInformerDedicated CacheInformerMode = "Dedicated"
185+
)
186+
179187
// NodeResourceTopologyCache define configuration details for the NodeResourceTopology cache.
180188
type NodeResourceTopologyCache struct {
181189
// ForeignPodsDetect sets how foreign pods should be handled.
@@ -192,6 +200,11 @@ type NodeResourceTopologyCache struct {
192200
// Has no effect if caching is disabled (CacheResyncPeriod is zero) or if DiscardReservedNodes
193201
// is enabled. "Autodetect" is the default, reads hint from NRT objects. Fallback is "All".
194202
ResyncMethod *CacheResyncMethod
203+
// InformerMode controls the channel the cache uses to get updates about pods.
204+
// "Shared" uses the default settings; "Dedicated" creates a specific subscription which is
205+
// guaranteed to best suit the cache needs, at cost of one extra connection.
206+
// If unspecified, default is "Dedicated"
207+
InformerMode *CacheInformerMode
195208
}
196209

197210
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

apis/config/v1/defaults.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ var (
8989

9090
defaultResyncMethod = CacheResyncAutodetect
9191

92+
defaultInformerMode = CacheInformerDedicated
93+
9294
// Defaults for NetworkOverhead
9395
// DefaultWeightsName contains the default costs to be used by networkAware plugins
9496
DefaultWeightsName = "UserDefined"
@@ -200,6 +202,9 @@ func SetDefaults_NodeResourceTopologyMatchArgs(obj *NodeResourceTopologyMatchArg
200202
if obj.Cache.ResyncMethod == nil {
201203
obj.Cache.ResyncMethod = &defaultResyncMethod
202204
}
205+
if obj.Cache.InformerMode == nil {
206+
obj.Cache.InformerMode = &defaultInformerMode
207+
}
203208
}
204209

205210
// SetDefaults_PreemptionTolerationArgs reuses SetDefaults_DefaultPreemptionArgs

apis/config/v1/defaults_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ func TestSchedulingDefaults(t *testing.T) {
205205
Cache: &NodeResourceTopologyCache{
206206
ForeignPodsDetect: &defaultForeignPodsDetect,
207207
ResyncMethod: &defaultResyncMethod,
208+
InformerMode: &defaultInformerMode,
208209
},
209210
},
210211
},

apis/config/v1/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ const (
174174
CacheResyncOnlyExclusiveResources CacheResyncMethod = "OnlyExclusiveResources"
175175
)
176176

177+
// CacheInformerMode is a "string" type
178+
type CacheInformerMode string
179+
180+
const (
181+
CacheInformerShared CacheInformerMode = "Shared"
182+
CacheInformerDedicated CacheInformerMode = "Dedicated"
183+
)
184+
177185
// NodeResourceTopologyCache define configuration details for the NodeResourceTopology cache.
178186
type NodeResourceTopologyCache struct {
179187
// ForeignPodsDetect sets how foreign pods should be handled.
@@ -190,6 +198,11 @@ type NodeResourceTopologyCache struct {
190198
// Has no effect if caching is disabled (CacheResyncPeriod is zero) or if DiscardReservedNodes
191199
// is enabled. "Autodetect" is the default, reads hint from NRT objects. Fallback is "All".
192200
ResyncMethod *CacheResyncMethod `json:"resyncMethod,omitempty"`
201+
// InformerMode controls the channel the cache uses to get updates about pods.
202+
// "Shared" uses the default settings; "Dedicated" creates a specific subscription which is
203+
// guaranteed to best suit the cache needs, at cost of one extra connection.
204+
// If unspecified, default is "Dedicated"
205+
InformerMode *CacheInformerMode `json:"informerMode,omitempty"`
193206
}
194207

195208
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

apis/config/v1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/config/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/config/v1beta3/defaults.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ var (
8989

9090
defaultResyncMethod = CacheResyncAutodetect
9191

92+
defaultInformerMode = CacheInformerDedicated
93+
9294
// Defaults for NetworkOverhead
9395
// DefaultWeightsName contains the default costs to be used by networkAware plugins
9496
DefaultWeightsName = "UserDefined"
@@ -200,6 +202,9 @@ func SetDefaults_NodeResourceTopologyMatchArgs(obj *NodeResourceTopologyMatchArg
200202
if obj.Cache.ResyncMethod == nil {
201203
obj.Cache.ResyncMethod = &defaultResyncMethod
202204
}
205+
if obj.Cache.InformerMode == nil {
206+
obj.Cache.InformerMode = &defaultInformerMode
207+
}
203208
}
204209

205210
// SetDefaults_PreemptionTolerationArgs reuses SetDefaults_DefaultPreemptionArgs

apis/config/v1beta3/defaults_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ func TestSchedulingDefaults(t *testing.T) {
205205
Cache: &NodeResourceTopologyCache{
206206
ForeignPodsDetect: &defaultForeignPodsDetect,
207207
ResyncMethod: &defaultResyncMethod,
208+
InformerMode: &defaultInformerMode,
208209
},
209210
},
210211
},

apis/config/v1beta3/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ const (
174174
CacheResyncOnlyExclusiveResources CacheResyncMethod = "OnlyExclusiveResources"
175175
)
176176

177+
// CacheInformerMode is a "string" type
178+
type CacheInformerMode string
179+
180+
const (
181+
CacheInformerShared CacheInformerMode = "Shared"
182+
CacheInformerDedicated CacheInformerMode = "Dedicated"
183+
)
184+
177185
// NodeResourceTopologyCache define configuration details for the NodeResourceTopology cache.
178186
type NodeResourceTopologyCache struct {
179187
// ForeignPodsDetect sets how foreign pods should be handled.
@@ -190,6 +198,11 @@ type NodeResourceTopologyCache struct {
190198
// Has no effect if caching is disabled (CacheResyncPeriod is zero) or if DiscardReservedNodes
191199
// is enabled. "Autodetect" is the default, reads hint from NRT objects. Fallback is "All".
192200
ResyncMethod *CacheResyncMethod `json:"resyncMethod,omitempty"`
201+
// InformerMode controls the channel the cache uses to get updates about pods.
202+
// "Shared" uses the default settings; "Dedicated" creates a specific subscription which is
203+
// guaranteed to best suit the cache needs, at cost of one extra connection.
204+
// If unspecified, default is "Dedicated"
205+
InformerMode *CacheInformerMode `json:"informerMode,omitempty"`
193206
}
194207

195208
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

apis/config/v1beta3/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)