mirror of
https://gitee.com/devstar/devstar-devcontainer-operator
synced 2025-09-09 03:25:50 +00:00
!2 CRD status Reporter + CI Workflow Test
* Added CI workflow for Dockerized k8s Operator * Added Readiness Listener based on StatefulSet.Status.ReadyReplicas * Update Readiness Probing timeout mechanism
This commit is contained in:
@@ -86,6 +86,23 @@ func (r *DevcontainerAppReconciler) Reconcile(ctx context.Context, req ctrl.Requ
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
} else {
|
||||
// 若 StatefulSet.Status.readyReplicas 变化,则更新 DevcontainerApp.Status.Ready 域(mark/un-mark)
|
||||
if statefulSetInNamespace.Status.ReadyReplicas > 0 {
|
||||
app.Status.Ready = true
|
||||
if err := r.Status().Update(ctx, app); err != nil {
|
||||
logger.Error(err, "Failed to update DevcontainerApp.Status.Ready", "DevcontainerApp.Status.Ready", app.Status.Ready)
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
logger.Info("DevContainer is now ready", "ReadyReplicas", statefulSetInNamespace.Status.ReadyReplicas)
|
||||
} else {
|
||||
app.Status.Ready = false
|
||||
if err := r.Status().Update(ctx, app); err != nil {
|
||||
logger.Error(err, "Failed to un-mark DevcontainerApp.Status.Ready", "DevcontainerApp.Status.Ready", app.Status.Ready)
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
logger.Info("DevContainer is NOT ready", "ReadyReplicas", statefulSetInNamespace.Status.ReadyReplicas)
|
||||
}
|
||||
|
||||
// 这里会反复触发更新
|
||||
// 原因:在 SetupWithManager方法中,监听了 StatefulSet ,所以只要更新 StatefulSet 就会触发
|
||||
// 此处更新和 controllerManager 更新 StatefulSet 都会触发更新事件,导致循环触发
|
||||
|
@@ -51,6 +51,11 @@ spec:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- exec cat /etc/ssh/ssh_host*.pub
|
||||
failureThreshold: 6
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 5
|
||||
resources:
|
||||
limits:
|
||||
cpu: 300m
|
||||
|
Reference in New Issue
Block a user