mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Update property name in metrics
selinux_volume_conflict should not have space in its label value - it's harder to query for that value. Use SELinuxLabel as both human friendly (in an event) and label value.
This commit is contained in:
parent
cf7a2c7d35
commit
8791efc732
@ -25,7 +25,7 @@ import (
|
||||
// A single conflict between two Pods using the same volume with different SELinux labels or policies.
|
||||
// Event should be sent to both of them.
|
||||
type Conflict struct {
|
||||
// Human-readable name of the conflicting property, like "SELinux label"
|
||||
// Human-readable name of the conflicting property + value of "property" label of selinux_volume_conflict metric.
|
||||
PropertyName string
|
||||
// Reason for the event, to be set as the Event.Reason field.
|
||||
EventReason string
|
||||
|
@ -140,14 +140,14 @@ func (c *volumeCache) AddVolume(logger klog.Logger, volumeName v1.UniqueVolumeNa
|
||||
if otherPodInfo.seLinuxLabel != label {
|
||||
// Send conflict to both pods
|
||||
conflicts = append(conflicts, Conflict{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: podKey,
|
||||
PropertyValue: label,
|
||||
OtherPod: otherPodKey,
|
||||
OtherPropertyValue: otherPodInfo.seLinuxLabel,
|
||||
}, Conflict{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: otherPodKey,
|
||||
PropertyValue: otherPodInfo.seLinuxLabel,
|
||||
@ -250,7 +250,7 @@ func (c *volumeCache) SendConflicts(logger klog.Logger, ch chan<- Conflict) {
|
||||
}
|
||||
if podInfo.seLinuxLabel != otherPodInfo.seLinuxLabel {
|
||||
ch <- Conflict{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: podKey,
|
||||
PropertyValue: podInfo.seLinuxLabel,
|
||||
|
@ -204,7 +204,7 @@ func TestVolumeCache_AddVolumeSendConflicts(t *testing.T) {
|
||||
},
|
||||
expectedConflicts: []Conflict{
|
||||
{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: cache.ObjectName{Namespace: "testns", Name: "testpod"},
|
||||
PropertyValue: "label-new",
|
||||
@ -254,7 +254,7 @@ func TestVolumeCache_AddVolumeSendConflicts(t *testing.T) {
|
||||
OtherPropertyValue: "MountOption",
|
||||
},
|
||||
{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: cache.ObjectName{Namespace: "testns", Name: "testpod"},
|
||||
PropertyValue: "label-new",
|
||||
@ -297,7 +297,7 @@ func TestVolumeCache_AddVolumeSendConflicts(t *testing.T) {
|
||||
OtherPropertyValue: "Recursive",
|
||||
},
|
||||
{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: cache.ObjectName{Namespace: "ns3", Name: "pod3-1"},
|
||||
PropertyValue: "label-new",
|
||||
|
@ -192,7 +192,7 @@ func TestSELinuxWarningController_Sync(t *testing.T) {
|
||||
pod: cache.ObjectName{Namespace: namespace, Name: "pod1"},
|
||||
conflicts: []volumecache.Conflict{
|
||||
{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: cache.ObjectName{Namespace: namespace, Name: "pod1"},
|
||||
PropertyValue: "label1",
|
||||
@ -200,7 +200,7 @@ func TestSELinuxWarningController_Sync(t *testing.T) {
|
||||
OtherPropertyValue: "label2",
|
||||
},
|
||||
{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: cache.ObjectName{Namespace: namespace, Name: "pod2"},
|
||||
PropertyValue: "label2",
|
||||
@ -218,8 +218,8 @@ func TestSELinuxWarningController_Sync(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expectedEvents: []string{
|
||||
`Normal SELinuxLabelConflict SELinux label "label1" conflicts with pod pod2 that uses the same volume as this pod with SELinux label "label2". If both pods land on the same node, only one of them may access the volume.`,
|
||||
`Normal SELinuxLabelConflict SELinux label "label2" conflicts with pod pod1 that uses the same volume as this pod with SELinux label "label1". If both pods land on the same node, only one of them may access the volume.`,
|
||||
`Normal SELinuxLabelConflict SELinuxLabel "label1" conflicts with pod pod2 that uses the same volume as this pod with SELinuxLabel "label2". If both pods land on the same node, only one of them may access the volume.`,
|
||||
`Normal SELinuxLabelConflict SELinuxLabel "label2" conflicts with pod pod1 that uses the same volume as this pod with SELinuxLabel "label1". If both pods land on the same node, only one of them may access the volume.`,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -237,7 +237,7 @@ func TestSELinuxWarningController_Sync(t *testing.T) {
|
||||
pod: cache.ObjectName{Namespace: namespace, Name: "pod1"},
|
||||
conflicts: []volumecache.Conflict{
|
||||
{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: cache.ObjectName{Namespace: namespace, Name: "pod1"},
|
||||
PropertyValue: "label1",
|
||||
@ -245,7 +245,7 @@ func TestSELinuxWarningController_Sync(t *testing.T) {
|
||||
OtherPropertyValue: "label2",
|
||||
},
|
||||
{
|
||||
PropertyName: "SELinux label",
|
||||
PropertyName: "SELinuxLabel",
|
||||
EventReason: "SELinuxLabelConflict",
|
||||
Pod: cache.ObjectName{Namespace: namespace, Name: "pod2"},
|
||||
PropertyValue: "label2",
|
||||
@ -264,7 +264,7 @@ func TestSELinuxWarningController_Sync(t *testing.T) {
|
||||
},
|
||||
expectedEvents: []string{
|
||||
// Event for the missing pod is not sent
|
||||
`Normal SELinuxLabelConflict SELinux label "label1" conflicts with pod pod2 that uses the same volume as this pod with SELinux label "label2". If both pods land on the same node, only one of them may access the volume.`,
|
||||
`Normal SELinuxLabelConflict SELinuxLabel "label1" conflicts with pod pod2 that uses the same volume as this pod with SELinuxLabel "label2". If both pods land on the same node, only one of them may access the volume.`,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user