You have bugs when planning
Closed this issue · 3 comments
role = Role(name="TITAN_TEST_ROLE")
warehouse = Warehouse(
name="TITAN_TEST_WAREHOUSE",
warehouse_size="xsmall",
auto_suspend=60,
)
grants = [
Grant(priv="usage", to=role, on=warehouse),
RoleGrant(role=role, to_role="SYSADMIN")
]
logger.info("Adding infrastructure to the blueprint")
bp.add(
role,
warehouse,
*grants,
)
plan = bp.plan(connection)
print(plan)
# Ask for confirmation before applying the plan
if input("Do you want to apply the plan? (y/n): ").lower() == "y":
bp.apply(connection, plan)
This will always output that we need to apply:
[ResourceChange(action=<Action.ADD: 'add'>, urn=URN(urn::<REDACTED>:grant/TITAN_TEST_ROLE?priv=usage&on=warehouse/TITAN_TEST_WAREHOUSE), before={}, after={'priv': 'usage', 'on': 'TITAN_TEST_WAREHOUSE', 'on_type': 'WAREHOUSE', 'to': Resource:TITAN_TEST_ROLE, 'grant_option': False, 'owner': 'SYSADMIN', '_privs': ['usage']}, delta={'priv': 'usage', 'on': 'TITAN_TEST_WAREHOUSE', 'on_type': 'WAREHOUSE', 'to': Resource:TITAN_TEST_ROLE, 'grant_option': False, 'owner': 'SYSADMIN', '_privs': ['usage']})]
In other words, even though SHOW GRANTS TO ROLE TITAN_TEST_ROLE
returns 1 record, as it should, titan[core] just ignores this. Here, the issue is more annoying that detrimental but it can cause confusion.
Same bug found for grants on other objects such as databases. The after and deltas are the same, before is empty, but the show grants return results. Unless this is intentional and you want to run the grants every single time you apply the blueprint?
I have confirmed the bug locally, will fix in the next release.