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: put the update into a eventually to avoid flaky error. #557

Conversation

xuezhaojun
Copy link
Member

Summary

Sometimes the update operation need another try.

To avoid errors like the following:

  Event: [hub-managedclustercontroller] NamespaceCreated: Created Namespace/autoapprovaltest-spoke-cluster1 because it was missing 
  [FAILED] in [It] - /home/runner/work/ocm/ocm/test/integration/registration/spokecluster_autoapproval_test.go:134 @ 07/05/24 03:36:20.343
• [FAILED] [0.011 seconds]
Cluster Auto Approval [It] Cluster can be denied by manually after automatically approved
/home/runner/work/ocm/ocm/test/integration/registration/spokecluster_autoapproval_test.go:100

  [FAILED] Unexpected error:
      <*errors.StatusError | 0xc0004cc500>: 
      Operation cannot be fulfilled on managedclusters.cluster.open-cluster-management.io "autoapprovaltest-spoke-cluster1": the object has been modified; please apply your changes to the latest version and try again
      {
          ErrStatus: {
              TypeMeta: {Kind: "", APIVersion: ""},
              ListMeta: {
                  SelfLink: "",
                  ResourceVersion: "",
                  Continue: "",
                  RemainingItemCount: nil,
              },
              Status: "Failure",
              Message: "Operation cannot be fulfilled on managedclusters.cluster.open-cluster-management.io \"autoapprovaltest-spoke-cluster1\": the object has been modified; please apply your changes to the latest version and try again",
              Reason: "Conflict",
              Details: {
                  Name: "autoapprovaltest-spoke-cluster1",
                  Group: "cluster.open-cluster-management.io",
                  Kind: "managedclusters",
                  UID: "",
                  Causes: nil,
                  RetryAfterSeconds: 0,
              },
              Code: 409,
          },
      }
  occurred
  In [It] at: /home/runner/work/ocm/ocm/test/integration/registration/spokecluster_autoapproval_test.go:134 @ 07/05/24 03:36:20.343

@openshift-ci openshift-ci bot requested review from ldpliu and zhiweiyin318 July 5, 2024 04:17
Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.41%. Comparing base (b3f15c1) to head (e01f5e8).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #557   +/-   ##
=======================================
  Coverage   62.41%   62.41%           
=======================================
  Files         177      177           
  Lines       13857    13857           
=======================================
  Hits         8649     8649           
  Misses       4339     4339           
  Partials      869      869           
Flag Coverage Δ
unit 62.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xuezhaojun xuezhaojun closed this Jul 5, 2024
@xuezhaojun xuezhaojun reopened this Jul 5, 2024
@xuezhaojun xuezhaojun closed this Jul 5, 2024
@xuezhaojun xuezhaojun reopened this Jul 5, 2024
@xuezhaojun xuezhaojun closed this Jul 5, 2024
@xuezhaojun xuezhaojun reopened this Jul 5, 2024
@xuezhaojun xuezhaojun closed this Jul 8, 2024
@xuezhaojun xuezhaojun reopened this Jul 8, 2024
_, err = clusterClient.ClusterV1().ManagedClusters().Update(context.TODO(), updatedCluster, v1.UpdateOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Eventually(func() error {
_, err = clusterClient.ClusterV1().ManagedClusters().Update(context.TODO(), updatedCluster, v1.UpdateOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

I do not think it works, you need to also call get in eventually.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, updated.

Signed-off-by: xuezhaojun <zxue@redhat.com>
@xuezhaojun xuezhaojun force-pushed the fix-update-should-be-wrapped-in-a-Eventually branch from b6d95bd to e01f5e8 Compare July 8, 2024 02:37
@xuezhaojun
Copy link
Member Author

/assign @qiujian16

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
/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jul 8, 2024
Copy link
Contributor

openshift-ci bot commented Jul 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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:

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

@openshift-ci openshift-ci bot added the approved label Jul 8, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 5617fec into open-cluster-management-io:main Jul 8, 2024
14 checks passed
@xuezhaojun xuezhaojun deleted the fix-update-should-be-wrapped-in-a-Eventually branch July 9, 2024 15:04
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.

2 participants