@@ -95,7 +95,7 @@ var _ = Describe("chgm", func() {
95
95
96
96
Describe ("Triggered" , func () {
97
97
When ("Triggered finds instances stopped by the customer" , func () {
98
- It ("should send a service log and silence the alert " , func () {
98
+ It ("should put the cluster on limited support " , func () {
99
99
event := cloudtrailv2types.Event {
100
100
Username : awsv2 .String ("12345" ),
101
101
CloudTrailEvent : awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{"type":"AssumedRole", "sessionContext":{"sessionIssuer":{"type":"Role", "userName": "654321"}}}}` ),
@@ -105,19 +105,19 @@ var _ = Describe("chgm", func() {
105
105
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {masterInstance , infraInstance }, nil )
106
106
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
107
107
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
108
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
108
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
109
109
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ())
110
110
111
111
result , gotErr := inv .Run (r )
112
112
113
113
Expect (gotErr ).NotTo (HaveOccurred ())
114
114
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
115
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
116
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
115
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
116
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
117
117
})
118
118
})
119
119
When ("Triggered finds instances stopped by the customer with CloudTrail eventVersion 1.99" , func () {
120
- It ("should still send a service log and silence the alert " , func () {
120
+ It ("should still put the cluster on limited support " , func () {
121
121
event := cloudtrailv2types.Event {
122
122
Username : awsv2 .String ("12345" ),
123
123
CloudTrailEvent : awsv2 .String (`{"eventVersion":"1.99", "userIdentity":{"type":"AssumedRole", "sessionContext":{"sessionIssuer":{"type":"Role", "userName": "654321"}}}}` ),
@@ -127,15 +127,15 @@ var _ = Describe("chgm", func() {
127
127
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {masterInstance , infraInstance }, nil )
128
128
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
129
129
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
130
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
130
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
131
131
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ())
132
132
133
133
result , gotErr := inv .Run (r )
134
134
135
135
Expect (gotErr ).NotTo (HaveOccurred ())
136
136
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
137
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
138
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
137
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
138
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
139
139
})
140
140
})
141
141
When ("Triggered errors" , func () {
@@ -203,21 +203,21 @@ var _ = Describe("chgm", func() {
203
203
})
204
204
})
205
205
When ("the returned CloudTrailEventRaw base data is correct, but the sessionissue's username is not an authorized user" , func () {
206
- It ("should send a service log and silence the alert " , func () {
206
+ It ("should put the cluster on limited support " , func () {
207
207
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
208
208
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
209
209
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
210
210
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{"type":"AssumedRole", "sessionContext":{"sessionIssuer":{"type":"Role", "userName": "654321"}}}}` )
211
211
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
212
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
212
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
213
213
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
214
214
// Act
215
215
result , gotErr := inv .Run (r )
216
216
// Assert
217
217
Expect (gotErr ).NotTo (HaveOccurred ())
218
218
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
219
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
220
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
219
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
220
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
221
221
})
222
222
})
223
223
When ("issuer user is authorized (openshift-machine-api-aws)" , func () {
@@ -424,106 +424,106 @@ var _ = Describe("chgm", func() {
424
424
})
425
425
})
426
426
When ("the returned CloudTrailEventRaw has an empty userIdentity" , func () {
427
- It ("should send a service log and silence the alert " , func () {
427
+ It ("should put the cluster on limited support " , func () {
428
428
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
429
429
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
430
430
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
431
431
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{}}` )
432
432
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
433
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
433
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
434
434
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
435
435
436
436
result , gotErr := inv .Run (r )
437
437
Expect (gotErr ).NotTo (HaveOccurred ())
438
438
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
439
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
440
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
439
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
440
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
441
441
})
442
442
})
443
443
When ("issuer user is unauthorized (testuser assumed role)" , func () {
444
- It ("should send a service log and silence the alert " , func () {
444
+ It ("should put the cluster on limited support " , func () {
445
445
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
446
446
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
447
447
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
448
448
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08","userIdentity":{"type":"AssumedRole","principalId":"REDACTED:OCM","arn":"arn:aws:sts::1234:assumed-role/testuser/OCM","accountId":"1234","accessKeyId":"REDACTED","sessionContext":{"sessionIssuer":{"type":"Role","principalId":"REDACTED","arn":"arn:aws:iam::1234:role/testuser","accountId":"1234","userName":"testuser"},"webIdFederationData":{},"attributes":{"creationDate":"2023-02-21T04:08:01Z","mfaAuthenticated":"false"}}},"eventTime":"2023-02-21T04:10:40Z","eventSource":"ec2v2types.amazonawsv2.com","eventName":"TerminateInstances","awsRegion":"ap-southeast-1","sourceIPAddress":"192.168.0.0","userAgent":"aws-sdk-go-v2/1.17.3 os/linux lang/go/1.19.5 md/GOOS/linux md/GOARCH/amd64 api/ec2/1.25.0","requestParameters":{"instancesSet":{"items":[{"instanceId":"i-00c1f1234567"}]}},"responseElements":{"requestId":"credacted","instancesSet":{"items":[{"instanceId":"i-00c1f1234567","currentState":{"code":32,"name":"shutting-down"},"previousState":{"code":16,"name":"running"}}]}},"requestID":"credacted","eventID":"e55a8a64-9949-47a9-9fff-12345678","readOnly":false,"eventType":"AwsApiCall","managementEvent":true,"recipientAccountId":"1234","eventCategory":"Management","tlsDetails":{"tlsVersion":"TLSv1.2","cipherSuite":"ECDHE-RSA-AES128-GCM-SHA256","clientProvidedHostHeader":"ec2v2types.ap-southeast-1.amazonawsv2.com"}}` )
449
449
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
450
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
450
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
451
451
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
452
452
453
453
result , gotErr := inv .Run (r )
454
454
Expect (gotErr ).NotTo (HaveOccurred ())
455
455
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
456
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
457
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
456
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
457
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
458
458
})
459
459
})
460
460
When ("the returned CloudTrailEventRaw base data is correct, but the sessionissue's role is not role" , func () {
461
- It ("should send a service log and silence the alert " , func () {
461
+ It ("should put the cluster on limited support " , func () {
462
462
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
463
463
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
464
464
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
465
465
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{"type":"AssumedRole", "sessionContext":{"sessionIssuer":{"type":"test"}}}}` )
466
466
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
467
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
467
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
468
468
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
469
469
470
470
result , gotErr := inv .Run (r )
471
471
Expect (gotErr ).NotTo (HaveOccurred ())
472
472
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
473
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
474
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
473
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
474
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
475
475
})
476
476
})
477
477
When ("the returned CloudTrailEventRaw has no data" , func () {
478
- It ("should send a service log and silence the alert " , func () {
478
+ It ("should put the cluster on limited support " , func () {
479
479
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
480
480
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
481
481
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
482
482
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
483
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
483
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
484
484
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
485
485
486
486
result , gotErr := inv .Run (r )
487
487
Expect (gotErr ).NotTo (HaveOccurred ())
488
488
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
489
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
490
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
489
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
490
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
491
491
})
492
492
})
493
493
494
494
When ("the returned CloudTrailEventRaw has an empty userIdentity" , func () {
495
- It ("should send a service log and silence the alert " , func () {
495
+ It ("should put the cluster on limited support " , func () {
496
496
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
497
497
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
498
498
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
499
499
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{}}` )
500
500
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
501
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
501
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
502
502
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
503
503
504
504
result , gotErr := inv .Run (r )
505
505
Expect (gotErr ).NotTo (HaveOccurred ())
506
506
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
507
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
508
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
507
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
508
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
509
509
})
510
510
})
511
511
512
512
When ("the returned CloudTrailEventRaw has a userIdentity is an iam user" , func () {
513
- It ("should send a service log and silence the alert " , func () {
513
+ It ("should put the cluster on limited support " , func () {
514
514
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
515
515
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
516
516
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
517
517
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{"type":"IAMUser"}}` )
518
518
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
519
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
519
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
520
520
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
521
521
522
522
result , gotErr := inv .Run (r )
523
523
Expect (gotErr ).NotTo (HaveOccurred ())
524
524
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
525
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
526
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
525
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
526
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
527
527
})
528
528
})
529
529
When ("the returned CloudTrailEvent has more than one resource" , func () {
0 commit comments