|
5 | 5 | "encoding/json" |
6 | 6 | "fmt" |
7 | 7 |
|
8 | | - sidecar "github.com/sei-protocol/seictl/sidecar/client" |
9 | 8 | "k8s.io/apimachinery/pkg/types" |
10 | 9 | "sigs.k8s.io/controller-runtime/pkg/log" |
11 | 10 |
|
@@ -70,7 +69,11 @@ func (e *updateNodeSpecsExecution) Status(_ context.Context) ExecutionStatus { |
70 | 69 | return e.status |
71 | 70 | } |
72 | 71 |
|
73 | | -// --- AwaitSpecUpdate: waits for StatefulSet rollout to complete --- |
| 72 | +// --- AwaitSpecUpdate: waits for each node's image update to complete --- |
| 73 | +// This task polls status.currentImage on each SeiNode. The SeiNode |
| 74 | +// controller's NodeUpdate plan handles the full rollout lifecycle |
| 75 | +// (apply-statefulset, observe-image, mark-ready) and stamps currentImage |
| 76 | +// only after the rollout is complete and the sidecar is re-initialized. |
74 | 77 |
|
75 | 78 | type awaitSpecUpdateExecution struct { |
76 | 79 | taskBase |
@@ -114,72 +117,3 @@ func (e *awaitSpecUpdateExecution) Status(ctx context.Context) ExecutionStatus { |
114 | 117 | e.complete() |
115 | 118 | return ExecutionComplete |
116 | 119 | } |
117 | | - |
118 | | -// --- MarkNodesReady: submits mark-ready to each node's sidecar --- |
119 | | - |
120 | | -type markNodesReadyExecution struct { |
121 | | - taskBase |
122 | | - params MarkNodesReadyParams |
123 | | - cfg ExecutionConfig |
124 | | - marked map[string]bool |
125 | | -} |
126 | | - |
127 | | -func deserializeMarkNodesReady(id string, params json.RawMessage, cfg ExecutionConfig) (TaskExecution, error) { |
128 | | - var p MarkNodesReadyParams |
129 | | - if len(params) > 0 { |
130 | | - if err := json.Unmarshal(params, &p); err != nil { |
131 | | - return nil, fmt.Errorf("deserializing mark-nodes-ready params: %w", err) |
132 | | - } |
133 | | - } |
134 | | - return &markNodesReadyExecution{ |
135 | | - taskBase: taskBase{id: id, status: ExecutionRunning}, |
136 | | - params: p, |
137 | | - cfg: cfg, |
138 | | - marked: make(map[string]bool, len(p.NodeNames)), |
139 | | - }, nil |
140 | | -} |
141 | | - |
142 | | -func (e *markNodesReadyExecution) Execute(_ context.Context) error { return nil } |
143 | | - |
144 | | -func (e *markNodesReadyExecution) Status(ctx context.Context) ExecutionStatus { |
145 | | - if s, done := e.isTerminal(); done { |
146 | | - return s |
147 | | - } |
148 | | - logger := log.FromContext(ctx) |
149 | | - |
150 | | - allReady := true |
151 | | - for _, name := range e.params.NodeNames { |
152 | | - if e.marked[name] { |
153 | | - continue |
154 | | - } |
155 | | - node := &seiv1alpha1.SeiNode{} |
156 | | - if err := e.cfg.KubeClient.Get(ctx, types.NamespacedName{Name: name, Namespace: e.params.Namespace}, node); err != nil { |
157 | | - allReady = false |
158 | | - continue |
159 | | - } |
160 | | - sc, err := sidecarClientForNode(node) |
161 | | - if err != nil { |
162 | | - allReady = false |
163 | | - continue |
164 | | - } |
165 | | - resp, err := sc.Status(ctx) |
166 | | - if err != nil { |
167 | | - allReady = false |
168 | | - continue |
169 | | - } |
170 | | - if resp.Status == sidecar.Ready { |
171 | | - e.marked[name] = true |
172 | | - continue |
173 | | - } |
174 | | - if _, err := sc.SubmitTask(ctx, sidecar.TaskRequest{Type: sidecar.TaskTypeMarkReady}); err != nil { |
175 | | - logger.V(1).Info("mark-ready submission failed", "node", name, "error", err) |
176 | | - } |
177 | | - allReady = false |
178 | | - } |
179 | | - |
180 | | - if allReady { |
181 | | - e.complete() |
182 | | - return ExecutionComplete |
183 | | - } |
184 | | - return ExecutionRunning |
185 | | -} |
0 commit comments