OpenSearch cloudwatch logging - #548
Conversation
| if !errors.As(err, &alreadyExists) { | ||
| logger.Error("ensureLogGroups: CreateLogGroup err", "err", err, "logGroup", name) | ||
| return err | ||
| } |
There was a problem hiding this comment.
| if !errors.As(err, &alreadyExists) { | |
| logger.Error("ensureLogGroups: CreateLogGroup err", "err", err, "logGroup", name) | |
| return err | |
| } | |
| if !errors.As(err, &alreadyExists) { | |
| logger.Error("ensureLogGroups: CreateLogGroup err", "err", err, "logGroup", name) | |
| return err | |
| } | |
| return err |
So we're catching the already exists error just to log it specifically? Or do we intend to ignore that error?
I also think we need to return the error if it's not already exists, so we don't trap those errors
There was a problem hiding this comment.
The intention of this block was to catch errors that are NOT alreadyExists and return those. I'm treating alreadyExists errors as successful here. I can change the logic here to make it more clear to read.
| t.Run(name, func(t *testing.T) { | ||
| i := test.initial | ||
| i.applyLogOptions(test.options) | ||
| if i.AuditLogsEnabled != test.expectedAudit { |
There was a problem hiding this comment.
Nit: would it be easier to have an expectedInstance for each test case and compare against that instead of comparing each property individually?
There was a problem hiding this comment.
Refactored this test file to match the pattern used in other unit tests
Co-authored-by: Mark Boyd <mark.boyd@gsa.gov> Signed-off-by: James Marcos <marcosjames135@gmail.com>
… into es-cw-logging
| gotCreated := append([]string{}, client.createdLogGroups...) | ||
| wantCreated := append([]string{}, test.expectedCreated...) | ||
| sort.Strings(gotCreated) | ||
| sort.Strings(wantCreated) | ||
| if diff := deep.Equal(gotCreated, wantCreated); diff != nil { | ||
| t.Errorf("createdLogGroups: %v", diff) | ||
| } |
There was a problem hiding this comment.
| gotCreated := append([]string{}, client.createdLogGroups...) | |
| wantCreated := append([]string{}, test.expectedCreated...) | |
| sort.Strings(gotCreated) | |
| sort.Strings(wantCreated) | |
| if diff := deep.Equal(gotCreated, wantCreated); diff != nil { | |
| t.Errorf("createdLogGroups: %v", diff) | |
| } | |
| sort.Strings(client.createdLogGroup) | |
| sort.Strings(test.expectedCreated) | |
| if diff := deep.Equal(client.createdLogGroup, test.expectedCreated); diff != nil { | |
| t.Errorf("createdLogGroups: %v", diff) | |
| } |
It's not important, but is there a reason this form wouldn't work?
markdboyd
left a comment
There was a problem hiding this comment.
Great work @jmarcos135
8a37ab5 to
0deee14
Compare
Changes proposed in this pull request:
Things to check
INFOand debugging statements are written withlog.debugor similar, then they won't be written to the otput, which can prevent unintentional leaks of sensitive data.Security considerations
[Note the any security considerations here, or make note of why there are none]