-
Notifications
You must be signed in to change notification settings - Fork 17
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
Broadcast events #267
Broadcast events #267
Conversation
Seems to work fine, but not sure about the sync events, they seem to happen a lot…
I'd say that we probably should put an event when sync fails maybe. |
af76925
to
1091bff
Compare
OK, removed the sync event, PTALA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems RBAC is preventing the operator from sending the events:
ERROR: logging before flag.Parse: E0507 15:53:45.742665 1 event.go:200] Server rejected event '&v1.Event{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"example-persistent-habitat.152c67bacb0d571d", GenerateName:"", Namespace:"default", SelfLink:"", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Initializers:(*v1.Initializers)(nil), Finalizers:[]string(nil), ClusterName:""}, InvolvedObject:v1.ObjectReference{Kind:"Habitat", Namespace:"default", Name:"example-persistent-habitat", UID:"d2e30278-520e-11e8-954f-0a580a160064", APIVersion:"habitat.sh", ResourceVersion:"1035", FieldPath:""}, Reason:"StatefulSetCreated", Message:"Created StatefulSet", Source:v1.EventSource{Component:"habitat-controller", Host:""}, FirstTimestamp:v1.Time{Time:time.Time{wall:0xbeb43b826c1b3d1d, ext:40695262304, loc:(*time.Location)(0x18b8b00)}}, LastTimestamp:v1.Time{Time:time.Time{wall:0xbeb43b826c1b3d1d, ext:40695262304, loc:(*time.Location)(0x18b8b00)}}, Count:1, Type:"Normal", EventTime:v1.MicroTime{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, Series:(*v1.EventSeries)(nil), Action:"", Related:(*v1.ObjectReference)(nil), ReportingController:"", ReportingInstance:""}': 'events is forbidden: User "system:serviceaccount:default:habitat-operator" cannot create events in the namespace "default"' (will not retry!)
Also, some comments.
pkg/controller/v1beta2/controller.go
Outdated
@@ -556,16 +594,19 @@ func (hc *HabitatController) conform(key string) error { | |||
return err | |||
} | |||
} else { | |||
hc.recorder.Event(h, apiv1.EventTypeWarning, stsFailed, messageStsCreated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be messageStsFailed
?
pkg/controller/v1beta2/controller.go
Outdated
} else { | ||
level.Info(hc.logger).Log("msg", "created peer IP ConfigMap", "name", cm.Name, "ip", leaderIP) | ||
level.Info(hc.logger).Log("msg", messageCMCreated, "name", cm.Name, "ip", leaderIP) | ||
hc.recorder.Event(h, apiv1.EventTypeNormal, cmUpdated, messagePeerIPAdded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a cm created event?
pkg/controller/v1beta2/controller.go
Outdated
|
||
return nil | ||
} | ||
|
||
level.Info(hc.logger).Log("msg", "created peer IP ConfigMap", "name", cm.Name) | ||
level.Info(hc.logger).Log("msg", messageCMCreated, "name", cm.Name) | ||
hc.recorder.Event(h, apiv1.EventTypeNormal, cmUpdated, messagePeerIPAdded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a cm created event?
I guess you need something like
In the operator RBAC rules |
Events are broadcast when: * A Habitat object is successfully synced * A Habitat object fails to validate * A sub-resource (StatefulSet, ConfigMap, Secret) fails to be created Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
1091bff
to
4c5d32b
Compare
PTALA my friends. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Emits an event when:
Habitat
fails to validate (will have to be removed when Use Schema for validation instead of ad-hoc code #185 is implemented, because an invalidHabitat
shouldn't even be creatable in the first place)Habitat
is synced successfully (not sure we really need this)To test: create a
Habitat
and typekubectl describe hab
Closes #221.