|
1 | 1 | // |
2 | 2 | // DISCLAIMER |
3 | 3 | // |
4 | | -// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany |
| 4 | +// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany |
5 | 5 | // |
6 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | // you may not use this file except in compliance with the License. |
@@ -40,6 +40,7 @@ import ( |
40 | 40 | "github.com/arangodb/kube-arangodb/pkg/deployment/features" |
41 | 41 | "github.com/arangodb/kube-arangodb/pkg/deployment/member" |
42 | 42 | "github.com/arangodb/kube-arangodb/pkg/deployment/pod" |
| 43 | + "github.com/arangodb/kube-arangodb/pkg/deployment/reconciler" |
43 | 44 | "github.com/arangodb/kube-arangodb/pkg/util" |
44 | 45 | "github.com/arangodb/kube-arangodb/pkg/util/constants" |
45 | 46 | "github.com/arangodb/kube-arangodb/pkg/util/errors" |
@@ -438,8 +439,12 @@ func (r *Resources) createPodForMember(ctx context.Context, cachedStatus inspect |
438 | 439 |
|
439 | 440 | ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx) |
440 | 441 | defer cancel() |
| 442 | + |
441 | 443 | podName, uid, err := CreateArangoPod(ctxChild, cachedStatus.PodsModInterface().V1(), apiObject, spec, group, CreatePodFromTemplate(template.PodSpec)) |
442 | 444 | if err != nil { |
| 445 | + if uerr := r.context.WithMemberStatusUpdateErr(ctx, m.ID, group, updateMemberPhase(api.MemberPhaseCreationFailed)); uerr != nil { |
| 446 | + return errors.WithStack(uerr) |
| 447 | + } |
443 | 448 | return errors.WithStack(err) |
444 | 449 | } |
445 | 450 |
|
@@ -486,6 +491,9 @@ func (r *Resources) createPodForMember(ctx context.Context, cachedStatus inspect |
486 | 491 | defer cancel() |
487 | 492 | podName, uid, err := CreateArangoPod(ctxChild, cachedStatus.PodsModInterface().V1(), apiObject, spec, group, CreatePodFromTemplate(template.PodSpec)) |
488 | 493 | if err != nil { |
| 494 | + if uerr := r.context.WithMemberStatusUpdateErr(ctx, m.ID, group, updateMemberPhase(api.MemberPhaseCreationFailed)); uerr != nil { |
| 495 | + return errors.WithStack(uerr) |
| 496 | + } |
489 | 497 | return errors.WithStack(err) |
490 | 498 | } |
491 | 499 |
|
@@ -691,3 +699,19 @@ func CreatePodSuffix(spec api.DeploymentSpec) string { |
691 | 699 | hash := sha1.Sum(raw) |
692 | 700 | return fmt.Sprintf("%0x", hash)[:6] |
693 | 701 | } |
| 702 | + |
| 703 | +func updateMemberPhase(phase api.MemberPhase) reconciler.DeploymentMemberStatusUpdateErrFunc { |
| 704 | + return func(s *api.MemberStatus) (bool, error) { |
| 705 | + if s == nil { |
| 706 | + return false, nil |
| 707 | + } |
| 708 | + |
| 709 | + if s.Phase == phase { |
| 710 | + return false, nil |
| 711 | + } |
| 712 | + |
| 713 | + s.Phase = phase |
| 714 | + |
| 715 | + return true, nil |
| 716 | + } |
| 717 | +} |
0 commit comments