Skip to content

Commit d638c79

Browse files
Policies guide: more updates
1 parent 13b376d commit d638c79

File tree

1 file changed

+128
-76
lines changed

1 file changed

+128
-76
lines changed

versioned_docs/version-4.1/policies.md

Lines changed: 128 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,58 @@ PUT /api/policies/%2f/ttl-fed
374374
By doing that all the queues matched by the pattern "^tf\\." will have the `"federation-upstream-set"`
375375
and the policy definitions applied to them.
376376

377+
378+
## Deleting a Policy
379+
380+
A policy can be deleted using `rabbitmqctl clear_policy` or `rabbitmqadmin policies delete`.
381+
382+
<Tabs groupId="examples">
383+
<TabItem value="bash" label="rabbitmqctl with bash" default>
384+
```bash
385+
rabbitmqctl clear_policy --vhost "vh.1" "policy.name"
386+
```
387+
</TabItem>
388+
389+
<TabItem value="rabbitmqadmin" label="rabbitmqadmin with bash">
390+
```bash
391+
rabbitmqadmin --vhost "vh.1" policies delete --name "policy.name"
392+
```
393+
</TabItem>
394+
395+
<TabItem value="PowerShell" label="rabbitmqctl with PowerShell">
396+
```PowerShell
397+
rabbitmqctl.bat clear_policy --vhost "vh.1" "policy.name"
398+
```
399+
</TabItem>
400+
401+
<TabItem value="rabbitmqadmin-PowerShell" label="rabbitmqadmin with PowerShell">
402+
```PowerShell
403+
rabbitmqadmin --vhost "vh.1" policies delete --name "policy.name"
404+
```
405+
</TabItem>
406+
407+
<TabItem value="HTTP API" label="HTTP API">
408+
```ini
409+
DELETE /api/policies/vh.1/policy.name
410+
```
411+
</TabItem>
412+
413+
<TabItem value="Management UI" label="Management UI">
414+
<ol>
415+
<li>
416+
Navigate to `Admin` > `Policies` > Click on the policy to delete.
417+
</li>
418+
<li>
419+
Click "Delete this policy"
420+
</li>
421+
<li>
422+
Confirm the operation.
423+
</li>
424+
</ol>
425+
</TabItem>
426+
</Tabs>
427+
428+
377429
## Declaring an Override (a Temporary Overriding Policy) {#override}
378430

379431
[`rabbitmqadmin`](./management-cli) can be used to declare an override, or an overriding policy.
@@ -424,6 +476,82 @@ rabbitmqadmin --vhost "vh.1" policies delete --name "overrides.pol.1"
424476

425477

426478

