Note: The handling of closer should be done by caller.
(closer *z.Closer, ns uint64)
| 429 | |
| 430 | // Note: The handling of closer should be done by caller. |
| 431 | func upsertGuardianAndGroot(closer *z.Closer, ns uint64) { |
| 432 | if worker.Config.AclSecretKey == nil { |
| 433 | // The acl feature is not turned on. |
| 434 | return |
| 435 | } |
| 436 | for closer.Ctx().Err() == nil { |
| 437 | ctx, cancel := context.WithTimeout(closer.Ctx(), time.Minute) |
| 438 | defer cancel() |
| 439 | ctx = x.AttachNamespace(ctx, ns) |
| 440 | if err := upsertGuardian(ctx); err != nil { |
| 441 | glog.Infof("Unable to upsert the guardian group. Error: %v", err) |
| 442 | time.Sleep(100 * time.Millisecond) |
| 443 | continue |
| 444 | } |
| 445 | break |
| 446 | } |
| 447 | |
| 448 | for closer.Ctx().Err() == nil { |
| 449 | ctx, cancel := context.WithTimeout(closer.Ctx(), time.Minute) |
| 450 | defer cancel() |
| 451 | ctx = x.AttachNamespace(ctx, ns) |
| 452 | if err := upsertGroot(ctx, "password"); err != nil { |
| 453 | glog.Infof("Unable to upsert the groot account. Error: %v", err) |
| 454 | time.Sleep(100 * time.Millisecond) |
| 455 | continue |
| 456 | } |
| 457 | break |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | // upsertGuardian must be called after setting the namespace in the context. |
| 462 | func upsertGuardian(ctx context.Context) error { |
no test coverage detected