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: Failed to process: Object 'Kind' is missing in Errors with rollouts notification #2150

Merged
merged 4 commits into from
Jul 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions rollout/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -419,6 +422,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,
})
}
RaviHari marked this conversation as resolved.
Show resolved Hide resolved
err = c.rolloutsInformer.GetStore().Update(&un)
if err != nil {
logCtx.Errorf("failed to update informer store: %v", err)
Expand Down