Cannot remove an offer with relations

Bug #1757926 reported by Stuart Bishop on 2018-03-22
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
juju
High
Ian Booth
2.3
High
Ian Booth

Bug Description

If I offer an application, I am unable to revoke the offer if there is a consumer. If I'm the manager of the offer, I am in charge of those resources and I should be able to revoke access without consulting the consumers (which I might not have access to, and may even be hostile).

$ juju remove-offer admin/default.hosted-db
ERROR cannot delete application offer "hosted-db": offer has 1 relation

Can't you "juju remove-relation" first?

John
=:->

On Thu, Mar 22, 2018 at 7:28 AM, Stuart Bishop <email address hidden>
wrote:

> Public bug reported:
>
> If I offer an application, I am unable to revoke the offer if there is a
> consumer. If I'm the manager of the offer, I am in charge of those
> resources and I should be able to revoke access without consulting the
> consumers (which I might not have access to, and may even be hostile).
>
>
> $ juju remove-offer admin/default.hosted-db
> ERROR cannot delete application offer "hosted-db": offer has 1 relation
>
> ** Affects: juju
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to juju.
> Matching subscriptions: juju bugs
> https://bugs.launchpad.net/bugs/1757926
>
> Title:
> Cannot remove an offer with relations
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/juju/+bug/1757926/+subscriptions
>

Ian Booth (wallyworld) wrote :

The idea was that you'd remove the relations first. There was an intent to add a --force or -y option to allow Juju to remove all existing relations prior to removing the offer. But we never got to it. Easy to add.

On 22/03/18 13:49, John A Meinel wrote:
> Can't you "juju remove-relation" first?
>
> John
> =:->
>
> On Thu, Mar 22, 2018 at 7:28 AM, Stuart Bishop <email address hidden>
> wrote:
>
> > Public bug reported:
> >
> > If I offer an application, I am unable to revoke the offer if there is a
> > consumer. If I'm the manager of the offer, I am in charge of those
> > resources and I should be able to revoke access without consulting the
> > consumers (which I might not have access to, and may even be hostile).
> >
> >
> > $ juju remove-offer admin/default.hosted-db
> > ERROR cannot delete application offer "hosted-db": offer has 1 relation
> >
> > ** Affects: juju
> >      Importance: Undecided
> >          Status: New
> >
> > --
> > You received this bug notification because you are subscribed to juju.
> > Matching subscriptions: juju bugs
> > https://bugs.launchpad.net/bugs/1757926
> >
> > Title:
> >   Cannot remove an offer with relations
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/juju/+bug/1757926/+subscriptions
> >
>

Stuart Bishop (stub) wrote :

'juju offers' lists the relation id, which can be removed with 'juju remove-relation'. It doesn't look like a normal relation id (no relname: prefix), but it works.

Changed in juju:
status: New → Invalid
Stuart Bishop (stub) wrote :

Spoke too soon. 'juju remove-relation 1' appears to succeed, and the units run the expected hooks, but 'juju offers' still lists the relation id and remove-relation still fails. 'juju remove-relation 1' can be run multiple times, but does nothing further.

Changed in juju:
status: Invalid → New
Ian Booth (wallyworld) wrote :

Juju models relation ids as either numeric or strings. Charms typically use the string form, but for connections to offer, the numeric form suits better.

We'll look into and fix the removal issue.

Changed in juju:
milestone: none → 2.3.5
importance: Undecided → High
status: New → Triaged
Ian Booth (wallyworld) wrote :

I'm having trouble reproducing this with a simple cross model mysql-mediawiki scenario using Juju 2.3.4
If I create a few cross model relations from a mysql app to several mediawikis, and then from the offering model remove-relation <id> on one of the ids, listing offers again shows the particular relation id has been deleted as expected.

Can you provide a little more info on how to reproduce the issue?

Changed in juju:
status: Triaged → Incomplete
Ian Booth (wallyworld) wrote :

Here's a PR which at least adds the option to --force remove an offer

https://github.com/juju/juju/pull/8527

