This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
ensure.go
65 lines (60 loc) · 1.54 KB
/
ensure.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package kubernetes
import (
"github.com/caos/orbos/internal/api"
"github.com/caos/orbos/internal/operator/orbiter/kinds/clusters/core/infra"
"github.com/caos/orbos/mntr"
)
func ensure(
monitor mntr.Monitor,
clusterID string,
desired *DesiredV0,
kubeAPIAddress *infra.Address,
pdf api.PushDesiredFunc,
k8sClient *Client,
oneoff bool,
controlplane initializedPool,
controlplaneMachines []*initializedMachine,
workers []initializedPool,
workerMachines []*initializedMachine,
initializeMachine initializeMachineFunc,
uninitializeMachine uninitializeMachineFunc,
) (done bool, err error) {
done, err = maintainNodes(append(controlplaneMachines, workerMachines...), monitor, k8sClient, pdf)
if err != nil || !done {
return done, err
}
targetVersion := ParseString(desired.Spec.Versions.Kubernetes)
upgradingDone, err := ensureSoftware(
monitor,
targetVersion,
k8sClient,
controlplaneMachines,
workerMachines)
if err != nil || !upgradingDone {
monitor.Info("Upgrading is not done yet")
return upgradingDone, err
}
var scalingDone bool
scalingDone, err = ensureScale(
monitor,
clusterID,
desired,
pdf,
controlplane,
workers,
kubeAPIAddress,
targetVersion,
k8sClient,
oneoff,
func(created infra.Machine, pool initializedPool) initializedMachine {
machine := initializeMachine(created, pool)
target := targetVersion.DefineSoftware()
machine.desiredNodeagent.Software = &target
return *machine
},
uninitializeMachine)
if !scalingDone {
monitor.Info("Scaling is not done yet")
}
return scalingDone, err
}