Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1489#discussion_r59801226
  
    --- Diff: engine/schema/src/com/cloud/upgrade/dao/Upgrade481to490.java ---
    @@ -53,6 +62,139 @@ public boolean supportsRollingUpgrade() {
     
         @Override
         public void performDataMigration(Connection conn) {
    +        setupRolesAndPermissionsForDynamicRBAC(conn);
    +    }
    +
    +    private void createDefaultRole(final Connection conn, final Long id, 
final String name, final RoleType roleType) {
    +        final String insertSql = String.format("INSERT INTO 
`cloud`.`roles` (`id`, `uuid`, `name`, `role_type`, `description`) values (%d, 
UUID(), '%s', '%s', 'Default %s role');",
    +                id, name, roleType.name(), roleType.name().toLowerCase());
    +        try ( PreparedStatement updatePstmt = 
conn.prepareStatement(insertSql) ) {
    +            updatePstmt.executeUpdate();
    +        } catch (SQLException e) {
    +            throw new CloudRuntimeException("Unable to create default role 
with id: " + id + " name: " + name, e);
    +        }
    +    }
    +
    +    private void createRoleMapping(final Connection conn, final Long 
roleId, final String apiName) {
    +        final String insertSql = String.format("INSERT INTO 
`cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`) values 
(UUID(), %d, '%s', 'ALLOW') ON DUPLICATE KEY UPDATE rule=rule;",
    +                roleId, apiName);
    +        try ( PreparedStatement updatePstmt = 
conn.prepareStatement(insertSql)) {
    +            updatePstmt.executeUpdate();
    +        } catch (SQLException ignored) {
    +            s_logger.debug("Unable to insert mapping for role id:" + 
roleId + " apiName: " + apiName);
    --- End diff --
    
    Why not log this condition to ``WARN``?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to