-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility of disabling audit log functionality per landscape #367
Changes from 7 commits
2b8e327
bea2e29
1129976
1e03eef
214ba67
a6e909e
cf6ea01
0ea85ee
eea82e3
fd9388d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,6 +2,7 @@ package fsm | |||||
|
||||||
import ( | ||||||
"context" | ||||||
"strings" | ||||||
|
||||||
imv1 "github.com/kyma-project/infrastructure-manager/api/v1" | ||||||
ctrl "sigs.k8s.io/controller-runtime" | ||||||
|
@@ -24,19 +25,45 @@ func sFnConfigureAuditLog(ctx context.Context, m *fsm, s *systemState) (stateFn, | |||||
return updateStatusAndRequeueAfter(gardenerRequeueDuration) | ||||||
} | ||||||
|
||||||
if err != nil { | ||||||
m.log.Error(err, "Failed to configure Audit Log") | ||||||
s.instance.UpdateStatePending( | ||||||
imv1.ConditionTypeAuditLogConfigured, | ||||||
imv1.ConditionReasonAuditLogError, | ||||||
"False", | ||||||
err.Error(), | ||||||
) | ||||||
if err != nil { //nolint:nestif | ||||||
errorMessage := err.Error() | ||||||
if strings.Contains(errorMessage, "auditlog config for region") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Here's another approach on how it should be achieved |
||||||
if m.RCCfg.AuditLogMandatory { | ||||||
m.log.Error(err, "Failed to configure Audit Log, missing region mapping for this shoot") | ||||||
s.instance.UpdateStatePending( | ||||||
imv1.ConditionTypeAuditLogConfigured, | ||||||
imv1.ConditionReasonAuditLogMissingRegionMapping, | ||||||
"False", | ||||||
errorMessage, | ||||||
) | ||||||
} else { | ||||||
m.log.Info(errorMessage, "Failed to configure Audit Log, missing region mapping for this shoot, but is not mandatory to be configured") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A tiny rewording proposal to make it more clear that it's a acceptable behavior. Feel free to ignore this suggestion if you don't agree.
Suggested change
|
||||||
s.instance.UpdateStateReady( | ||||||
imv1.ConditionTypeAuditLogConfigured, | ||||||
imv1.ConditionReasonAuditLogMissingRegionMapping, | ||||||
"Missing region mapping for this shoot. Audit Log is not mandatory. Skipping configuration") | ||||||
} | ||||||
} else { | ||||||
if m.RCCfg.AuditLogMandatory { | ||||||
m.log.Error(err, "Failed to configure Audit Log") | ||||||
s.instance.UpdateStatePending( | ||||||
imv1.ConditionTypeAuditLogConfigured, | ||||||
imv1.ConditionReasonAuditLogError, | ||||||
"False", | ||||||
errorMessage) | ||||||
} else { | ||||||
m.log.Info(errorMessage, "Failed to configure Audit Log, but is not mandatory to be configured") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During verification I've encountered a panic:
Quoting logger api docs:
I wonder if just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to check code. In my opinion this additional info need to be present to clearly describe that Audit Log was set as not mandatory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's possible to add either one parameter (errorMessage) or 3/5/7 etc with additional ones for key name and the value . (always uneven). When I executed this part I noticed the So how about such invocation: The log would look like this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logging additional information on region and provider type could make it easier to quickly fix such issues. |
||||||
s.instance.UpdateStateReady( | ||||||
imv1.ConditionTypeAuditLogConfigured, | ||||||
imv1.ConditionReasonAuditLogError, | ||||||
"Configuration of Audit Log is not mandatory, error for context: "+errorMessage) | ||||||
} | ||||||
} | ||||||
} else { | ||||||
s.instance.UpdateStateReady( | ||||||
imv1.ConditionTypeAuditLogConfigured, | ||||||
imv1.ConditionReasonAuditLogConfigured, | ||||||
"Audit Log configured successfully", | ||||||
"Audit Log state completed successfully", | ||||||
) | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document this new paramenter (link)