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

Broadcast events #267

Merged
merged 3 commits into from
May 9, 2018
Merged

Conversation

asymmetric
Copy link
Contributor

@asymmetric asymmetric commented May 2, 2018

Emits an event when:

  • A Habitat fails to validate (will have to be removed when Use Schema for validation instead of ad-hoc code #185 is implemented, because an invalid Habitat shouldn't even be creatable in the first place)
  • One of the sub-resources fails to be created
  • A Habitat is synced successfully (not sure we really need this)

To test: create a Habitat and type kubectl describe hab

Closes #221.

@krnowak
Copy link
Contributor

krnowak commented May 3, 2018

Seems to work fine, but not sure about the sync events, they seem to happen a lot…

Events:
  Type    Reason              Age                From                Message
  ----    ------              ----               ----                -------
  …
  Normal  Synced              13s (x12 over 1m)  habitat-controller  Successfully synced Habitat

I'd say that we probably should put an event when sync fails maybe.

@asymmetric
Copy link
Contributor Author

OK, removed the sync event, PTALA.

Copy link
Contributor

@iaguis iaguis left a 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.

@@ -556,16 +594,19 @@ func (hc *HabitatController) conform(key string) error {
return err
}
} else {
hc.recorder.Event(h, apiv1.EventTypeWarning, stsFailed, messageStsCreated)
Copy link
Contributor

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?

} 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)
Copy link
Contributor

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?


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)
Copy link
Contributor

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?

@iaguis
Copy link
Contributor

iaguis commented May 7, 2018

I guess you need something like

...
- apiGroups:
  - ""
  resources:
  - events
  verbs:
  - get
  - update
  - patch
  - create

In the operator RBAC rules

Lorenzo Manacorda added 3 commits May 8, 2018 14:13
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>
@asymmetric
Copy link
Contributor Author

PTALA my friends.

Copy link
Contributor

@iaguis iaguis left a comment

Choose a reason for hiding this comment

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

lgtm

@asymmetric asymmetric merged commit 3a74d78 into habitat-sh:master May 9, 2018
@asymmetric asymmetric deleted the asymmetric/events branch May 9, 2018 15:14
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.

3 participants