// Create some users, request them on the federated cluster so they're cached.
var users []arvados.User
- for userNr := range []int{1, 2} {
+ for userNr := range []int{0, 1} {
_, _, _, user := s.testClusters["z1111"].UserClients(
rootctx1,
c,
})
c.Assert(err, check.Equals, nil)
- // Re-request the list on the federated cluster
- _, err = conn3.UserList(rootctx1, arvados.ListOptions{Limit: math.MaxInt64})
+ // Re-request the list on the federated cluster & check for updates
+ lst, err := conn3.UserList(rootctx1, arvados.ListOptions{Limit: math.MaxInt64})
c.Assert(err, check.Equals, nil)
+ var user0Found, user1Found bool
+ for _, user := range lst.Items {
+ if user.UUID == users[0].UUID {
+ user0Found = true
+ c.Assert(user.Username, check.Equals, users[1].Username)
+ } else if user.UUID == users[1].UUID {
+ user1Found = true
+ c.Assert(user.Username, check.Equals, users[0].Username)
+ }
+ }
+ c.Assert(user0Found, check.Equals, true)
+ c.Assert(user1Found, check.Equals, true)
}
// Test for bug #16263
end
end
if needupdate.length > 0
- u.update_attributes!(needupdate)
+ begin
+ u.update_attributes!(needupdate)
+ rescue ActiveRecord::RecordInvalid
+ loginCluster = Rails.configuration.Login.LoginCluster
+ if u.uuid[0..4] == loginCluster && !needupdate[:username].nil?
+ local_user = User.find_by_username(needupdate[:username])
+ # A cached user record from the LoginCluster is stale, reset its username
+ # and retry the update operation.
+ if local_user.andand.uuid[0..4] == loginCluster && local_user.uuid != u.uuid
+ Rails.logger.warn("cached username '#{needupdate[:username]}' collision with user '#{local_user.uuid}' - resetting")
+ local_user.update_attributes!({username: nil})
+ retry
+ end
+ end
+ raise # Not the issue we're handling above
+ end
end
@objects << u
end