479+
## Updating Policies {#updating}
480+
481+
A policy can be updated by re-declaring it with a different definition, priority, and so on.
482+
This requires the operator to have a full policy definition.
483+
484+
Alternatively, [`rabbitmqadmin` v2](./management-cli) provides commands that can modify
485+
policy definitions, declare override policies and blanket policies.
486+
487+
### Policy Redefinition {#redefining}
488+
489+
If a full policy definition is known, [redefining](#defining) a policy with an updated definition
490+
and (optionally) a new priority but the same original name will update it.
491+
492+
:::important
493+
494+
The effects of new settings on queues, streams and exchanges will take a moment to become effective,
495+
in particular for clusters with a large number of entites (say, thousands).
496+
497+
:::
498+
499+
### Deleting Policy Definition Keys {#deleting-keys}
500+
501+
To delete one or multiple keys from a policy definition, use [`rabbitmqadmin policies delete_definition_keys`](./management-cli):
502+
503+
<Tabs groupId="examples">
504+
<TabItem value="bash" label="bash" default>
505+
```bash
506+
# removes all keys related to classic queue mirroring (that feature was removed in RabbitMQ 4.x)
507+
# from the definition of a policy named "cq.policies.1" in virtual host vh-1
508+
rabbitmqadmin --vhost "vh-1" policies delete_definition_keys --name "cq.policies.1" --definition-keys "ha-mode,ha-params,ha-promote-on-shutdown,ha-promote-on-failure,ha-sync-mode,ha-sync-batch-size"
509+
```
510+
</TabItem>
511+
512+
<TabItem value="PowerShell" label="PowerShell">
513+
```PowerShell
514+
# removes all keys related to classic queue mirroring (that feature was removed in RabbitMQ 4.x)
515+
# from the definition of a policy named "cq.policies.1" in virtual host vh-1
516+
rabbitmqadmin --vhost "vh-1" policies delete_definition_keys --name "cq.policies.1" --definition-keys "ha-mode,ha-params,ha-promote-on-shutdown,ha-promote-on-failure,ha-sync-mode,ha-sync-batch-size"
517+
```
518+
</TabItem>
519+
</Tabs>
520+
521+
522+
The `--definitions-keys` parameter accepts a single definition key or a command-separated list of keys.
523+
524+
To perform the same operation across all policies in a virtual host, use [`rabbitmqadmin policies delete_definition_keys_from_all_in`](./management-cli):
525+
526+
```bash
527+
# removes all keys related to classic queue mirroring (that feature was removed in RabbitMQ 4.x)
528+
# from all policy definitions in virtual host vh-1
529+
rabbitmqadmin --vhost "vh-1" policies delete_definition_keys_from_all_in --definition-keys "ha-mode,ha-params,ha-promote-on-shutdown,ha-promote-on-failure,ha-sync-mode,ha-sync-batch-size"
530+
```
531+
532+
533+
### Partially Updating Policy Definition {#patching}
534+
535+
[`rabbitmqadmin policies patch`](./management-cli) is a command that can update a policy
536+
using a partial definition, for example, to add a [`max-length` key](./maxlength/) to an existing
537+
policy:
538+
539+
```bash
540+
rabbitmqadmin policies patch --name "cq.pol.1" --definition '{"max-length": 1000000}'
541+
```
542+
543+
The new `--definition` object will be merged into the existing policy definition.
544+
545+
In the following example, an existing policy named `queues.pol.1` in the default virtual host (`/`)
546+
is updated to enable [queue federation](./federated-queues) to all the configured upstreams for the matched queues,
547+
without affecting the rest of the policy definitions:
548+
549+
```bash
550+
rabbitmqadmin policies patch --name "queues.pol.1" --definition '{"federation-upstream-set":"all"}'
551+
```
552+
553+
554+
427555
## Operator Policies {#operator-policies}
428556

429557
### Difference From Regular Policies {#why-operator-policies-exist}
@@ -728,82 +856,6 @@ HTTP API and Web UI.
728856
management.restrictions.operator_policy_changes.disabled = true
729857
```
730858

731-
## Updating Policies {#updating}
732-
733-
A policy can be updated by re-declaring it with a different definition, priority, and so on.
734-
This requires the operator to have a full policy definition.
735-
736-
Alternatively, [`rabbitmqadmin` v2](./management-cli) provides commands that can modify
737-
policy definitions, declare override policies and blanket policies.
738-
739-
### Policy Redefinition {#redefining}
740-
741-
If a full policy definition is known, [redefining](#defining) a policy with an updated definition
742-
and (optionally) a new priority but the same original name will update it.
743-
744-
:::important
745-
746-
The effects of new settings on queues, streams and exchanges will take a moment to become effective,
747-
in particular for clusters with a large number of entites (say, thousands).
748-
749-
:::
750-
751-
### Deleting Policy Definition Keys {#deleting-keys}
752-
753-
To delete one or multiple keys from a policy definition, use [`rabbitmqadmin policies delete_definition_keys`](./management-cli):
754-
755-
<Tabs groupId="examples">
756-
<TabItem value="bash" label="bash" default>
757-
```bash
758-
# removes all keys related to classic queue mirroring (that feature was removed in RabbitMQ 4.x)
759-
# from the definition of a policy named "cq.policies.1" in virtual host vh-1
760-
rabbitmqadmin --vhost "vh-1" policies delete_definition_keys --name "cq.policies.1" --definition-keys "ha-mode,ha-params,ha-promote-on-shutdown,ha-promote-on-failure,ha-sync-mode,ha-sync-batch-size"
761-
```
762-
</TabItem>
763-
764-
<TabItem value="PowerShell" label="PowerShell">
765-
```PowerShell
766-
# removes all keys related to classic queue mirroring (that feature was removed in RabbitMQ 4.x)
767-
# from the definition of a policy named "cq.policies.1" in virtual host vh-1
768-
rabbitmqadmin --vhost "vh-1" policies delete_definition_keys --name "cq.policies.1" --definition-keys "ha-mode,ha-params,ha-promote-on-shutdown,ha-promote-on-failure,ha-sync-mode,ha-sync-batch-size"
769-
```
770-
</TabItem>
771-
</Tabs>
772-
773-
774-
The `--definitions-keys` parameter accepts a single definition key or a command-separated list of keys.
775-
776-
To perform the same operation across all policies in a virtual host, use [`rabbitmqadmin policies delete_definition_keys_from_all_in`](./management-cli):
777-
778-
```bash
779-
# removes all keys related to classic queue mirroring (that feature was removed in RabbitMQ 4.x)
780-
# from all policy definitions in virtual host vh-1
781-
rabbitmqadmin --vhost "vh-1" policies delete_definition_keys_from_all_in --definition-keys "ha-mode,ha-params,ha-promote-on-shutdown,ha-promote-on-failure,ha-sync-mode,ha-sync-batch-size"
782-
```
783-
784-
785-
### Partially Updating Policy Definition {#patching}
786-
787-
[`rabbitmqadmin policies patch`](./management-cli) is a command that can update a policy
788-
using a partial definition, for example, to add a [`max-length` key](./maxlength/) to an existing
789-
policy:
790-
791-
```bash
792-
rabbitmqadmin policies patch --name "cq.pol.1" --definition '{"max-length": 1000000}'
793-
```
794-
795-
The new `--definition` object will be merged into the existing policy definition.
796-
797-
In the following example, an existing policy named `queues.pol.1` in the default virtual host (`/`)
798-
is updated to enable [queue federation](./federated-queues) to all the configured upstreams for the matched queues,
799-
without affecting the rest of the policy definitions:
800-
801-
```bash
802-
rabbitmqadmin policies patch --name "queues.pol.1" --definition '{"federation-upstream-set":"all"}'
803-
```
804-
805-
806-
807859

808860
## Troubleshooting
809861

0 commit comments

Comments
 (0)