Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
k8s-ingress
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
uplex-varnish
k8s-ingress
Commits
831b25c2
Commit
831b25c2
authored
Jan 15, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the sync_result_total counter vector.
parent
314c607e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
61 additions
and
9 deletions
+61
-9
backendconfig.go
pkg/controller/backendconfig.go
+2
-0
controller.go
pkg/controller/controller.go
+22
-1
endpoints.go
pkg/controller/endpoints.go
+4
-0
ingress.go
pkg/controller/ingress.go
+2
-0
metrics.go
pkg/controller/metrics.go
+17
-8
secret.go
pkg/controller/secret.go
+2
-0
service.go
pkg/controller/service.go
+2
-0
varnishconfig.go
pkg/controller/varnishconfig.go
+2
-0
worker.go
pkg/controller/worker.go
+8
-0
No files found.
pkg/controller/backendconfig.go
View file @
831b25c2
...
...
@@ -95,6 +95,8 @@ func (worker *NamespaceWorker) syncBcfg(key string) error {
// CRD validation should prevent this.
worker
.
log
.
Warnf
(
"BackendConfig %s/%s: no services defined, "
+
"ignoring"
,
bcfg
.
Namespace
,
bcfg
.
Name
)
syncCounters
.
WithLabelValues
(
worker
.
namespace
,
"BackendConfig"
,
"Ignore"
)
.
Inc
()
return
nil
}
...
...
pkg/controller/controller.go
View file @
831b25c2
...
...
@@ -256,9 +256,28 @@ func (ingc *IngressController) updateObj(old, new interface{}) {
ingc
.
log
.
Infof
(
"Update %s %s/%s: unchanged"
,
t
.
GetKind
(),
oldMeta
.
GetNamespace
(),
oldMeta
.
GetName
())
syncCounters
.
WithLabelValues
(
oldMeta
.
GetNamespace
(),
t
.
GetKind
(),
"Ignore"
)
.
Inc
()
}
else
{
ingc
.
log
.
Infof
(
"Update %s/%s: unchanged"
,
kind
:=
"Unknown"
switch
old
.
(
type
)
{
case
*
extensions
.
Ingress
:
kind
=
"Ingress"
case
*
api_v1
.
Service
:
kind
=
"Service"
case
*
api_v1
.
Endpoints
:
kind
=
"Endpoints"
case
*
api_v1
.
Secret
:
kind
=
"Secret"
case
*
vcr_v1alpha1
.
VarnishConfig
:
kind
=
"VarnishConfig"
case
*
vcr_v1alpha1
.
BackendConfig
:
kind
=
"BackendConfig"
}
ingc
.
log
.
Infof
(
"Update %s %s/%s: unchanged"
,
kind
,
oldMeta
.
GetNamespace
(),
oldMeta
.
GetName
())
syncCounters
.
WithLabelValues
(
oldMeta
.
GetNamespace
(),
kind
,
"Ignore"
)
.
Inc
()
}
return
}
...
...
@@ -272,6 +291,8 @@ func (ingc *IngressController) updateObj(old, new interface{}) {
ingc
.
log
.
Infof
(
"Update endpoints %s/%s: empty Subsets, ignoring"
,
newEndp
.
Namespace
,
newEndp
.
Name
)
syncCounters
.
WithLabelValues
(
oldMeta
.
GetNamespace
(),
"Endpoints"
,
"Ignore"
)
.
Inc
()
return
}
...
...
pkg/controller/endpoints.go
View file @
831b25c2
...
...
@@ -36,6 +36,8 @@ func (worker *NamespaceWorker) syncEndp(key string) error {
if
err
!=
nil
{
worker
.
log
.
Warnf
(
"Cannot get service for endpoints %s/%s, "
+
"ignoring"
,
worker
.
namespace
,
key
)
syncCounters
.
WithLabelValues
(
worker
.
namespace
,
"Endpoints"
,
"Ignore"
)
.
Inc
()
return
nil
}
...
...
@@ -56,6 +58,8 @@ func (worker *NamespaceWorker) syncEndp(key string) error {
if
len
(
ings
)
==
0
{
worker
.
log
.
Debugf
(
"No ingresses for endpoints: %s/%s"
,
worker
.
namespace
,
key
)
syncCounters
.
WithLabelValues
(
worker
.
namespace
,
"Endpoints"
,
"Ignore"
)
.
Inc
()
return
nil
}
...
...
pkg/controller/ingress.go
View file @
831b25c2
...
...
@@ -555,6 +555,8 @@ func (worker *NamespaceWorker) syncIng(key string) error {
worker
.
log
.
Infof
(
"Ignoring Ingress %s/%s, Annotation '%v' "
+
"absent or is not 'varnish'"
,
ing
.
Namespace
,
ing
.
Name
,
ingressClassKey
)
syncCounters
.
WithLabelValues
(
worker
.
namespace
,
"Ingress"
,
"Ignore"
)
.
Inc
()
return
nil
}
return
worker
.
addOrUpdateIng
(
ing
)
...
...
pkg/controller/metrics.go
View file @
831b25c2
...
...
@@ -119,14 +119,22 @@ func (_ promProvider) NewRetriesMetric(name string) workqueue.CounterMetric {
return
retries
}
var
watchCounters
map
[
string
]
map
[
SyncType
]
prometheus
.
Counter
=
map
[
string
]
map
[
SyncType
]
prometheus
.
Counter
{
"Ingress"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"Service"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"Endpoints"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"Secret"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"VarnishConfig"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"BackendConfig"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
}
var
(
watchCounters
map
[
string
]
map
[
SyncType
]
prometheus
.
Counter
=
map
[
string
]
map
[
SyncType
]
prometheus
.
Counter
{
"Ingress"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"Service"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"Endpoints"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"Secret"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"VarnishConfig"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"BackendConfig"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
}
syncCounters
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Namespace
:
namespace
,
Subsystem
:
"sync"
,
Name
:
"result_total"
,
Help
:
"Total number of synchronization results"
,
},
[]
string
{
"namespace"
,
"kind"
,
"result"
})
)
func
InitMetrics
()
{
workqueue
.
SetProvider
(
promProvider
{})
...
...
@@ -152,6 +160,7 @@ func InitMetrics() {
prometheus
.
Register
(
m
[
syncType
])
}
}
prometheus
.
Register
(
syncCounters
)
}
func
ServeMetrics
(
log
*
logrus
.
Logger
,
port
uint16
)
{
...
...
pkg/controller/secret.go
View file @
831b25c2
...
...
@@ -128,6 +128,8 @@ func (worker *NamespaceWorker) syncSecret(key string) error {
if
!
ok
||
app
!=
labelVal
{
worker
.
log
.
Infof
(
"Not a Varnish secret: %s/%s"
,
secret
.
Namespace
,
secret
.
Name
)
syncCounters
.
WithLabelValues
(
worker
.
namespace
,
"Secret"
,
"Ignore"
)
.
Inc
()
return
nil
}
...
...
pkg/controller/service.go
View file @
831b25c2
...
...
@@ -83,6 +83,8 @@ func (worker *NamespaceWorker) getIngsForSvc(
if
len
(
ings
)
==
0
{
worker
.
log
.
Infof
(
"No Varnish Ingresses defined for service %s/%s"
,
svc
.
Namespace
,
svc
.
Name
)
syncCounters
.
WithLabelValues
(
worker
.
namespace
,
"Service"
,
"Ignore"
)
.
Inc
()
}
return
ings
,
nil
}
...
...
pkg/controller/varnishconfig.go
View file @
831b25c2
...
...
@@ -110,6 +110,8 @@ func (worker *NamespaceWorker) syncVcfg(key string) error {
// CRD validation should prevent this.
worker
.
log
.
Infof
(
"VarnishConfig %s/%s: no services defined, "
+
"ignoring"
,
vcfg
.
Namespace
,
vcfg
.
Name
)
syncCounters
.
WithLabelValues
(
worker
.
namespace
,
"VarnishConfig"
,
"Ignore"
)
.
Inc
()
return
nil
}
...
...
pkg/controller/worker.go
View file @
831b25c2
...
...
@@ -84,29 +84,37 @@ func (worker *NamespaceWorker) event(obj interface{}, evtType, reason,
if
syncObj
,
ok
:=
obj
.
(
*
SyncObj
);
ok
{
eventObj
=
syncObj
.
Obj
}
kind
:=
"Unknown"
switch
eventObj
.
(
type
)
{
case
*
extensions
.
Ingress
:
ing
,
_
:=
eventObj
.
(
*
extensions
.
Ingress
)
worker
.
recorder
.
Eventf
(
ing
,
evtType
,
reason
,
msgFmt
,
args
...
)
kind
=
"Ingress"
case
*
api_v1
.
Service
:
svc
,
_
:=
eventObj
.
(
*
api_v1
.
Service
)
worker
.
recorder
.
Eventf
(
svc
,
evtType
,
reason
,
msgFmt
,
args
...
)
kind
=
"Service"
case
*
api_v1
.
Endpoints
:
endp
,
_
:=
eventObj
.
(
*
api_v1
.
Endpoints
)
worker
.
recorder
.
Eventf
(
endp
,
evtType
,
reason
,
msgFmt
,
args
...
)
kind
=
"Endpoints"
case
*
api_v1
.
Secret
:
secr
,
_
:=
eventObj
.
(
*
api_v1
.
Secret
)
worker
.
recorder
.
Eventf
(
secr
,
evtType
,
reason
,
msgFmt
,
args
...
)
kind
=
"Secret"
case
*
ving_v1alpha1
.
VarnishConfig
:
vcfg
,
_
:=
eventObj
.
(
*
ving_v1alpha1
.
VarnishConfig
)
worker
.
recorder
.
Eventf
(
vcfg
,
evtType
,
reason
,
msgFmt
,
args
...
)
kind
=
"VarnishConfig"
case
*
ving_v1alpha1
.
BackendConfig
:
bcfg
,
_
:=
eventObj
.
(
*
ving_v1alpha1
.
BackendConfig
)
worker
.
recorder
.
Eventf
(
bcfg
,
evtType
,
reason
,
msgFmt
,
args
...
)
kind
=
"BackendConfig"
default
:
worker
.
log
.
Warnf
(
"Unhandled type %T, no event generated"
,
eventObj
)
}
syncCounters
.
WithLabelValues
(
worker
.
namespace
,
kind
,
reason
)
.
Inc
()
}
func
(
worker
*
NamespaceWorker
)
infoEvent
(
obj
interface
{},
reason
,
msgFmt
string
,
...
...
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