- 
                Notifications
    
You must be signed in to change notification settings  - Fork 25.6k
 
Improved PolicyManager error reporting #121824
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
Conversation
This lets us produce error messages that guide the user to add the right entitlement to the right plugin/server/etc.
| 
           Pinging @elastic/es-core-infra (Team:Core/Infra)  | 
    
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.
LGTM
| public static final ModuleEntitlements NONE = new ModuleEntitlements(Map.of(), FileAccessTree.EMPTY); | ||
| public static final String UNKNOWN_COMPONENT_NAME = "(unknown)"; | ||
| public static final String SERVER_COMPONENT_NAME = "(server)"; | ||
| public static final String AGENT_COMPONENT_NAME = "(agent)"; | 
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.
This is actually apm agent. Just "agent" may be confused with the entitlement agent.
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.
Great point.
| 
               | 
          ||
| record ModuleEntitlements(Map<Class<? extends Entitlement>, List<Entitlement>> entitlementsByType, FileAccessTree fileAccess) { | ||
| public static final ModuleEntitlements NONE = new ModuleEntitlements(Map.of(), FileAccessTree.EMPTY); | ||
| public static final String UNKNOWN_COMPONENT_NAME = "(unknown)"; | 
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.
These can all be at most package private?
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.
Oh true. I think they're public from a prior revision of this code.
Avoids confusion with the entitlements agent.
* Report componentName in ModuleEntitlements. This lets us produce error messages that guide the user to add the right entitlement to the right plugin/server/etc. * Include component names in errors and logs * Name APM agent specifically. Avoids confusion with the entitlements agent. * Entitlement component names package private * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]>
* Report componentName in ModuleEntitlements. This lets us produce error messages that guide the user to add the right entitlement to the right plugin/server/etc. * Include component names in errors and logs * Name APM agent specifically. Avoids confusion with the entitlements agent. * Entitlement component names package private * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]>
* Report componentName in ModuleEntitlements. This lets us produce error messages that guide the user to add the right entitlement to the right plugin/server/etc. * Include component names in errors and logs * Name APM agent specifically. Avoids confusion with the entitlements agent. * Entitlement component names package private * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]>
* Report componentName in ModuleEntitlements. This lets us produce error messages that guide the user to add the right entitlement to the right plugin/server/etc. * Include component names in errors and logs * Name APM agent specifically. Avoids confusion with the entitlements agent. * Entitlement component names package private * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]>
* Report componentName in ModuleEntitlements. This lets us produce error messages that guide the user to add the right entitlement to the right plugin/server/etc. * Include component names in errors and logs * Name APM agent specifically. Avoids confusion with the entitlements agent. * Entitlement component names package private * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]>
Problem
The current errors and logs don't give an indication of which plugin (or server or agent) is requesting the entitlement, and so it's hard to know what needs fixing.
Also, instead of the
requestingClass, we sometimes report thecallerClass, which is not useful or relevant.Fix
In the memoized
ModuleEntitlementsrecord, include the name of the "component". This is either the plugin name, or else a special string like(server)or(agent).Clean up the exceptions and logging to report the component, module, and class information in a consistent order and format.