-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a priority label #288
base: main
Are you sure you want to change the base?
add a priority label #288
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ func New(log *logrus.Entry) *Metrics { | |
Help: "Where the container in use is using the latest upstream registry version", | ||
}, | ||
[]string{ | ||
"namespace", "pod", "container", "container_type", "image", "current_version", "latest_version", | ||
"namespace", "pod", "container", "container_type", "image", "current_version", "latest_version", "priority", | ||
}, | ||
) | ||
|
||
|
@@ -87,7 +87,7 @@ func (m *Metrics) Run(servingAddress string) error { | |
return nil | ||
} | ||
|
||
func (m *Metrics) AddImage(namespace, pod, container, containerType, imageURL string, isLatest bool, currentVersion, latestVersion string) { | ||
func (m *Metrics) AddImage(namespace, pod, container, containerType, imageURL string, isLatest bool, currentVersion, latestVersion, priority string) { | ||
// Remove old image url/version if it exists | ||
m.RemoveImage(namespace, pod, container, containerType) | ||
|
||
|
@@ -100,7 +100,7 @@ func (m *Metrics) AddImage(namespace, pod, container, containerType, imageURL st | |
} | ||
|
||
m.containerImageVersion.With( | ||
m.buildLabels(namespace, pod, container, containerType, imageURL, currentVersion, latestVersion), | ||
m.buildLabels(namespace, pod, container, containerType, imageURL, currentVersion, latestVersion, priority), | ||
).Set(isLatestF) | ||
|
||
index := m.latestImageIndex(namespace, pod, container, containerType) | ||
|
@@ -131,7 +131,7 @@ func (m *Metrics) latestImageIndex(namespace, pod, container, containerType stri | |
return strings.Join([]string{namespace, pod, container, containerType}, "") | ||
} | ||
|
||
func (m *Metrics) buildLabels(namespace, pod, container, containerType, imageURL, currentVersion, latestVersion string) prometheus.Labels { | ||
func (m *Metrics) buildLabels(namespace, pod, container, containerType, imageURL, currentVersion, latestVersion, priority string) prometheus.Labels { | ||
return prometheus.Labels{ | ||
"namespace": namespace, | ||
"pod": pod, | ||
|
@@ -140,6 +140,7 @@ func (m *Metrics) buildLabels(namespace, pod, container, containerType, imageURL | |
"image": imageURL, | ||
"current_version": currentVersion, | ||
"latest_version": latestVersion, | ||
"priority": priority, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,21 @@ import ( | |
"github.com/sirupsen/logrus" | ||
) | ||
|
||
const ( | ||
defaultPriority = "0" | ||
) | ||
|
||
func TestCache(t *testing.T) { | ||
m := New(logrus.NewEntry(logrus.New())) | ||
|
||
for i, typ := range []string{"init", "container"} { | ||
version := fmt.Sprintf("0.1.%d", i) | ||
m.AddImage("namespace", "pod", "container", typ, "url", true, version, version) | ||
m.AddImage("namespace", "pod", "container", typ, "url", true, version, version, defaultPriority) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do need this, (see comment in |
||
for i, typ := range []string{"init", "container"} { | ||
version := fmt.Sprintf("0.1.%d", i) | ||
mt, _ := m.containerImageVersion.GetMetricWith(m.buildLabels("namespace", "pod", "container", typ, "url", version, version)) | ||
mt, _ := m.containerImageVersion.GetMetricWith(m.buildLabels("namespace", "pod", "container", typ, "url", version, version, defaultPriority)) | ||
count := testutil.ToFloat64(mt) | ||
if count != 1 { | ||
t.Error("Should have added metric") | ||
|
@@ -30,7 +34,7 @@ func TestCache(t *testing.T) { | |
} | ||
for i, typ := range []string{"init", "container"} { | ||
version := fmt.Sprintf("0.1.%d", i) | ||
mt, _ := m.containerImageVersion.GetMetricWith(m.buildLabels("namespace", "pod", "container", typ, "url", version, version)) | ||
mt, _ := m.containerImageVersion.GetMetricWith(m.buildLabels("namespace", "pod", "container", typ, "url", version, version, defaultPriority)) | ||
count := testutil.ToFloat64(mt) | ||
if count != 0 { | ||
t.Error("Should have removed metric") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as with
metrics.go
- I'm not entirely sure this would be needed.