diff --git a/rollout/controller.go b/rollout/controller.go index eaece46ce7..e314adf4af 100644 --- a/rollout/controller.go +++ b/rollout/controller.go @@ -8,6 +8,9 @@ import ( "strconv" "time" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/argoproj/argo-rollouts/pkg/apis/rollouts" smiclientset "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/split/clientset/versioned" log "github.com/sirupsen/logrus" appsv1 "k8s.io/api/apps/v1" @@ -421,6 +424,19 @@ func (c *Controller) writeBackToInformer(ro *v1alpha1.Rollout) { return } un := unstructured.Unstructured{Object: obj} + // With code-gen tools the argoclientset is generated and the update method here is removing typemetafields + // which the notification controller expects when it converts rolloutobject to toUnstructured and if not present + // and that throws an error "Failed to process: Object 'Kind' is missing in ..." + // Fixing this here as the informer is shared by notification controller by updating typemetafileds. + // TODO: Need to revisit this in the future and maybe we should have a dedicated informer for notification + gvk := un.GetObjectKind().GroupVersionKind() + if len(gvk.Version) == 0 || len(gvk.Group) == 0 || len(gvk.Kind) == 0 { + un.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{ + Group: v1alpha1.SchemeGroupVersion.Group, + Kind: rollouts.RolloutKind, + Version: v1alpha1.SchemeGroupVersion.Version, + }) + } err = c.rolloutsInformer.GetStore().Update(&un) if err != nil { logCtx.Errorf("failed to update informer store: %v", err)