@@ -96,7 +96,7 @@ var _ = Describe("chgm", func() {
96
96
97
97
Describe ("Triggered" , func () {
98
98
When ("Triggered finds instances stopped by the customer" , func () {
99
- It ("should send a service log and silence the alert " , func () {
99
+ It ("should put the cluster on limited support " , func () {
100
100
event := cloudtrailv2types.Event {
101
101
Username : awsv2 .String ("12345" ),
102
102
CloudTrailEvent : awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{"type":"AssumedRole", "sessionContext":{"sessionIssuer":{"type":"Role", "userName": "654321"}}}}` ),
@@ -106,19 +106,19 @@ var _ = Describe("chgm", func() {
106
106
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {masterInstance , infraInstance }, nil )
107
107
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
108
108
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
109
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
109
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
110
110
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ())
111
111
112
112
result , gotErr := inv .Run (r )
113
113
114
114
Expect (gotErr ).NotTo (HaveOccurred ())
115
115
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
116
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
117
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
116
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
117
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
118
118
})
119
119
})
120
120
When ("Triggered finds instances stopped by the customer with CloudTrail eventVersion 1.99" , func () {
121
- It ("should still send a service log and silence the alert " , func () {
121
+ It ("should still put the cluster on limited support " , func () {
122
122
event := cloudtrailv2types.Event {
123
123
Username : awsv2 .String ("12345" ),
124
124
CloudTrailEvent : awsv2 .String (`{"eventVersion":"1.99", "userIdentity":{"type":"AssumedRole", "sessionContext":{"sessionIssuer":{"type":"Role", "userName": "654321"}}}}` ),
@@ -128,15 +128,15 @@ var _ = Describe("chgm", func() {
128
128
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {masterInstance , infraInstance }, nil )
129
129
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
130
130
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
131
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
131
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
132
132
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ())
133
133
134
134
result , gotErr := inv .Run (r )
135
135
136
136
Expect (gotErr ).NotTo (HaveOccurred ())
137
137
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
138
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
139
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
138
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
139
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
140
140
})
141
141
})
142
142
When ("Triggered errors" , func () {
@@ -204,21 +204,21 @@ var _ = Describe("chgm", func() {
204
204
})
205
205
})
206
206
When ("the returned CloudTrailEventRaw base data is correct, but the sessionissue's username is not an authorized user" , func () {
207
- It ("should send a service log and silence the alert " , func () {
207
+ It ("should put the cluster on limited support " , func () {
208
208
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
209
209
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
210
210
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
211
211
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{"type":"AssumedRole", "sessionContext":{"sessionIssuer":{"type":"Role", "userName": "654321"}}}}` )
212
212
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
213
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
213
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
214
214
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
215
215
// Act
216
216
result , gotErr := inv .Run (r )
217
217
// Assert
218
218
Expect (gotErr ).NotTo (HaveOccurred ())
219
219
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
220
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
221
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
220
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
221
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
222
222
})
223
223
})
224
224
When ("issuer user is authorized (openshift-machine-api-aws)" , func () {
@@ -425,106 +425,106 @@ var _ = Describe("chgm", func() {
425
425
})
426
426
})
427
427
When ("the returned CloudTrailEventRaw has an empty userIdentity" , func () {
428
- It ("should send a service log and silence the alert " , func () {
428
+ It ("should put the cluster on limited support " , func () {
429
429
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
430
430
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
431
431
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
432
432
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{}}` )
433
433
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
434
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
434
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
435
435
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
436
436
437
437
result , gotErr := inv .Run (r )
438
438
Expect (gotErr ).NotTo (HaveOccurred ())
439
439
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
440
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
441
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
440
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
441
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
442
442
})
443
443
})
444
444
When ("issuer user is unauthorized (testuser assumed role)" , func () {
445
- It ("should send a service log and silence the alert " , func () {
445
+ It ("should put the cluster on limited support " , func () {
446
446
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
447
447
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
448
448
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
449
449
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"}}` )
450
450
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
451
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
451
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
452
452
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
453
453
454
454
result , gotErr := inv .Run (r )
455
455
Expect (gotErr ).NotTo (HaveOccurred ())
456
456
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
457
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
458
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
457
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
458
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
459
459
})
460
460
})
461
461
When ("the returned CloudTrailEventRaw base data is correct, but the sessionissue's role is not role" , func () {
462
- It ("should send a service log and silence the alert " , func () {
462
+ It ("should put the cluster on limited support " , func () {
463
463
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
464
464
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
465
465
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
466
466
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{"type":"AssumedRole", "sessionContext":{"sessionIssuer":{"type":"test"}}}}` )
467
467
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
468
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
468
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
469
469
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
470
470
471
471
result , gotErr := inv .Run (r )
472
472
Expect (gotErr ).NotTo (HaveOccurred ())
473
473
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
474
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
475
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
474
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
475
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
476
476
})
477
477
})
478
478
When ("the returned CloudTrailEventRaw has no data" , func () {
479
- It ("should send a service log and silence the alert " , func () {
479
+ It ("should put the cluster on limited support " , func () {
480
480
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
481
481
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
482
482
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
483
483
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
484
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
484
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
485
485
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
486
486
487
487
result , gotErr := inv .Run (r )
488
488
Expect (gotErr ).NotTo (HaveOccurred ())
489
489
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
490
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
491
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
490
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
491
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
492
492
})
493
493
})
494
494
495
495
When ("the returned CloudTrailEventRaw has an empty userIdentity" , func () {
496
- It ("should send a service log and silence the alert " , func () {
496
+ It ("should put the cluster on limited support " , func () {
497
497
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
498
498
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
499
499
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
500
500
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{}}` )
501
501
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
502
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
502
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
503
503
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
504
504
505
505
result , gotErr := inv .Run (r )
506
506
Expect (gotErr ).NotTo (HaveOccurred ())
507
507
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
508
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
509
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
508
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
509
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
510
510
})
511
511
})
512
512
513
513
When ("the returned CloudTrailEventRaw has a userIdentity is an iam user" , func () {
514
- It ("should send a service log and silence the alert " , func () {
514
+ It ("should put the cluster on limited support " , func () {
515
515
r .OcmClient .(* ocmmock.MockClient ).EXPECT ().GetClusterMachinePools (gomock .Any ()).Return (machinePools , nil )
516
516
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListNonRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
517
517
r .AwsClient .(* awsmock.MockClient ).EXPECT ().ListRunningInstances (gomock .Eq (infraID )).Return ([]ec2v2types.Instance {instance }, nil )
518
518
event .CloudTrailEvent = awsv2 .String (`{"eventVersion":"1.08", "userIdentity":{"type":"IAMUser"}}` )
519
519
r .AwsClient .(* awsmock.MockClient ).EXPECT ().PollInstanceStopEventsFor (gomock .Any (), gomock .Any ()).Return ([]cloudtrailv2types.Event {event }, nil )
520
- r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostServiceLog (gomock .Eq (cluster . ID ()) , gomock .Eq (& chgmSL )).Return (nil )
520
+ r .OcmClient .(* ocmmock.MockClient ).EXPECT ().PostLimitedSupportReason (gomock .Eq (& stoppedInfraLS ) , gomock .Eq (cluster . ID () )).Return (nil )
521
521
r .PdClient .(* pdmock.MockClient ).EXPECT ().SilenceIncidentWithNote (gomock .Any ()).Return (nil )
522
522
523
523
result , gotErr := inv .Run (r )
524
524
Expect (gotErr ).NotTo (HaveOccurred ())
525
525
Expect (result .ServiceLogPrepared .Performed ).To (BeFalse ())
526
- Expect (result .ServiceLogSent .Performed ).To (BeTrue ())
527
- Expect (result .LimitedSupportSet .Performed ).To (BeFalse ())
526
+ Expect (result .ServiceLogSent .Performed ).To (BeFalse ())
527
+ Expect (result .LimitedSupportSet .Performed ).To (BeTrue ())
528
528
})
529
529
})
530
530
When ("the returned CloudTrailEvent has more than one resource" , func () {
0 commit comments