Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

[BUG] infinite loop reconcile yurtappdaemon #129

@adamzhoul

Description

@adamzhoul

What happened:
yurtappdaemon_controlle fall in infinite loop reconciles unchanged yurtappdaemon resource.
image

What you expected to happen:

reconcile only one time

How to reproduce it (as minimally and precisely as possible):

  • create a yurtappdaemon resource
  • update it (eg: update the image)

Anything else we need to know?:

reason:

  • calculateStatus only update CurrentRevision when it's empty.
    so new hash revision never applies to status when status has an old one.

But the reconciler creates new controllerrevisions when the hash is updated.

} else {
//if there is no equivalent revision we create a new one
updateRevision, err = r.createControllerRevision(ud, updateRevision, &collisionCount)
if err != nil {

func (r *ReconcileYurtAppDaemon) manageWorkloads(instance *unitv1alpha1.YurtAppDaemon, currentNodepoolToWorkload map[string]*workloadcontroller.Workload,
allNameToNodePools map[string]unitv1alpha1.NodePool, expectedRevision string, templateType unitv1alpha1.TemplateType) (newStatus *unitv1alpha1.YurtAppDaemonStatus, updateErr error) {
newStatus = instance.Status.DeepCopy()

func (r *ReconcileYurtAppDaemon) calculateStatus(instance *unitv1alpha1.YurtAppDaemon, newStatus *unitv1alpha1.YurtAppDaemonStatus,
currentRevision *appsv1.ControllerRevision, collisionCount int32, templateType unitv1alpha1.TemplateType) *unitv1alpha1.YurtAppDaemonStatus {
newStatus.CollisionCount = &collisionCount
if newStatus.CurrentRevision == "" {
// init with current revision
newStatus.CurrentRevision = currentRevision.Name
}

  • nodepool is an []string, which reflect.DeepEqual returns false when in a different order

func (r *ReconcileYurtAppDaemon) updateYurtAppDaemon(yad *unitv1alpha1.YurtAppDaemon, oldStatus, newStatus *unitv1alpha1.YurtAppDaemonStatus) (*unitv1alpha1.YurtAppDaemon, error) {
if oldStatus.CurrentRevision == newStatus.CurrentRevision &&
*oldStatus.CollisionCount == *newStatus.CollisionCount &&
oldStatus.TemplateType == newStatus.TemplateType &&
yad.Generation == newStatus.ObservedGeneration &&
reflect.DeepEqual(oldStatus.NodePools, newStatus.NodePools) &&
reflect.DeepEqual(oldStatus.Conditions, newStatus.Conditions) {
klog.Infof("YurtAppDaemon[%s/%s] oldStatus==newStatus, no need to update status", yad.GetNamespace(), yad.GetName())
return yad, nil
}

we check:reflect.DeepEqual(oldStatus.NodePools, newStatus.NodePools)
but nodepools come from a map. orders can not be made sure

for np := range allNameToNodePools {
nps = append(nps, np)
}
newStatus.NodePools = nps

Environment:

  • yurt-app-manager version: v0.6.0

/kind bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions