Skip to content

Conversation

@zhiying-lin
Copy link
Contributor

Description of your changes

get or create cluster resource snapshots if needed.

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Unit tests

Special notes for your reviewer

if err != nil {
return nil, err
}
latestResourceSnapshotHash := ""
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are already retrieving latest resource snapshot and its index in the lookup function, why not retrieve hashes there? It would simplify the logic a little bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The lookup func is little complicated for now, so prefer to get the hash outside.

Refactored the code. PTAL to see if the readability is better.

klog.ErrorS(err, "Failed to list active clusterResourceSnapshots", "clusterResourcePlacement", crpKObj)
return nil, -1, controller.NewAPIServerError(false, err)
}
if len(snapshotList.Items) == 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we handle the multiple resourceSnapshots objects per index?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not now, will handle it in the second phase.

}

// latestResourceSnapshotIndex should be -1 when there is no snapshot.
latestResourceSnapshot, latestResourceSnapshotIndex, err := r.lookupLatestResourceSnapshot(ctx, crp)
Copy link
Contributor

Choose a reason for hiding this comment

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

the resourceSnapshot and schedulingPolicySnapshot are generated following the same rule. Do we need to create two functions to look up the last? Will generic help unite them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the implementation will diverge when we handle the 1MB limit for the resourceSnapshot.

So prefer not to unify them, otherwise there will be too many "if else" conditions.

@ryanzhang-oss ryanzhang-oss merged commit f855087 into Azure:main Jun 29, 2023
@zhiying-lin zhiying-lin deleted the resource branch June 30, 2023 01:06
britaniar pushed a commit to britaniar/fleet that referenced this pull request Jan 12, 2026
@britaniar britaniar mentioned this pull request Jan 12, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants