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

controller/v1beta2: Warn users when owned resources are changed. #273

Conversation

kosyfrances
Copy link
Contributor

@kosyfrances kosyfrances commented May 14, 2018

Fixes #252

We should warn users when habitat's own resources are manually modified,
because the operator will override these changes.

Copy link
Contributor

@asymmetric asymmetric left a comment

Choose a reason for hiding this comment

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

We should warn users only when the change does not come from us, so e.g.

messageCMFailed = "Failed creating ConfigMap"
messagePeerIPAdded = "Added peer IP to ConfigMap"
messagePeerIPUpdated = "Updated peer IP in ConfigMap"
messagePeerIPUpdatedWarn = "Readonly configuration updated. Update will be reverted"
Copy link
Contributor

Choose a reason for hiding this comment

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

The variable name should be more generic, as this warning applies to multiple situtations. Something like messageReadOnlyResourceChanged.

@@ -488,6 +489,8 @@ func (hc *HabitatController) handleConfigMap(h *habv1beta1.Habitat) error {

level.Info(hc.logger).Log("msg", messagePeerIPUpdated, "name", cm.Name, "ip", leaderIP)
hc.recorder.Event(h, apiv1.EventTypeNormal, cmUpdated, messagePeerIPUpdated)
level.Warn(hc.logger).Log("msg", messagePeerIPUpdatedWarn, "name", cm.Name, "ip", leaderIP)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, it's the operator who has just updated the CM, so it's not one of the situations we should warn users about.

Copy link
Contributor

@indradhanush indradhanush left a comment

Choose a reason for hiding this comment

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

Nitpicks that can be safely ignored.

messageCMFailed = "Failed creating ConfigMap"
messagePeerIPAdded = "Added peer IP to ConfigMap"
messagePeerIPUpdated = "Updated peer IP in ConfigMap"
messageReadOnlyResourceChanged = "Readonly configuration updated. Update will be reverted"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Maybe add the new variable at the end of the block instead of in the middle, unless it fits in some kind of an order?

@kosyfrances kosyfrances force-pushed the kosy/warn-users-resources branch 2 times, most recently from 4aaf3b1 to 286ecf6 Compare May 17, 2018 15:45
hc.handleCM(newObj)
}

func (hc *HabitatController) handleCMDelete(obj interface{}) {
level.Warn(hc.logger).Log("msg", messageReadOnlyResourceChanged)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if some kind of tag should be added to this message, just like that of the others. For example: level.Warn(hc.logger).Log("msg", messageReadOnlyResourceChanged, "name", pod.Name)

@kosyfrances
Copy link
Contributor Author

Please take a look again :)

We should warn users when habitat's own resources are manually modified,
because the operator will override these changes.

Signed-off-by: Kosy Anyanwu <kosy@kinvolk.io>
@krnowak
Copy link
Contributor

krnowak commented May 28, 2018

I'd say "no" for this PR at the moment. It produces a lot of output from the operator, even when I'm not doing anything after just creating a standalone example:

[kv@localhost ([k8s], [go-1.10, chef]) habitat-operator]$ ./habitat-operator -kubeconfig $KUBECONFIG
ts=2018-05-28T10:42:37.851495152+02:00 level=info msg="Habitat CRD already exists, continuing"
ts=2018-05-28T10:42:37.853839189+02:00 level=info component=controller/v1beta1 msg="Watching Habitat objects"
ts=2018-05-28T10:42:37.910004163+02:00 level=info msg="Habitat CRD already exists, continuing"
ts=2018-05-28T10:42:37.910244161+02:00 level=info component=controller/v1beta2 msg="Watching Habitat objects"
ts=2018-05-28T10:43:07.947941987+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:43:07.94803311+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:43:07.948067871+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:43:07.948102153+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:43:37.948137279+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:43:37.948281193+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:43:37.948323431+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:43:37.948368279+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:43:44.993067819+02:00 level=info component=controller/v1beta2 msg="created StatefulSet" name=example-standalone-habitat
ts=2018-05-28T10:43:45.006781911+02:00 level=info component=controller/v1beta2 msg="Created peer IP ConfigMap" name=peer-watch-file
ts=2018-05-28T10:43:45.178053666+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted" name=example-standalone-habitat
ts=2018-05-28T10:43:59.791845298+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted" name=example-standalone-habitat-0
ts=2018-05-28T10:43:59.898967306+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted" name=example-standalone-habitat
ts=2018-05-28T10:43:59.977324681+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:43:59.977473154+02:00 level=info component=controller/v1beta2 msg="Updated peer IP in ConfigMap" name=peer-watch-file ip=10.40.0.1
ts=2018-05-28T10:44:07.948439782+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:44:07.948575376+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:44:07.94862311+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:44:07.948682977+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:44:07.948749956+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:44:37.94866227+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:44:37.94876892+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:44:37.948913852+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:44:37.949014912+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:44:37.949073643+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:07.948988557+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:07.949116965+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:07.949218019+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:07.949312724+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:07.949367039+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:37.949365583+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:37.949494171+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:37.949552203+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:37.949594255+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:45:37.949628686+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"

It is way too verbose. The verbosity maybe could be cut down if we somehow detected that nothing really happened, so nothing is going to change.

When writing this message I got another bunch of lines:

ts=2018-05-28T10:46:07.949657556+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:46:07.949738612+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:46:07.949774726+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:46:07.949805319+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:46:07.949834305+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:46:37.950166681+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:46:37.950409317+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:46:37.950575661+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:46:37.950850238+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:46:37.951069833+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:07.950435553+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:07.950571249+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:07.950627983+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:07.95067917+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:07.950714613+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:37.950835388+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:37.950920325+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:37.951000786+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:37.951040217+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:47:37.952010668+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:48:07.951184929+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:48:07.951323585+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:48:07.951374239+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:48:07.951413169+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"
ts=2018-05-28T10:48:07.951478048+02:00 level=warn component=controller/v1beta2 msg="Readonly configuration updated. Update will be reverted"

@kosyfrances
Copy link
Contributor Author

kosyfrances commented May 28, 2018

@krnowak do you think we should close this PR and educate the users instead?
cc @asymmetric

@asymmetric
Copy link
Contributor

Yes. I'm not sure what we should do to educate users, maybe add something to the design doc.

@kosyfrances kosyfrances self-assigned this May 30, 2018
@krnowak
Copy link
Contributor

krnowak commented May 30, 2018

The design doc already states that those resources are readonly. Maybe at some point we will get this functionality in kubernetes itself, which we can use.

Closing.

@krnowak krnowak closed this May 30, 2018
@kosyfrances kosyfrances deleted the kosy/warn-users-resources branch May 30, 2018 09:48
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.

4 participants