Changed in juju:
milestone: 2.3.5 → none
Stuart Bishop (stub) wrote :

Here is the script to reproduce, at least with the lxd provider.

$ juju --version
2.3.4-xenial-amd64
$ juju add-model srv
Added 'srv' model on localhost/localhost with credential 'localhost' for user 'admin'
$ juju deploy cs:postgresql
Located charm "cs:postgresql-174".
Deploying charm "cs:postgresql-174".
$ juju add-model client
Added 'client' model on localhost/localhost with credential 'localhost' for user 'admin'
$ juju deploy cs:~postgresql-charmers/postgresql-client psql
Located charm "cs:~postgresql-charmers/postgresql-client-5".
Deploying charm "cs:~postgresql-charmers/postgresql-client-5".
$ juju offer psql:db client-db
Application "psql" endpoints [db] available at "admin/client.client-db"
$ juju switch srv
lxd:admin/client -> lxd:admin/srv
$ juju find-offers
Store URL Access Interfaces
lxd admin/client.client-db admin pgsql:db

$ juju consume admin/client.client-db psql
Added admin/client.client-db as psql
$ juju add-relation postgresql:db psql:db
$ juju wait
INFO:root:All units idle since 2018-03-26 07:38:53.346395Z (postgresql/0)
$ juju remove-relation postgresql:db psql:db
$ juju remove-consumed-application psql
$ juju switch client
lxd:admin/srv -> lxd:admin/client
$ juju status | cat
Model Controller Cloud/Region Version SLA
client lxd localhost/localhost 2.3.4 unsupported

App Version Status Scale Charm Store Rev OS Notes
psql 9.5 blocked 1 postgresql-client jujucharms 5 ubuntu

Unit Workload Agent Machine Public address Ports Message
psql/0* blocked idle 0 10.0.4.86 Needs db relation

Machine State DNS Inst id Series AZ Message
0 started 10.0.4.86 juju-6de2ae-0 xenial Running

Offer Application Charm Rev Connected Endpoint Interface Role
client-db psql postgresql-client 5 1/1 db pgsql requirer

$ juju list-offers
Offer User Relation id Status Endpoint Interface Role Ingress subnets
client-db admin 0 joined db pgsql requirer

$ juju remove-offer client-db
ERROR application offer URL is missing application
$ juju remove-relation 0
$ juju list-offers
Offer User Relation id Status Endpoint Interface Role Ingress subnets
client-db admin 0 joined db pgsql requirer

$ juju wait
INFO:root:All units idle since 2018-03-26 07:41:23.353477Z (psql/0)
$ juju list-offers
Offer User Relation id Status Endpoint Interface Role Ingress subnets
client-db admin 0 joined db pgsql requirer

$ juju remove-relation 0
$ juju remove-offer admin/client.client-db
ERROR cannot delete application offer "client-db": offer has 1 relation

Changed in juju:
status: Incomplete → New
Ian Booth (wallyworld) wrote :

I deployed the scenario in comment #8.

There's 2 ways of removing the relation to the offer: from the offering side of from the consuming side.

When doing it from the offering side, you juju remove-relation <id> and because that operates on the offering model directly, this removes the relation immediately and the offer can then be removed. You can use juju offers to see the connection to an offer and hence if <ids>s. There upcoming --force arg to remove-offer will remove all existing connections.

The bug report talks about removing the relation from the consuming side. I did this also as described. However, it takes a few seconds for the offering side to have the event that the relation is gone sent to it. I did "juju offers" a couple of times on the offering model and waited till the offer connection/relation was gone. Then I could delete the offer without using the --force flag.

Ian Booth (wallyworld) wrote :

Note: juju wait might not be appropriate here since things will appear idle in the offering model if the event signalling the relation is gone hasn't arrived yet. The Juju poll interval for such events is up to 5 seconds (not just for cross model things but all db event propagation).

tags: added: docteam
Ian Booth (wallyworld) on 2018-03-27
Changed in juju:
assignee: nobody → Ian Booth (wallyworld)
status: New → Fix Committed
milestone: none → 2.4-beta1
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers