Skip to content

Conversation

@lmiccini
Copy link
Contributor

@lmiccini lmiccini commented Dec 5, 2025

This commit:

  • adds RabbitMQUser and RabbitMQVhost CRDs
  • adds a basic client using the rabbitmq management api
  • modifies TransportURL to be able to reference users and vhosts
  • adds functional tests for RabbitMQUser and RabbitMQVhost
  • adds a RabbitMqConfig shared struct that can be used by other operators to configure the respective user and vhost

In addition:

  • reworks how Mirrored queues policy is applied to use the management api instead of a direct pod rsh
  • fixes an issue with the rabbitmq defaulting webhook that we broke with the sdk rebase

Operators can now perform rabbitmq credentials rotation by:

  • editing the openstackcontrolplane to point each service at a new user
  • wait the pods reconciliation
  • trigger the edpm deployment to apply the change to the data plane
  • finally delete the previous RabbitMQUser when desired

Rollback is possible by switching the service to use the previous RabbitMQUser.

Credential rotation happens without downtime since both the old and new credentials are valid at the same time.

Assisted-by: Claude (Anthropic AI)

@openshift-ci openshift-ci bot requested review from dciabrin and viroel December 5, 2025 09:40
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 5, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lmiccini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Dec 5, 2025
@lmiccini lmiccini requested review from stuggi and removed request for viroel December 5, 2025 11:30
},
Spec: rabbitmqv1.RabbitMQVhostSpec{RabbitmqClusterName: instance.Spec.RabbitmqClusterName, Name: vhostName},
}
if err := controllerutil.SetControllerReference(instance, vhost, r.Scheme); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if err !=nil?

Comment on lines 296 to 298
if !controllerutil.ContainsFinalizer(user, rabbitmqv1.UserFinalizer) {
controllerutil.AddFinalizer(user, rabbitmqv1.UserFinalizer)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, could just call AddFinalizer, it returns true if it got added.

},
Spec: rabbitmqv1.RabbitMQUserSpec{RabbitmqClusterName: instance.Spec.RabbitmqClusterName, Username: instance.Spec.Username, VhostRef: vhostRef},
}
if err := controllerutil.SetControllerReference(instance, user, r.Scheme); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, what if err !=nil?

if vhostName != "/" {
if err := apiClient.DeleteVhost(vhostName); err != nil {
// Log error but don't fail deletion - the vhost may already be gone
log.FromContext(ctx).Error(err, "Failed to delete vhost from RabbitMQ", "vhost", vhostName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok to just log?

@lmiccini lmiccini force-pushed the rabbitmq_vhosts branch 3 times, most recently from 85b6224 to 944d12b Compare December 6, 2025 13:50
@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/openstack-k8s-operators/infra-operator for 511,944d12baacad61d2dd7626038ab6eb7d8b06c15e

@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/openstack-k8s-operators/infra-operator for 511,a371354f8f55d3179e796224af190b5f6bfa457d

@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/openstack-k8s-operators/infra-operator for 511,b1562fc7b977ed317be5aa9413730a2c3fa10106

…otation

This commit:
- adds RabbitMQUser and RabbitMQVhost CRDs
- adds a basic client using the rabbitmq management api
- modifies TransportURL to be able to reference users and vhosts
- adds functional tests for RabbitMQUser and RabbitMQVhost
- adds a RabbitMqConfig shared struct that can be used by other
  operators to configure the respective user and vhost

In addition:
- reworks how Mirrored queues policy is applied to use the management
  api instead of a direct pod rsh

Operators can now perform rabbitmq credentials rotation by:
- editing the openstackcontrolplane to point each service at a new user
- wait the pods reconciliation
- trigger the edpm deployment to apply the change to the data plane
- finally delete the previous RabbitMQUser when desired

Rollback is possible by switching the service to use the previous RabbitMQUser.

Credential rotation happens without downtime since both the old and new
credentials are valid at the same time.

Assisted-by: Claude (Anthropic AI)
// Log non-NotFound errors but continue with deletion
log.FromContext(ctx).Error(err, "Failed to get admin secret")
}
// Skip policy deletion if credentials are not accessible - finalizer will still be removed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do I get it right that we proceed with deletion and say its ok that the policy remains on the cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my idea with this was not to block the cluster deletion in case we can't delete the poicy for whatever reason.

// Note: Delete methods already treat 404 as success
if err := apiClient.DeletePermissions(vhostName, username); err != nil {
// Log error but don't fail deletion - the permissions may already be gone
// Log error but don't fail deletion - finalizer will still be removed to prevent CR from being stuck
Copy link
Contributor

@stuggi stuggi Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't there be a side effect that permissions remain on the cluster? in case of debugging you could not rely on the CR status maps to what is on the cluster configured?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as previous comment, not sure if it's better to have the cluster stuck deleting if we can't delete the user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants