Skip to content

Commit

Permalink
chore: support available condition for instanceSet
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei committed Jun 23, 2024
1 parent 482ae1b commit bc1361a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
4 changes: 4 additions & 0 deletions controllers/apps/operations/ops_progress_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ func handleScaleOutProgressWithInstanceSet(
compStatus *appsv1alpha1.OpsRequestComponentStatus) (completedCount int32, err error) {
currPodRevisionMap, _ := instanceset.GetRevisions(its.Status.CurrentRevisions)
notReadyPodSet := instanceset.GetPodNameSetFromInstanceSetCondition(its, workloads.InstanceReady)
notAvailablePodSet := instanceset.GetPodNameSetFromInstanceSetCondition(its, workloads.InstanceAvailable)
failurePodSet := instanceset.GetPodNameSetFromInstanceSetCondition(its, workloads.InstanceFailure)
pgRes.opsMessageKey = "Create"
memberStatusMap := map[string]sets.Empty{}
Expand All @@ -479,6 +480,9 @@ func handleScaleOutProgressWithInstanceSet(
updateProgressDetailForHScale(opsRes, pgRes, compStatus, objectKey, appsv1alpha1.ProcessingProgressStatus)
continue
}
if _, ok := notAvailablePodSet[podName]; ok {
continue
}
if _, ok := memberStatusMap[podName]; !ok && needToCheckRole(pgRes) {
continue
}
Expand Down
8 changes: 6 additions & 2 deletions controllers/apps/opsrequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ func (r *OpsRequestReconciler) reconcileStatusDuringRunningOrCanceling(reqCtx in
opsRequest := opsRes.OpsRequest
// wait for OpsRequest.status.phase to Succeed
if requeueAfter, err := operations.GetOpsManager().Reconcile(reqCtx, r.Client, opsRes); err != nil {
r.Recorder.Eventf(opsRequest, corev1.EventTypeWarning, reasonOpsReconcileStatusFailed, "Failed to reconcile the status of OpsRequest: %s", err.Error())
if !apierrors.IsConflict(err) {
r.Recorder.Eventf(opsRequest, corev1.EventTypeWarning, reasonOpsReconcileStatusFailed, "Failed to reconcile the status of OpsRequest: %s", err.Error())
}
return intctrlutil.ResultToP(intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, ""))
} else if requeueAfter != 0 {
// if the reconcileAction need requeue, do it
Expand Down Expand Up @@ -300,7 +302,9 @@ func (r *OpsRequestReconciler) doOpsRequestAction(reqCtx intctrlutil.RequestCtx,
opsDeepCopy := opsRequest.DeepCopy()
res, err := operations.GetOpsManager().Do(reqCtx, r.Client, opsRes)
if err != nil {
r.Recorder.Eventf(opsRequest, corev1.EventTypeWarning, reasonOpsDoActionFailed, "Failed to process the operation of OpsRequest: %s", err.Error())
if !apierrors.IsConflict(err) {
r.Recorder.Eventf(opsRequest, corev1.EventTypeWarning, reasonOpsDoActionFailed, "Failed to process the operation of OpsRequest: %s", err.Error())
}
if !reflect.DeepEqual(opsRequest.Status, opsDeepCopy.Status) {
if patchErr := r.Client.Status().Patch(reqCtx.Ctx, opsRequest, client.MergeFrom(opsDeepCopy)); patchErr != nil {
return intctrlutil.ResultToP(intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, ""))
Expand Down
1 change: 1 addition & 0 deletions controllers/apps/transformer_component_workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ func copyAndMergeITS(oldITS, newITS *workloads.InstanceSet, synthesizeComp *comp
itsObjCopy.Spec.Credential = itsProto.Spec.Credential
itsObjCopy.Spec.Instances = itsProto.Spec.Instances
itsObjCopy.Spec.OfflineInstances = itsProto.Spec.OfflineInstances
itsObjCopy.Spec.MinReadySeconds = itsProto.Spec.MinReadySeconds

if itsProto.Spec.UpdateStrategy.Type != "" || itsProto.Spec.UpdateStrategy.RollingUpdate != nil {
updateUpdateStrategy(itsObjCopy, itsProto)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/factory/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func BuildInstanceSet(synthesizedComp *component.SynthesizedComponent, component
AddAnnotationsInMap(mergeAnnotations).
AddMatchLabelsInMap(labels).
SetReplicas(synthesizedComp.Replicas).
SetMinReadySeconds(synthesizedComp.MinReadySeconds).
SetMinReadySeconds(10).
SetTemplate(template)

var vcts []corev1.PersistentVolumeClaim
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/instanceset/reconciler_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (r *statusReconciler) Reconcile(tree *kubebuilderx.ObjectTree) (*kubebuilde
}
meta.SetStatusCondition(&its.Status.Conditions, *readyCondition)

availableCondition, err := buildAvailableCondition(its, availableReplicas >= readyReplicas, notAvailableNames)
availableCondition, err := buildAvailableCondition(its, availableReplicas >= replicas, notAvailableNames)
if err != nil {
return nil, err
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/controller/kubebuilderx/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/apecloud/kubeblocks/pkg/controller/graph"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
)

Expand Down Expand Up @@ -108,15 +107,16 @@ func (c *controller) Commit() error {
return nil
}
builder := NewPlanBuilder(c.ctx, c.cli, c.oldTree, c.tree, c.recorder, c.logger)
if c.err = builder.Init(); c.err != nil {
return c.err
if err := builder.Init(); err != nil {
return err
}
var plan graph.Plan
plan, c.err = builder.Build()
if c.err != nil {
return c.err
plan, err := builder.Build()
if err != nil {
return err
}
if err = plan.Execute(); err != nil {
return err
}
c.err = plan.Execute()
return c.err
}

Expand Down

0 comments on commit bc1361a

Please sign in to comment.