|
| 1 | +// |
| 2 | +// DISCLAIMER |
| 3 | +// |
| 4 | +// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany |
| 5 | +// |
| 6 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | +// |
| 18 | +// Copyright holder is ArangoDB GmbH, Cologne, Germany |
| 19 | +// |
| 20 | + |
| 21 | +package deployment |
| 22 | + |
| 23 | +import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" |
| 24 | + |
| 25 | +func RecoverPodDetails(in *api.DeploymentStatus) (changed bool, _ error) { |
| 26 | + changed = false |
| 27 | + for _, m := range in.Members.AsList() { |
| 28 | + if m.Member.Pod == nil { |
| 29 | + // Pod is nil, recovery might be needed |
| 30 | + if m.Member.PodName != "" { |
| 31 | + m.Member.Pod = &api.MemberPodStatus{ |
| 32 | + Name: m.Member.PodName, |
| 33 | + UID: m.Member.PodUID, |
| 34 | + SpecVersion: m.Member.PodSpecVersion, |
| 35 | + } |
| 36 | + |
| 37 | + if err := in.Members.Update(m.Member, m.Group); err != nil { |
| 38 | + return false, err |
| 39 | + } |
| 40 | + changed = true |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | + return |
| 45 | +} |
0 commit comments