GCP的PULUMI GO SDK:无法销毁SQL Server

发布于 2025-02-13 02:04:51 字数 1666 浏览 1 评论 0 原文

我正在使用pulumi go sdk:当我尝试销毁堆栈时,我在其中提供了新的SQL数据库,数据库,密码和用户时,我会收到此错误消息:

21:00:33  [2022-07-05T18:00:33.872Z] Diagnostics:
21:00:33  [2022-07-05T18:00:33.874Z]   gcp:sql:User (gcp-test02-user:myuser):
21:00:33  [2022-07-05T18:00:33.875Z]     error: deleting urn:pulumi:us-east4-gcp-test02::cluster::gcp:myuser/sql:Database$gcp:sql/user:User::gcp-test02-user:myuser: 1 error occurred:
21:00:33  [2022-07-05T18:00:33.876Z]        * Error, failed to deleteuser myuser in instance gcp-test02-1b95d9a: googleapi: Error 400: Invalid request: failed to delete user myuser: . role "myuser" cannot be dropped because some objects depend on it Details: 640 objects in database mydatabases., invalid
21:00:33  [2022-07-05T18:00:33.877Z]  
21:00:33  [2022-07-05T18:00:33.877Z]   gcp:sql:Database (gcp-test02-db:mydatabases):
21:00:33  [2022-07-05T18:00:33.879Z]     error: deleting urn:pulumi:us-east4-auto-mgmt-console-gcp-test02::cluster::gcp:myuser/sql:Database$gcp:sql/database:Database::gcp-test02-db:mydatabases: 1 error occurred:
21:00:33  [2022-07-05T18:00:33.880Z]        * Error when reading or editing Database: googleapi: Error 400: Invalid request: failed to delete database "sentinellabs". Detail: pq: database "sentinellabs" is being accessed by other users. (Please use psql client to delete database that is not owned by "cloudsqlsuperuser")., invalid
21:00:33  [2022-07-05T18:00:33.881Z]  
21:00:33  [2022-07-05T18:00:33.881Z]   pulumi:pulumi:Stack (cluster-us-east4-auto-mgmt-console-gcp-test02):
21:00:33  [2022-07-05T18:00:33.882Z]     error: update failed

I am using Pulumi GO SDK: When I try to destroy stack where I provisioned a new SQL DatabaseInstance, Database, password and user I get this error message:

21:00:33  [2022-07-05T18:00:33.872Z] Diagnostics:
21:00:33  [2022-07-05T18:00:33.874Z]   gcp:sql:User (gcp-test02-user:myuser):
21:00:33  [2022-07-05T18:00:33.875Z]     error: deleting urn:pulumi:us-east4-gcp-test02::cluster::gcp:myuser/sql:Database$gcp:sql/user:User::gcp-test02-user:myuser: 1 error occurred:
21:00:33  [2022-07-05T18:00:33.876Z]        * Error, failed to deleteuser myuser in instance gcp-test02-1b95d9a: googleapi: Error 400: Invalid request: failed to delete user myuser: . role "myuser" cannot be dropped because some objects depend on it Details: 640 objects in database mydatabases., invalid
21:00:33  [2022-07-05T18:00:33.877Z]  
21:00:33  [2022-07-05T18:00:33.877Z]   gcp:sql:Database (gcp-test02-db:mydatabases):
21:00:33  [2022-07-05T18:00:33.879Z]     error: deleting urn:pulumi:us-east4-auto-mgmt-console-gcp-test02::cluster::gcp:myuser/sql:Database$gcp:sql/database:Database::gcp-test02-db:mydatabases: 1 error occurred:
21:00:33  [2022-07-05T18:00:33.880Z]        * Error when reading or editing Database: googleapi: Error 400: Invalid request: failed to delete database "sentinellabs". Detail: pq: database "sentinellabs" is being accessed by other users. (Please use psql client to delete database that is not owned by "cloudsqlsuperuser")., invalid
21:00:33  [2022-07-05T18:00:33.881Z]  
21:00:33  [2022-07-05T18:00:33.881Z]   pulumi:pulumi:Stack (cluster-us-east4-auto-mgmt-console-gcp-test02):
21:00:33  [2022-07-05T18:00:33.882Z]     error: update failed

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖心男生 2025-02-20 02:04:51

[...]无法删除用户myuser:。角色“ myuser”无法删除,因为某些对象取决于[...]

删除用户 (或删除角色)在角色仍然拥有任何东西或对其他对象有任何特权。

在GCP控制台中,在您的云SQL实例中,您应该使用 drop拥有 (这不是显而易见的) 。 <

[...]当前对象上给定角色的任何特权
数据库和共享对象(数据库,表空间)也将被撤销。

因此,删除角色的命令的顺序应该是:

REASSIGN OWNED BY myuser TO postgres;  
DROP OWNED BY myuser;

中运行两个命令,每个数据库角色拥有任何东西或具有任何特权。
然后:

DROP USER myuser;
  • 重新分配拥有的更改该角色当前拥有的所有对象的所有权。
  • Drop拥有的然后仅撤销特权(所有权不解决)。

再次尝试 pulumi Destroy 。

最后,您应该运行“ pulumi刷新”,然后CLI应该检测到它已被删除并将其从堆栈中取出。

Recommended:

[...] failed to delete user myuser: . role "myuser" cannot be dropped because some objects depend on it [...]

DROP USER(or DROP ROLE) cannot proceed while the role still owns anything or has any granted privileges on other objects.

In the GCP Console, in your Cloud SQL instance, you should get rid of all privileges with DROP OWNED (which isn't obvious). The manual:

[...] Any privileges granted to the given roles on objects in the current
database and on shared objects (databases, tablespaces) will also be revoked.

So the sequence of commands to drop a role should be:

REASSIGN OWNED BY myuser TO postgres;  
DROP OWNED BY myuser;

Run both commands in every database of the same cluster where the role owns anything or has any privileges.
And then:

DROP USER myuser;
  • REASSIGN OWNED changes ownership for all objects currently owned by the role.
  • DROP OWNED then only revokes privileges (ownerships out of the way).

Try again pulumi destroy.

Finally, you should run ‘pulumi refresh’, and then the CLI should detect that it was deleted and remove it from the stack.

Recommended:

饮惑 2025-02-20 02:04:51

看来可能在该SQL实例中添加了一个附加的数据库,该数据库正在访问和锁定。您可能必须登录到SQL实例并首先删除该数据库,然后运行 pulumi Refresh pulumi Destroy 。 400错误正在从Google返回。

It looks like there might be an additional database added to that sql instance that is being accessed and locked. You might have to login to the sql instance and drop that db first, then run pulumi refresh, and pulumi destroy. The 400 error is being returned from Google.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文