Skip to content

Commit fa65129

Browse files
danilrwxloktev-d
authored andcommitted
fix(audit): improve VM Access message (#1313)
Description Improve VM Access audit messages. Add stage from audit message to eventLog name. Why do we need it, and what problem does it solve? At the moment it is not clear at what stage the request comes when connecting via port-forward, as well as when connecting via console and vnc. What is the expected result? Add stage status of request from event message. --------- Signed-off-by: Daniil Antoshin <[email protected]> Signed-off-by: Daniil Loktev <[email protected]>
1 parent 0962f72 commit fa65129

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

images/virtualization-artifact/pkg/audit/events/vm/vm_access.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package vm
1818

1919
import (
20+
"fmt"
21+
2022
"k8s.io/apiserver/pkg/apis/audit"
2123

2224
"github.com/deckhouse/deckhouse/pkg/log"
@@ -80,9 +82,7 @@ func (m *VMAccess) Fill() error {
8082
m.eventLog.Name = "Access to VM via portforward"
8183
}
8284

83-
if m.event.Stage == audit.StageRequestReceived {
84-
m.eventLog.Name = "Request " + m.eventLog.Name
85-
}
85+
m.eventLog.Name = fmt.Sprintf("%s: %s", m.eventLog.Name, m.event.Stage)
8686

8787
vm, err := util.GetVMFromInformer(m.ttlCache, m.informerList.GetVMInformer(), m.event.ObjectRef.Namespace+"/"+m.event.ObjectRef.Name)
8888
if err != nil {

images/virtualization-artifact/pkg/audit/events/vm/vm_access_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,33 +252,33 @@ var _ = Describe("VMOP Events", func() {
252252
shouldFailMatch: true,
253253
}),
254254
Entry("VM Access with ResponseComplete should contain decision and fill without errors", vmAccessTestArgs{
255-
expectedName: "Access to VM via serial console",
255+
expectedName: "Access to VM via serial console: ResponseComplete",
256256
customSubresource: "console",
257257
}),
258258
Entry("VM Access with RequestReceived shouldn't contain decision and fill without errors", vmAccessTestArgs{
259-
expectedName: "Request Access to VM via serial console",
259+
expectedName: "Access to VM via serial console: RequestReceived",
260260
customSubresource: "console",
261261
isRequestReceived: true,
262262
}),
263263
Entry("VM Access by Console event should filled without errors", vmAccessTestArgs{
264-
expectedName: "Access to VM via serial console",
264+
expectedName: "Access to VM via serial console: ResponseComplete",
265265
customSubresource: "console",
266266
}),
267267
Entry("VM Access by VNC event should filled without errors", vmAccessTestArgs{
268-
expectedName: "Access to VM via VNC",
268+
expectedName: "Access to VM via VNC: ResponseComplete",
269269
customSubresource: "vnc",
270270
}),
271271
Entry("VM Access by Portforward event should filled without errors", vmAccessTestArgs{
272-
expectedName: "Access to VM via portforward",
272+
expectedName: "Access to VM via portforward: ResponseComplete",
273273
customSubresource: "portforward",
274274
}),
275275
Entry("VM Access with losted VM event should filled without errors", vmAccessTestArgs{
276-
expectedName: "Access to VM via serial console",
276+
expectedName: "Access to VM via serial console: ResponseComplete",
277277
customSubresource: "console",
278278
shouldLostVM: true,
279279
}),
280280
Entry("VM Access with losted VD and Node event should filled without errors", vmAccessTestArgs{
281-
expectedName: "Access to VM via serial console",
281+
expectedName: "Access to VM via serial console: ResponseComplete",
282282
customSubresource: "console",
283283
shouldLostVD: true,
284284
shouldLostNode: true,

0 commit comments

Comments
 (0)