Skip to content

Commit

Permalink
fix: Failed to process: Object 'Kind' is missing in Errors with rollo…
Browse files Browse the repository at this point in the history
…uts notification (#2150)

* fix: update rolloutobject with gvk before writing to rollout informer

Signed-off-by: Ravi Hari <ravireliable@gmail.com>

* fix: controller schema linting

Signed-off-by: Ravi Hari <ravireliable@gmail.com>

* docs: comment the details on the change

Signed-off-by: Ravi Hari <ravireliable@gmail.com>

* docs: comment the details on the change

Signed-off-by: Ravi Hari <ravireliable@gmail.com>
  • Loading branch information
RaviHari authored Jul 29, 2022
1 parent 3329626 commit 0ec5ac1
Showing 1 changed file with 16 additions and 0 deletions.
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 @@ -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)
Expand Down

0 comments on commit 0ec5ac1

Please sign in to comment.