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

api: omit empty Digest in Artifact #1031

Merged
merged 1 commit into from
Feb 16, 2023
Merged

api: omit empty Digest in Artifact #1031

merged 1 commit into from
Feb 16, 2023

Conversation

hiddeco
Copy link
Member

@hiddeco hiddeco commented Feb 16, 2023

While we initially decided against it, this otherwise causes the regexp validator to error on an empty field when it goes through a YAML -> JSON encode loop (even when marked with +optional).

This is not actually a viable path the controller could take, as the controller trying to update the Artifact with an older version of the API package would omit the Digest field (because it does not exist in that version), while a newer version of the controller would always include the field (because we produce it for all kinds). While in cases where the controller would be backed by a Persistent Volume (and a partial status update is made), the validation rule would not be triggered because the field is not part of the patch.

However, for sake of correctness, we still issue a patch.

While we initially decided against it, this otherwise causes the regexp
validator to error on an empty field when it goes through a YAML -> JSON
encode loop (even when marked with `+optional`).

This is not actually a viable path the controller could take, as the
controller trying to update the Artifact with an older version of the
API package would omit the `Digest` field (because it does not exist
in that version), while a newer version of the controller would always
include the field (because we produce it for all kinds). While in cases
where the controller would be backed by a Persistent Volume (and a
partial status update is made), the validation rule would not be
triggered because the field is not part of the patch.

However, for sake of correctness, we still issue a patch.

Signed-off-by: Hidde Beydals <hello@hidde.co>
@hiddeco hiddeco added the area/git Git related issues and pull requests label Feb 16, 2023
@hiddeco
Copy link
Member Author

hiddeco commented Feb 16, 2023

To be one hundred percent sure I re-run a manual test which rolled over from v0.34.0 to v0.35.0 while being backed by a Persistent Volume, and the current v0.35.0 does not cause any issues without this.

Events:
  Type    Reason                      Age                    From               Message
  ----    ------                      ----                   ----               -------
  Normal  NewArtifact                 7m                     source-controller  stored artifact for commit 'Merge pull request #249 from exfly/be-fix-stress-t...'
  Normal  GitOperationSucceeded       5m42s (x3 over 6m)     source-controller  no changes since last reconcilation: observed revision 'master/eac008b339f65594e4bd694aab6e9bccd745e168'
  Normal  GitOperationSucceeded       4m10s (x2 over 5m10s)  source-controller  no changes since last reconcilation: observed revision 'master@sha1:eac008b339f65594e4bd694aab6e9bccd745e168'
  Normal  NewArtifact                 4m7s                   source-controller  stored artifact for commit 'Merge pull request #243 from stefanprodan/release-...'
  Normal  GarbageCollectionSucceeded  3m10s                  source-controller  garbage collected 1 artifacts
  Normal  GitOperationSucceeded       9s (x4 over 3m10s)     source-controller  no changes since last reconcilation: observed revision '6.3.1@sha1:f7a9563986812dfe696a88a39aace957d648c7c1'

Which is a timeline of:

  1. Creating an Artifact with v0.34.0.
  2. Reconciling again with v0.34.0.
  3. Reconciling again with v0.34.0 but with the CRDs from v0.35.0.
  4. Reconciling again with v0.35.0 and up-to-date CRDs.
  5. Changing the .spec.ref from branch to tag, which caused the intermediate patch to succeed even while the existing Artifact in the Status did not have a Digest.

@hiddeco
Copy link
Member Author

hiddeco commented Feb 16, 2023

Example where it does create an issue but is not a real scenario can be found in https://github.com/fluxcd/kustomize-controller/actions/runs/4197521470/jobs/7279943383

@hiddeco hiddeco merged commit 7abdb55 into main Feb 16, 2023
@hiddeco hiddeco deleted the omitempty-digest branch February 16, 2023 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/git Git related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants