Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
apiserver/uniter: Ignore EnterScope with invalid principals #7542
Conversation
babbageclunk
added some commits
Jun 22, 2017
| + Relation: mysqlRel.Tag().String(), | ||
| + Unit: wpLoggingU.Tag().String(), | ||
| + }}} | ||
| + result, err := api.EnterScope(args) |
wallyworld
Jun 22, 2017
Owner
We should check not just that the error is nil, but also that nothing has been done
babbageclunk
Jun 22, 2017
Member
Well, I thought this was ok, because the way you check whether it's in scope is by creating a RelationUnit and then calling ru.InScope(). I'll change it to look in the DB.
| + | ||
| +// IsInvalidPrincipalError returns whether the given error or its | ||
| +// cause is ErrInvalidPrincipal. | ||
| +func IsInvalidPrincipalError(err interface{}) bool { |
babbageclunk
Jun 22, 2017
Member
I was copying (maybe cargo-culting?) this from the other is-error functions in the file.
babbageclunk
Jun 22, 2017
Member
As discussed in IRC, it doesn't look like there's any good reason for this - pretty much all the other Is*Error functions in the codebase take error. I'll change it.
| + return false | ||
| + } | ||
| + // In case of a wrapped error, check the cause first. | ||
| + value := err |
wallyworld
Jun 22, 2017
Owner
don't need all this
_, ok := errors.Cause(err).(*ErrInvalidPrincipal)
return ok
|
!!build!! |
babbageclunk
referenced this pull request
Jun 23, 2017
Merged
apiserver/uniter: Ignore EnterScope from invalid units #7547
added a commit
that referenced
this pull request
Jun 23, 2017
|
Superseded by #7547. |
babbageclunk
closed this
Jun 23, 2017
babbageclunk
deleted the
babbageclunk:bad-relationunits
branch
Jun 23, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
babbageclunk commentedJun 22, 2017
Description of change
If an uniter for a subordinate unit requests to EnterScope for a
relation that isn't valid because its principal isn't a member of the
relation, we ignore it. This is needed for clean upgrading from 2.1 to
2.2.1 - there's an upgrade step that corrects unitcounts and invalid
relationscope records, but without this change the agents will re-enter
the scopes incorrectly when they reconnect to the controller (because we
don't get a chance to upgrade them first).
QA steps
Bug reference
Actually fixes https://bugs.launchpad.net/juju/+bug/1699050