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

Always allow converting MySQL[AAD]Users back to v1alpha1 #1393

Merged

Conversation

babbageclunk
Copy link
Member

@babbageclunk babbageclunk commented Mar 17, 2021

Previously if a v1alpha2 MySQLUser or MySQLAADUser had server-level roles or roles in more or fewer than one database, trying to convert it to a v1alpha1 representation would fail because the older format could only refer to exactly one database. This caused something (likely a cache but I'm not entirely sure ☹️) in the system to go into a loop trying to request the resource as v1alpha1 every second and spamming the log with errors.

Change the from conversion to store the affected fields as JSON in an azure.microsoft.com/convert-stash annotation, and the to conversion to incorporate the annotation values when going back to v1alpha2.

Fixes #1388.

How does this PR make you feel:
gif

If applicable:

  • this PR contains documentation
  • this PR contains tests

The output of `make manager` goes into bin/ which is already
ignored. This entry was causing very confusing things to happen with
directories called `manager` further down the directory tree.
(Unless JSON serialisation fails for some reason.) Instead we store
the changed fields in an annotation and allow roundtripping that when
converting in the other direction.
@babbageclunk
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

(Unless JSON serialisation fails for some reason.) Instead we store
the changed fields in an annotation and allow roundtripping that when
converting in the other direction.
@babbageclunk babbageclunk force-pushed the mysqlaaduser-no-err-conversion branch from 8b99242 to f2b1705 Compare March 18, 2021 02:30
matthchr
matthchr previously approved these changes Mar 22, 2021
Copy link
Member

@matthchr matthchr left a comment

Choose a reason for hiding this comment

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

LGTM!

api/v1alpha1/conversion_stash.go Show resolved Hide resolved
api/v1alpha1/conversion_stash.go Show resolved Hide resolved
}
sort.Strings(dbNames)
Copy link
Member

Choose a reason for hiding this comment

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

What's the logic behind sorting this? The collection is "ordered" already (in that the customer has specified some order) - is there a problem with just using whatever dbname they specified first?

Copy link
Member Author

Choose a reason for hiding this comment

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

Purely for repeatability and testing - I'll add a comment. Although it's ordered in the text of the yaml, we only see it in a map, by which time the ordering is lost.

api/v1alpha1/mysqluser_conversion.go Show resolved Hide resolved
}
if dst.Spec.DatabaseRoles == nil {
dst.Spec.DatabaseRoles = make(map[string][]string)
}
dst.Spec.DatabaseRoles[src.Spec.DBName] = append([]string(nil), src.Spec.Roles...)
Copy link
Member

Choose a reason for hiding this comment

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

Is this just a no-op in the case where there was a stashed annotation? (The assignment has actually already happened but we're just doing it again?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Not necessarily a no-op- if a user was doing an edit they might send back a resource with changed roles for the selected database (but the original values in the annotation). But in general probably.

matthchr
matthchr previously approved these changes Mar 23, 2021
@babbageclunk
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@babbageclunk
Copy link
Member Author

The MySQL happy path test seem to be failing intermittently - it looks like it's just timing out creating the server (before anything in this PR). I'll have a look at bumping up the timeout in a separate PR.

@babbageclunk
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@babbageclunk
Copy link
Member Author

babbageclunk commented Mar 23, 2021

Or I guess if it's failing so frequently that I can't merge it I'll try bumping it up in this PR ☹️

matthchr
matthchr previously approved these changes Mar 24, 2021
This is perpetually timing out for me at the moment, and testing
manually shows that creation can take more than an hour.
@babbageclunk babbageclunk merged commit bfabead into Azure:master Mar 24, 2021
@babbageclunk babbageclunk deleted the mysqlaaduser-no-err-conversion branch March 24, 2021 03:26
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.

Bug: MySQLAADUser conversion webhook failure spamming log
3 participants