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

Cheksum is recalculated every time even without any change #198

Closed
headyj opened this issue Oct 5, 2023 · 5 comments · Fixed by #197
Closed

Cheksum is recalculated every time even without any change #198

headyj opened this issue Oct 5, 2023 · 5 comments · Fixed by #197
Labels
bug Something isn't working needs:triage

Comments

@headyj
Copy link

headyj commented Oct 5, 2023

Hello,

For any reason, the implementation of the checksum to avoid terraform init doesn't seems to work (#81)

2023-10-05T12:57:42.798Z	DEBUG	provider-terraform	Reconciling	{"controller": "managed/workspace.tf.upbound.io", "request": "/***"}
2023-10-05T12:57:43.431Z	DEBUG	provider-terraform	Checksums don't match so run terraform init:	{"request": "***", "old": "24ecf93858a5060f1e0578874edb3ab2", "new": "ee59f22df0b11e36cee43755ee7e8fa6"}

Even if nothing has changed, I have this kind of logs for all my workspaces every 5 minutes or so. If I get both folders and do a manual diff on my computer, it seems related to .git folder, but also on the lineage of the tfstate:

diff -r /tmp/terraform/old/ /tmp/terraform/new/
Only in /tmp/terraform/new/.git: FETCH_HEAD
Binary files /tmp/terraform/old/.git/index and /tmp/terraform/new/.git/index differ
diff -r /tmp/terraform/old/.git/logs/HEAD /tmp/terraform/New/.git/logs/HEAD
1,3c1,3
< 0000000000000000000000000000000000000000 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696518406 +0000  clone: from https://gitlab.*****/project.git
< 6161f8f8646d8f253530f855ed74b83dd9926cb2 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696518406 +0000  checkout: moving from develop to develop
< 6161f8f8646d8f253530f855ed74b83dd9926cb2 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696518406 +0000  checkout: moving from develop to develop
---
> 0000000000000000000000000000000000000000 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696522021 +0000  clone: from https://gitlab.*****/project.git
> 6161f8f8646d8f253530f855ed74b83dd9926cb2 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696522021 +0000  checkout: moving from develop to develop
> 6161f8f8646d8f253530f855ed74b83dd9926cb2 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696522021 +0000  checkout: moving from develop to develop
diff -r /tmp/terraform/old/.git/logs/refs/heads/develop /tmp/terraform/new/.git/logs/refs/heads/develop
1c1
< 0000000000000000000000000000000000000000 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696518406 +0000  clone: from https://gitlab.*****/project.git
---
> 0000000000000000000000000000000000000000 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696522021 +0000  clone: from https://gitlab.*****/project.git
diff -r /tmp/terraform/old/.git/logs/refs/remotes/origin/HEAD /tmp/terraform/new/.git/logs/refs/remotes/origin/HEAD
1c1
< 0000000000000000000000000000000000000000 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696518406 +0000  clone: from https://gitlab.*****/project.git
---
> 0000000000000000000000000000000000000000 6161f8f8646d8f253530f855ed74b83dd9926cb2 Unknown <unknown@provider-terraform-cd0c1afe87e6-75856796d7-fjq96.(none)> 1696522021 +0000  clone: from https://gitlab.*****/project.git
Only in /tmp/terraform/new/.git/objects/pack: pack-1db9c583ab505ce17ac6d40f23fcdf050f8c62ee.idx
Only in /tmp/terraform/new/.git/objects/pack: pack-1db9c583ab505ce17ac6d40f23fcdf050f8c62ee.pack
Only in /tmp/terraform/new/.git/objects/pack: pack-201b82d1141243f1f8509199a1bd79f2e60338a8.idx
Only in /tmp/terraform/new/.git/objects/pack: pack-201b82d1141243f1f8509199a1bd79f2e60338a8.pack
diff -r /tmp/terraform/old/.terraform/terraform.tfstate /tmp/terraform/new/.terraform/terraform.tfstate
4c4
<     "lineage": "7efead6a-8c4d-03b4-d416-f441d8c542a4",
---
>     "lineage": "09c6d6a2-a29f-6508-1b4e-b76b0545d584",
  • Crossplane Version: v1.13.2
  • Provider Version: v0.10.0
  • Kubernetes Version: v1.26
  • Kubernetes Distribution: EKS
@headyj headyj added bug Something isn't working needs:triage labels Oct 5, 2023
@bobh66
Copy link
Collaborator

bobh66 commented Oct 5, 2023

@headyj this appears to be a remote Workspace that is pulling from git and the git repo has changed? Maybe we should ignore the .git directory in the checksum calculation, as was suggested for the local plugins directory when the plugin cache is not used.

I assume that the selected branch has not changed or there would be other deltas to trigger the terraform init, and it's just the repo metadata that has changed because of changes in other branches.

Thoughts @ytsarev ?

@headyj
Copy link
Author

headyj commented Oct 5, 2023

Yes it's a remote source from git. The selected branch is actually a tag and hasn't changed. My concern is also about the lineage on the state which is different for any reason.

@headyj
Copy link
Author

headyj commented Oct 6, 2023

I did some further tests and I think that ignoring the .git directory should do the trick:

/usr/bin/find . -type f -not -path "./.git/*" -exec /usr/bin/md5sum {} + | LC_ALL=C /usr/bin/sort | /usr/bin/md5sum | /usr/bin/awk '{print $1}'

I guess the lineage differs because of the terraform init?

@headyj
Copy link
Author

headyj commented Dec 4, 2023

@bobh66 Unfortunately the problem seems to be still present in v0.12.0:

diff -r --exclude=.git before/e7c1772d-ed18-4152-b377-76e772881dfd after/e7c1772d-ed18-4152-b377-76e772881dfd
diff -r '--exclude=.git' before/e7c1772d-ed18-4152-b377-76e772881dfd/.terraform/terraform.tfstate after/e7c1772d-ed18-4152-b377-76e772881dfd/.terraform/terraform.tfstate
4c4
<     "lineage": "9ea5911a-af97-2a17-e6de-02744de7a523",
---
>     "lineage": "26605bb9-21a7-840b-58cd-00c67697da34",

I don't know why the lineage still differs, as nothing is changing and the provider is doing reconciliation at each poll (5 minutes by default)

@headyj
Copy link
Author

headyj commented Jan 5, 2024

@bobh66 any news about this? this issue is closed but doesn't seems to be solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage
Projects
None yet
2 participants