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

add labels and annotations to rollouts api #3832

Merged
merged 3 commits into from
Feb 23, 2023

Conversation

natasha41575
Copy link
Contributor

@natasha41575 natasha41575 commented Feb 21, 2023

Should resolve #3797.

This PR adds labels and annotations to the rollouts api under syncTemplate.

For example:

apiVersion: gitops.kpt.dev/v1alpha1
kind: Rollout
metadata:
  name: sample
spec:
  syncTemplate:
    rootSync:
      metadata:
        annotations:
          foo: bar
        labels:
          foo: bar
    type: RootSync
...

The specified annotations and labels get added to spec of RemoteRootSync objects that the rollout creates. The RemoteRootSync objects add them to the metadata of RootSync objects that they create.

@natasha41575 natasha41575 changed the title WIP: add labels and annotations to rollouts api add labels and annotations to rollouts api Feb 21, 2023
@natasha41575 natasha41575 marked this pull request as ready for review February 21, 2023 18:22
@natasha41575 natasha41575 requested a review from a team as a code owner February 21, 2023 18:22
Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

Awesome, this is looking good. Some minor comments.

rollouts/api/v1alpha1/remoterootsync_types.go Outdated Show resolved Hide resolved
rollouts/controllers/rollout_controller.go Outdated Show resolved Hide resolved
rollouts/controllers/rollout_controller.go Outdated Show resolved Hide resolved
Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

Excellent. We can merge this, found a few more things that we need to address.

@@ -276,6 +277,14 @@ func (r *RolloutReconciler) getPackageDiscoveryClient(rolloutNamespacedName type
func (r *RolloutReconciler) reconcileRollout(ctx context.Context, rollout *gitopsv1alpha1.Rollout, strategy *gitopsv1alpha1.ProgressiveRolloutStrategy, packageDiscoveryClient *packagediscovery.PackageDiscovery) error {
logger := klog.FromContext(ctx)

if rollout != nil && rollout.Spec.SyncTemplate != nil {
if rollout.Spec.SyncTemplate.Type == gitopsv1alpha1.TemplateTypeRepoSync {
err := fmt.Errorf("reposync is not yet supported")
Copy link
Contributor

Choose a reason for hiding this comment

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

just a note for us: we will have to start capturing these as errors as conditions in the status part of the API to surface it to the end users. Today, one has to look at the error logs of the controller :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed #3839

if pkg.Revision != rrs.Spec.Template.Spec.Git.Revision {
if pkg.Revision != rrs.Spec.Template.Spec.Git.Revision ||
!reflect.DeepEqual(rollout.Spec.SyncTemplate.RootSync.Metadata,
rrs.Spec.Template.Metadata) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for us: I can see this logic evolving, so would be good to extract it out as a function and have unit tests around it. Something along the lines of:

func DoesPkgNeedUpdate(rollout, pkg, rrs) (bool) {

}

I can see we are not comparing other bits of the template such as git secret ref etc. Can you file another issue for tracking this bug. I think this seems more critical to be addressed.

Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

Awesome! 🚢

@natasha41575 natasha41575 merged commit 7bc1011 into kptdev:main Feb 23, 2023
@natasha41575 natasha41575 deleted the rootsyncmeta branch February 23, 2023 17:36
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.

Rollout API should support deletion of objects created by it
2 participants