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

[WIP] fix: add changes to the Remediator to revert Config Sync metadata changes on drift #1486

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from

Conversation

Camila-B
Copy link
Contributor

@Camila-B Camila-B commented Nov 9, 2024

@Camila-B Camila-B requested a review from nan-yu November 9, 2024 00:58
Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from camila-b. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@Camila-B Camila-B changed the title fix: add changes to the Remediator to revert Config Sync metadata changes on drift [WIP] fix: add changes to the Remediator to revert Config Sync metadata changes on drift Nov 9, 2024
e2e/testcases/ignore_mutation_test.go Outdated Show resolved Hide resolved
core.Annotation(metadata.LifecycleMutationAnnotation, metadata.IgnoreMutation),
)
nt.Must(rootSyncGitRepo.Add("ns.yaml", nsObj))
nt.MustKubectl("apply", "-f", filepath.Join(rootSyncGitRepo.Root, "ns.yaml"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto. Suggesting using nt.KubeClient.Apply.

Also we need a cleanup block to delete the object in case the test fails halfway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced MustKubectl with nt.KubeClient.Apply. However, the test now fails. I explained the issue here #1477 (comment)

e2e/testcases/ignore_mutation_test.go Outdated Show resolved Hide resolved
e2e/testcases/ignore_mutation_test.go Outdated Show resolved Hide resolved
e2e/testcases/ignore_mutation_test.go Show resolved Hide resolved
@@ -781,9 +781,9 @@ func TestDriftKubectlAnnotateManagedFieldWithIgnoreMutationAnnotation(t *testing
))
})
tg.Go(func() error {
// Note: this proves that the applier does not currently honor the ignore-mutation annotation.
Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few ignore-mutation related test cases in this file. Can it be covered by the new ignore_mutation_test.go? It would be good to remove those duplicated tests.

pkg/applier/applier_test.go Outdated Show resolved Hide resolved
pkg/applier/applier_test.go Outdated Show resolved Hide resolved

applier.Apply(context.Background(), eventHandler, resources)

testutil.AssertEqual(t, tc.expectedObjsToApply, fakeKptApplier.objsToApply)
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to use fakeClient.Check(t, tc.expectedServerObjs...) so that we don't need to declare expectedObjsToApply as object.UnstructuredSet. Instead, it can be declared as []client.Object, which is simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now, the objects are not actually applied to the fake server when the fake KptApplier is called. Should the fake KptApplier's Run fn be modified to actually apply the objects? Or should a function be added to the fake client that converts a given object to the scheme-preferred version so that it can be used in the tests?

pkg/applier/applier_test.go Show resolved Hide resolved
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