Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the pre-delete hook is recreated in hosted mode #231

Conversation

zhiweiyin318
Copy link
Member

No description provided.

@zhiweiyin318
Copy link
Member Author

/assign @qiujian16
/assign @zhujian7

Copy link
Member

@qiujian16 qiujian16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to add an integration test. e.g. add another finalizer to pend the addon deletion, and check if manifestwork recreation.

@zhiweiyin318
Copy link
Member Author

I think you need to add an integration test. e.g. add another finalizer to pend the addon deletion, and check if manifestwork recreation.

@qiujian16 have added.

}
return nil
}, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we wait for 5 seconds and check if work is not recreated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, updated the addon cr label to trigger reconcile 3 times to check if the per-delete manifestwork is not re-created.

Copy link
Member

@qiujian16 qiujian16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

Copy link
Contributor

openshift-ci bot commented Jan 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16, zhiweiyin318

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [qiujian16,zhiweiyin318]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@qiujian16
Copy link
Member

leave to @zhujian7 for final review

return addon, err
}
} else {
// cleanup is safe here since there is no case which HookManifestCompleted condition is changed from true to false.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it fails to cleanup hook work/remove finalizer here, it also could result in creating the hook again, right?

Copy link
Member Author

@zhiweiyin318 zhiweiyin318 Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, if go to clean part, that means the hookcompleted condition is true, so that means the addon after this in the queue has the true hookcompleted condition, that will never go to apply manifestwork part.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it fails at the cleanup part, it returns, so no chance to add the hook completed condition right?
But it is a corner case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, if it fails at the cleanup part, that means the hookcompleted condition has been true. no place to change the condition to false.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it!

@@ -214,7 +214,7 @@ func TestHostingHookReconcile(t *testing.T) {
},
},
{
name: "deploy hook manifest for a deleting addon with 2 finalizer, completed",
name: "deploy hook manifest for a deleting addon with 2 finalizer, completed,without completed condition",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name is confusing, I do not know if it is complete or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

t.Errorf("expected no HostingPreDeleteHookFinalizer on addon.")
}
if !meta.IsStatusConditionTrue(addOn.Status.Conditions, addonapiv1alpha1.ManagedClusterAddOnHookManifestCompleted) {
t.Errorf("HookManifestCompleted condition should be true,but got false.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Errorf("HookManifestCompleted condition should be true,but got false.")
t.Errorf("HookManifestCompleted condition should be true, but got false.")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

test/integration/agent_hosting_hook_deploy_test.go Outdated Show resolved Hide resolved
}
addon.Labels = map[string]string{"test": fmt.Sprintf("%d", i)}
_, err = hubAddonClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).
Update(context.Background(), addon, metav1.UpdateOptions{})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider putting the getting/updating into a retry block since it may fail with a conflict.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@zhiweiyin318 zhiweiyin318 force-pushed the fix-hostedmodepredelete branch 3 times, most recently from b8b2b00 to 5c56dde Compare January 23, 2024 04:09
Signed-off-by: Zhiwei Yin <zyin@redhat.com>
@zhujian7
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jan 23, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 71f1b13 into open-cluster-management-io:main Jan 23, 2024
9 checks passed
@zhiweiyin318 zhiweiyin318 deleted the fix-hostedmodepredelete branch January 23, 2024 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants