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

[MM-16722] Use github.com/banzaicloud/k8s-objectmatcher for all resource reconciliation comparisons #72

Merged
merged 20 commits into from
Oct 1, 2019

Conversation

jozuenoon
Copy link
Contributor

@jozuenoon jozuenoon commented Aug 27, 2019

Resolves: mattermost/mattermost#11919

Some comments about changes:

  • added custom annotation for k8s-objectmatcher mattermost.com/last-applied.
  • change naming of reconciled resources to current and desired - this change is up to discussion. I found it much more readable this way and less likely to make mistake when passing down to update function. By function context it should be always obvious what current and desired are.
  • mysql-cluster resource if used with objectmatcher have negative impacts on mysql operator, resulting in either cluster being stalled in read only mode or completely ignoring subsequent changes to spec. This happen in situation when TestMattermost/mattermost_upgrade_test starts. Since db resource have same name for every deployment mysql-cluster resource gets override (from test-mm to test-mm2) with new password secret and owner reference. I found that if objectmatcher is in use mysql annotation mysql.presslabs.org/version gets dropped, resulting in mysql operator ignoring any changes to resource. If this annotation is restored manually it makes some progress however cluster stays in read only mode.

Some followup ideas:

  • would be nice to make mysql-cluster resource name variable, depending on name of mattermost deployment <name>-db and not using static db (this would probably prevent problems with objectmatcher on this resource),
  • in e2e tests there is upgrade test right after scale test, the scale test creates database at default version, then immediately test-mm2 overrides with downgraded version, however database schema doesn't change since it operates on same resource, then upgrade is performed, but it performs upgrades (if any) over already existing upgraded version. If testing schema upgrades is not intended here that may need a comment in tests, otherwise this should be fixed with variable db resource name likely also triggering some changes to e2e test,
  • inspecting mysql-operator interactions with CRD and look through logs for any possible strange behaviors,
  • remove create<...>IfNotExists functions since embedding them directly into reconcile functions would save one call to API Get and improve line of sight,
  • add getOrCreateMySQLSecrets as fully checked resource on reconcile.

@jwilander
Copy link
Member

@jozuenoon thanks for the PR! Let me know when this is ready for review and I'll add reviewers

@jwilander
Copy link
Member

How's this going @jozuenoon ? Need any help?

if err != nil {
return err
}

// Updating mysql.cluster with objectMatcher breaks mysql operator.
// Only fields that are expected to be changed by mattermost-operator should be included here.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Until other problems around database resource are resolved, mysql reconcile connot be changed to objectMatcher.

@jozuenoon jozuenoon marked this pull request as ready for review September 19, 2019 20:46
@jwilander
Copy link
Member

@cpanato @gabrieljackson what do you think about @jozuenoon's thoughts in the summary?

@jwilander
Copy link
Member

I think your changes make sense, especially regarding the mysql cluster. We should do our best to not interfere with the internal workings of the mysql operator and just reconcile the parts of the spec we are setting

For the follow-ups:

would be nice to make mysql-cluster resource name variable, depending on name of mattermost deployment -db and not using static db (this would probably prevent problems with objectmatcher on this resource),

I agree with not using a static name for the db cluster. The problem with using a variable name is that the mysql slaves use a really long name to connect to the master (see bitpoke/mysql-operator#170) which is why we started using the static name.

e2e tests

I'll leave that to @cpanato's feedback

inspecting mysql-operator interactions with CRD and look through logs for any possible strange behaviors

I'm all for that 👍

remove create<...>IfNotExists functions since embedding them directly into reconcile functions would save one call to API Get and improve line of sight,

Not sure what you mean on how this saves an API call? The reason we separated those out was so they could be reused if needed

add getOrCreateMySQLSecrets as fully checked resource on reconcile

Makes sense to me

Copy link
Member

@jwilander jwilander left a comment

Choose a reason for hiding this comment

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

LGTM 👍 nice work @jozuenoon !

Copy link
Collaborator

@gabrieljackson gabrieljackson left a comment

Choose a reason for hiding this comment

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

Very nice work @jozuenoon!

@jwilander has covered most of your questions/thoughts and I agree with him. Primarily, we are currently constrained by the mysql operator behavior as he noted, so it makes sense to improve that objectmatching in a follow-up PR.

As for the e2e tests, they should be flushed out since we have added quite a bit to the operator since their inception, so we will keep your thoughts in mind for when we get around to that.

Thanks again! 🎉

@gabrieljackson gabrieljackson merged commit 61eb82c into mattermost:master Oct 1, 2019
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.

Use github.com/banzaicloud/k8s-objectmatcher for all resource reconciliation comparisons
4 participants