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: Update NAB status phase and condition together #86

Conversation

mateusoliveira43
Copy link
Contributor

Why the changes were made

As discussed with the team, we want to do less reconcile steps for NAB full reconcile loop (but keeping only making one update call per reconcile). With this PR, NAB reconcile update phases and conditions together in one update call.

Also, simplified Predicate and Handlers logic.

How to test the changes made

Run tests and check logs (make simulation-test) or test in a cluster following development documentation.

Copy link

openshift-ci bot commented Sep 24, 2024

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

if !checkAnnotationValueIsValid(annotations, constant.NabOriginNameAnnotation) {
return false
}
// TODO what is a valid uuid?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I have a different validation here? (from what we talked today, this is field will be removed, right? To add one ourselves)

Choose a reason for hiding this comment

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

It needs to be updated, not removed, created an issue for this #89

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can use go https://github.com/google/uuid to generate UUID ourselves.

Choose a reason for hiding this comment

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

yes or another option would be https://github.com/satori/go.uuid
But Google one seems like its more maintained.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@shubham-pampattiwar the satori one was last updated 6 years ago with ~37K uses, so I think it's better stick to something more active. google/uuid was updated 2 weeks ago so it's much more active project with ~320K uses.

Copy link
Member

Choose a reason for hiding this comment

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

yes certainly, google/uuid is the way to go.

@mateusoliveira43 mateusoliveira43 force-pushed the fix/update-phase-and-condition-together branch from 1d75275 to f5e9c6b Compare September 25, 2024 18:40
@mateusoliveira43 mateusoliveira43 marked this pull request as ready for review September 25, 2024 18:43
internal/common/constant/constant.go Show resolved Hide resolved
@@ -125,9 +127,9 @@ func GenerateVeleroBackupName(namespace, nabName string) string {
veleroBackupName := fmt.Sprintf("%s-%s-%s", constant.VeleroBackupNamePrefix, namespace, nameHash)

// Ensure the name is within the character limit
if len(veleroBackupName) > constant.MaxKubernetesNameLength {
if len(veleroBackupName) > validation.DNS1123SubdomainMaxLength {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this change.

Choose a reason for hiding this comment

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

+1

internal/handler/velerobackup_handler.go Show resolved Hide resolved
internal/predicate/nonadminbackup_predicate.go Outdated Show resolved Hide resolved
internal/predicate/velerobackup_predicate.go Outdated Show resolved Hide resolved
@@ -125,9 +127,9 @@ func GenerateVeleroBackupName(namespace, nabName string) string {
veleroBackupName := fmt.Sprintf("%s-%s-%s", constant.VeleroBackupNamePrefix, namespace, nameHash)

// Ensure the name is within the character limit
if len(veleroBackupName) > constant.MaxKubernetesNameLength {
if len(veleroBackupName) > validation.DNS1123SubdomainMaxLength {

Choose a reason for hiding this comment

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

+1

internal/predicate/velerobackup_predicate.go Outdated Show resolved Hide resolved
internal/predicate/velerobackup_predicate.go Outdated Show resolved Hide resolved
@shubham-pampattiwar
Copy link
Member

I tried creating a NAB backup using this PR and found some discrepancy in NAB status, it is showing phase as Created even though the VeleroBackup is Completed. Can you please double check for sanity ?

status:                                                                                                                                             17:33:00 [3/1874]
  conditions:                                                                                                                                                        
  - lastTransitionTime: "2024-10-02T00:31:42Z"                                                                                                                       
    message: backup accepted                                                                                                                                         
    reason: BackupAccepted
    status: "True"
    type: Accepted
  - lastTransitionTime: "2024-10-02T00:31:42Z"
    message: Created Velero Backup object 
    reason: BackupScheduled
    status: "True"
    type: Queued
  phase: Created
  veleroBackupName: nab-nacuser-e68ec47f50dc20
  veleroBackupNamespace: openshift-adp
  veleroBackupStatus:
    completionTimestamp: "2024-10-02T00:31:54Z"
    expiration: "2024-11-01T00:31:42Z"
    formatVersion: 1.1.0
    phase: Completed
    progress:
      itemsBackedUp: 71
      totalItems: 71

@mateusoliveira43
Copy link
Contributor Author

@shubham-pampattiwar this is expected per design https://github.com/migtools/oadp-non-admin/blob/master/docs/design/nab_status_update.md#phase

we only have 3 phases, created is the last one. We can change that

@shubham-pampattiwar
Copy link
Member

@mateusoliveira43 yeah correct, On one hand Created seemed a bit out of place to me (maybe just becasue not used to seeing it) but on the other hand we do not want to duplicate data from VeleroBackup. Anyway if we wanted to change, it would be a separate PR.

@kaovilai kaovilai requested a review from mpryc October 2, 2024 14:18
@mpryc
Copy link
Collaborator

mpryc commented Oct 3, 2024

@mateusoliveira43 yeah correct, On one hand Created seemed a bit out of place to me (maybe just becasue not used to seeing it) but on the other hand we do not want to duplicate data from VeleroBackup. Anyway if we wanted to change, it would be a separate PR.

We have the veleroBackupStatus which reflects the state of the Backup.

On the other hand we could also think about 4th phase in NAB that will be Completed when the veleroBackupStatus also is completed without error.

Copy link
Collaborator

@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.

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Oct 3, 2024
Copy link

openshift-ci bot commented Oct 3, 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

@openshift-merge-bot openshift-merge-bot bot merged commit 0d30f21 into migtools:master Oct 3, 2024
8 checks passed
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.

3 participants