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 for #89 - Use custom UUID for NAB Object #101

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mpryc
Copy link
Collaborator

@mpryc mpryc commented Oct 14, 2024

With this change a new UUID is generated to reference parent/child relationship between objects in the Non Admin Controller use cases.

The first consumer of this UUID is a Velero Backup, created when the NonAdminBackup object is reconciled.

The NonAdminBackup object generates the NAC UUID and stores it in its Status. This prevents users from modifying it. The UUID is later used to create the Velero Backup during reconciliation.

While the NAC UUID is currently used as the Velero Backup name, this is not required, as the UUID is also stored as a Velero Backup label, which is used during the reconcile loop. Usage of NAC UUID as Velero Backup name is to easy it's creation.

This PR also includes small changes to fix linting issues of the code, as well reworks the tests to properly take advantage of gingko BeforeEach function.

Why the changes were made

Fixes #89
Fixes #90

@mpryc
Copy link
Collaborator Author

mpryc commented Oct 14, 2024

@shubham-pampattiwar FYI please review

With this change a new UUID is generated to reference parent/child relationship
between objects in the Non Admin Controller use cases.

The first consumer of this UUID is a Velero Backup, created when the
NonAdminBackup object is reconciled.

The NonAdminBackup object generates the NAC UUID and stores it in its
Status. This prevents users from modifying it. The UUID is later used
to create the Velero Backup during reconciliation.

While the NAC UUID is currently used as the Velero Backup name, this is
not required, as the UUID is also stored as a Velero Backup label, which
is used during the reconcile loop. Usage of NAC UUID as Velero Backup name
is to easy it's creation.

This PR also includes small changes to fix linting issues of the code,
as well reworks the tests to properly take advantage of gingko BeforeEach
function.

Signed-off-by: Michal Pryc <[email protected]>
Improved function to properly validate NAC Object Labels
Dropped length of Annotation Value validation, as it's not limited
to 63 or 256 chars.

Signed-off-by: Michal Pryc <[email protected]>
Changes to address code review.

Signed-off-by: Michal Pryc <[email protected]>
@mpryc
Copy link
Collaborator Author

mpryc commented Oct 16, 2024

@shubham-pampattiwar @mateusoliveira43 Added commit which I hope answers all comments.

ba85bd5

@shubham-pampattiwar
Copy link
Member

@mpryc ++

Renamed function which lists objects by label in a
specific namespace.

Signed-off-by: Michal Pryc <[email protected]>
Change to include:
 - Reworked diagram to include one reconcile entry and multiple states
 - Labels and annotations uses common function to check for the
   name and namespace value length
 - Additional test to cover above scenario.

Signed-off-by: Michal Pryc <[email protected]>
gomega.Expect(checkTestNonAdminBackupStatus(nonAdminBackup, scenario.ExpectedStatus, nonAdminNamespaceName, oadpNamespaceName)).To(gomega.Succeed())

gomega.Expect(checkTestNonAdminBackupStatus(nonAdminBackupAfterReconcile, scenario.nonAdminBackupExpectedStatus, oadpNamespace)).To(gomega.Succeed())
if scenario.uuidCreatedByReconcile {
Copy link
Contributor

Choose a reason for hiding this comment

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

this check needs to be moved inside checkTestNonAdminBackupStatus function

first expect in this if here is not valid, no? if namespace name is big, it wont be present in nameUUID

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know how to nicely do that without changing the arguments of the checkTestNonAdminBackupStatus function, which I do not want to do at this point. Added TODO and comment in the code.

The problem is that the structure in the nonAdminBackupSingleReconcileScenario can not take advantage of variables in an easy way, so we would need to pass some extra args to the checkTestNonAdminBackupStatus instead of using what's in the nonAdminBackupSingleReconcileScenario, bacause we are using here the nonAdminObjectNamespace whcih is var nonAdminObjectNamespace = fmt.Sprintf("test-nab-reconcile-%v", counter) assigned on every BeforeEach

Copy link
Contributor

@mateusoliveira43 mateusoliveira43 left a comment

Choose a reason for hiding this comment

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

note to self: would have done things a little different, setting UUID (only 36 length) as a NAB and Velero Backup label (less secure to use as label instead of status in NAB, but easier to iterate over). After creating UUID, would do get call in NAB and OADP namespace, to confirm UUID is unique in the cluster (#102), but that would not check things in storage provider.

Copy link
Collaborator Author

@mpryc mpryc left a comment

Choose a reason for hiding this comment

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

@mateusoliveira43 I think I responded to all of your comments. Please point me the ones which must be fixed before this will get merged, which we want to fix as follow up and which are just nice to have. Also I am not sure why it's approved by you with so many comments added.

@mpryc
Copy link
Collaborator Author

mpryc commented Oct 24, 2024

@mateusoliveira43 I've made changes and submitted last commit. There is still one unresolved comment in my opinion, which I've added TODO as I am not sure how to nicely change the current implementation to satisfy your request. Let me know if we can merge it with that or you want to make additional changes.

@mpryc
Copy link
Collaborator Author

mpryc commented Oct 25, 2024

@shubham-pampattiwar @mateusoliveira43 can we merge this or something else is stopping e.g. I am expected to propose corresponding PR to oadp operator? I am asking because based on this PR I have another one for NAB deletion pending, which I would like to submit for review.

Copy link

openshift-ci bot commented Oct 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mateusoliveira43, mpryc, shubham-pampattiwar

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 [mateusoliveira43,mpryc,shubham-pampattiwar]

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

@shubham-pampattiwar
Copy link
Member

/lgtm
@mpryc please create the corresponding OADP operator PR for CRD updates. From now on lets do both the PRs is parallel and merge the OADP Operator one first once changes are agreed upon on the NAC PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Review
3 participants