Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
9cee7bd5
Commit
9cee7bd5
authored
Jun 27, 2022
by
Brad Davidson
Committed by
Brad Davidson
Jul 01, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't crash when service IPFamiliyPolicy is not set
Service.Spec.IPFamilyPolicy may be a nil pointer on freshly upgraded clusters. Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
15ad1632
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
controller.go
pkg/servicelb/controller.go
+7
-3
No files found.
pkg/servicelb/controller.go
View file @
9cee7bd5
...
@@ -189,7 +189,7 @@ func (h *handler) onChangeNode(key string, node *core.Node) (*core.Node, error)
...
@@ -189,7 +189,7 @@ func (h *handler) onChangeNode(key string, node *core.Node) (*core.Node, error)
// updateService ensures that the Service ingress IP address list is in sync
// updateService ensures that the Service ingress IP address list is in sync
// with the Nodes actually running pods for this service.
// with the Nodes actually running pods for this service.
func
(
h
*
handler
)
updateService
(
svc
*
core
.
Service
)
(
runtime
.
Object
,
error
)
{
func
(
h
*
handler
)
updateService
(
svc
*
core
.
Service
)
(
runtime
.
Object
,
error
)
{
if
!
h
.
enabled
{
if
!
h
.
enabled
||
svc
.
Spec
.
Type
!=
core
.
ServiceTypeLoadBalancer
{
return
svc
,
nil
return
svc
,
nil
}
}
...
@@ -301,7 +301,7 @@ func (h *handler) podIPs(pods []*core.Pod, svc *core.Service) ([]string, error)
...
@@ -301,7 +301,7 @@ func (h *handler) podIPs(pods []*core.Pod, svc *core.Service) ([]string, error)
// filterByIPFamily filters ips based on dual-stack parameters of the service
// filterByIPFamily filters ips based on dual-stack parameters of the service
func
filterByIPFamily
(
ips
[]
string
,
svc
*
core
.
Service
)
([]
string
,
error
)
{
func
filterByIPFamily
(
ips
[]
string
,
svc
*
core
.
Service
)
([]
string
,
error
)
{
var
ipFamilyPolicy
core
.
IPFamilyPolicyType
var
ipv4Addresses
[]
string
var
ipv4Addresses
[]
string
var
ipv6Addresses
[]
string
var
ipv6Addresses
[]
string
...
@@ -314,7 +314,11 @@ func filterByIPFamily(ips []string, svc *core.Service) ([]string, error) {
...
@@ -314,7 +314,11 @@ func filterByIPFamily(ips []string, svc *core.Service) ([]string, error) {
}
}
}
}
switch
*
svc
.
Spec
.
IPFamilyPolicy
{
if
svc
.
Spec
.
IPFamilyPolicy
!=
nil
{
ipFamilyPolicy
=
*
svc
.
Spec
.
IPFamilyPolicy
}
switch
ipFamilyPolicy
{
case
core
.
IPFamilyPolicySingleStack
:
case
core
.
IPFamilyPolicySingleStack
:
if
svc
.
Spec
.
IPFamilies
[
0
]
==
core
.
IPv4Protocol
{
if
svc
.
Spec
.
IPFamilies
[
0
]
==
core
.
IPv4Protocol
{
return
ipv4Addresses
,
nil
return
ipv4Addresses
,
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment