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
1da4f4a7
Unverified
Commit
1da4f4a7
authored
Jul 31, 2017
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix duplicate metrics collector registration attempted error
parent
088c1982
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
reflector.go
staging/src/k8s.io/client-go/tools/cache/reflector.go
+7
-1
No files found.
staging/src/k8s.io/client-go/tools/cache/reflector.go
View file @
1da4f4a7
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"strconv"
"strconv"
"strings"
"strings"
"sync"
"sync"
"sync/atomic"
"syscall"
"syscall"
"time"
"time"
...
@@ -98,12 +99,17 @@ func NewReflector(lw ListerWatcher, expectedType interface{}, store Store, resyn
...
@@ -98,12 +99,17 @@ func NewReflector(lw ListerWatcher, expectedType interface{}, store Store, resyn
return
NewNamedReflector
(
getDefaultReflectorName
(
internalPackages
...
),
lw
,
expectedType
,
store
,
resyncPeriod
)
return
NewNamedReflector
(
getDefaultReflectorName
(
internalPackages
...
),
lw
,
expectedType
,
store
,
resyncPeriod
)
}
}
// reflectorDisambiguator is used to disambiguate started reflectors.
// initialized to an unstable value to ensure meaning isn't attributed to the suffix.
var
reflectorDisambiguator
=
int64
(
time
.
Now
()
.
UnixNano
()
%
12345
)
// NewNamedReflector same as NewReflector, but with a specified name for logging
// NewNamedReflector same as NewReflector, but with a specified name for logging
func
NewNamedReflector
(
name
string
,
lw
ListerWatcher
,
expectedType
interface
{},
store
Store
,
resyncPeriod
time
.
Duration
)
*
Reflector
{
func
NewNamedReflector
(
name
string
,
lw
ListerWatcher
,
expectedType
interface
{},
store
Store
,
resyncPeriod
time
.
Duration
)
*
Reflector
{
reflectorSuffix
:=
atomic
.
AddInt64
(
&
reflectorDisambiguator
,
1
)
r
:=
&
Reflector
{
r
:=
&
Reflector
{
name
:
name
,
name
:
name
,
// we need this to be unique per process (some names are still the same)but obvious who it belongs to
// we need this to be unique per process (some names are still the same)but obvious who it belongs to
metrics
:
newReflectorMetrics
(
makeValidPromethusMetricName
(
fmt
.
Sprintf
(
"reflector_"
+
name
+
"_%
07d"
,
rand
.
Intn
(
1000000
)
))),
metrics
:
newReflectorMetrics
(
makeValidPromethusMetricName
(
fmt
.
Sprintf
(
"reflector_"
+
name
+
"_%
d"
,
reflectorSuffix
))),
listerWatcher
:
lw
,
listerWatcher
:
lw
,
store
:
store
,
store
:
store
,
expectedType
:
reflect
.
TypeOf
(
expectedType
),
expectedType
:
reflect
.
TypeOf
(
expectedType
),
...
...
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