зеркало из
1
0
Форкнуть 0
Граф коммитов

1207 Коммитов

Автор SHA1 Сообщение Дата
Bevan Arps 882ed6e362
Document hard coded key and reference origin (#4280) 2024-09-19 20:47:57 +00:00
dependabot[bot] 00f242735e
Bump sigs.k8s.io/controller-runtime from 0.13.0 to 0.16.2 (#3332)
* Bump sigs.k8s.io/controller-runtime from 0.13.0 to 0.16.2

Bumps [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) from 0.13.0 to 0.16.2.
- [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases)
- [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md)
- [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.13.0...v0.16.2)

---
updated-dependencies:
- dependency-name: sigs.k8s.io/controller-runtime
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update implementations of webhook.Validator

* Remove references to envtest/printer

* Update for API changes

* Update version of controller-gen

* Update Go version

* Add argument to controller-gen

* Limit manifests to ASO v1

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bevan Arps <bevan.arps@microsoft.com>
Co-authored-by: Matthew Christopher <matthchr@users.noreply.github.com>
2023-10-13 07:59:12 +13:00
Matthew Christopher 5761dfb724
Update dependencies (#3198)
* Update dependencies
* Update Taskfile to ensure task --force works
* Fix wait-for-operator-ready script
    Previously it only waited 5s which was less than the total time required
    to list all CRDs. This caused the script to fail if it happened to run
    after all CRDs were added (list takes long time) but succeed if it ran
    right as CRDs were being added (list takes less time because not all
    CRDs added yet).
* Fix failing ASOv1 test
2023-08-22 08:08:08 -07:00
Matthew Christopher a93ed945f1
Add support for subscriptionID on AzureSQL types (#2910) 2023-05-03 08:49:06 -07:00
Matthew Christopher 802ae08a02
Update to latest version of a few packages to take CVE fixes (#2384)
* Update to latest version of a few packages to take CVE fixes
* Fix eventhub bugs due to changed upstream API
2022-07-15 13:47:59 -07:00
Mathis Kretz cfb40ee2e4
Make elastic pool id configurable on Azure SQL DB (#2184) 2022-03-31 12:48:13 -07:00
George Pollard 2ee579fa00
gofmt -s -w . (#2050) 2022-01-25 11:20:32 +13:00
Christian Muirhead 7f37186dfc
MySQL: support granting ALL privileges in a database to a user (#1784)
* Support granting ALL privileges in a database to a user

If ALL is specified, we don't delete any privileges.

* Add validation webhooks for MySQL[AAD]User to prevent server-ALL

Since the ASO mysql admin user doesn't have privileges to grant global
ALL privileges, prevent this from being set in the resources.

* Update the docs for mysql users and aad users

* Test the MySQL[AAD]User webhook prevents ALL at the server level
2021-09-08 17:52:03 +12:00
Matthew Christopher b3e72934cd
Add new options to support KeyVault soft delete (#1717)
* Update KeyVault SecretClient to recover soft delete

   * Includes a test ensuring that this works
   * Add Azure SQL Combined test to ensure create+delete+recreate works
   * Update CI to not fail on stderr
2021-08-19 16:47:05 -07:00
Christian Muirhead 1def7c58fb
Add operator mode configuration (#1658)
* Add OperatorMode config value and use it from main

It's specified as AZURE_OPERATOR_MODE, with possible values `webhooks`, `watchers` and `watchers-and-webhooks`. Use the setting from main() to decide whether watchers and webhooks should be started.

* Move reconciler and webhook registration out of main

Move it to controllers.RegisterReconcilers and controllers.RegisterWebhooks so that it can be shared between main and the controller tests.

* Test the watchers/webhooks behaviour of different operator modes

* Include operator logging when TEST_EMIT_ASO_LOGS is set

This can be very useful when trying to understand why a test is failing, but it's far too noisy to include all the time.

* Add tests for OperatorMode

* Add make targets and pipeline jobs for webhooks + watchers modes
2021-08-18 01:08:45 +12:00
Christian Muirhead e190674531
Remove envtest job timeout for now (#1723)
* Remove envtest job timeout for now

It seems like there's a problem in the job that's causing it to be killed by the timeout, but the way the job is killed prevents us from seeing the output which would let us fix the underlying problem in whichever test is failing.

* Use require rather than assert in Azure SQL

Also in the Ensure* helpers.

The assert library doesn't stop the current test if the assertion fails, which means that the test run always ends up finishing with a timeout waiting for something that can't happen because some prerequisite failed.

In general the require model is better for tests. The downside is that you might need to run the test multiple times to see all the problems, but it avoids nonsensical situations where you timeout deleting a resource that you failed to create.

* Increase test FailoverGracePeriod to 60

Previous runs were failing with an error saying that 60 is the minimum. (Not sure whether this is a new constraint?)

* Rewrite Retry as a non-recursive function

It was producing very annoying stack traces if a test timed out.
2021-08-17 20:25:42 +12:00
Matthew Christopher 34f39d5ef3
Update Azure SDK version and update Helm chart parameters (#1695)
* Use updated Azure Go SDK Environment for MySQL URLs
* Add Helm parameter for kube-rbac-proxy
* Fix leftover TODOs in MySQLServer controller
2021-08-09 14:21:07 -07:00
Matthew Christopher 4289ebe283
Support MySQLServer secret rollover (#1654) 2021-07-22 12:16:13 -07:00
Matthew Christopher 5a137b1ca6
Fix possible VNET panic (#1652) 2021-07-15 17:53:45 -07:00
Bevan Arps 1e9cc4f12c
Enforce alternatives to %v and %+v (#1639)
Co-authored-by: Matthew Christopher <matthchr@microsoft.com>
2021-07-16 11:10:58 +12:00
Matthew Christopher 02973a1276
Update ASO v1 dependencies (#1646)
* Update Go version to 1.16
* Update dependencies
* Pass ctx to reconcile
2021-07-15 13:20:47 -07:00
Matthew Christopher 409bc54698
Fix header check (#1643) 2021-07-13 10:48:22 -07:00
Matthew Christopher 81091cf18a
Support user specified MySQLServer secrets (#1625)
* Support user specified MySQLServer secrets
 - The specified secret must be a Kubernetes secret.
 - The specified secret must contain a "username" and "password" field.
 - The specified secret must be in the same namespace as the MySQLServer.
 - If the specified secret doesn't exist, reconciliation will be blocked
   until the secret does exist. Once the secret is created, reconciliation
   will continue as normal.
 - The operator does not make the user specified secret owned by
   the MySQLServer.
 - The operator still creates a secret containing connection string details
   and username/password for the server. This secret is named as it was
   before. This means that the customer specified username and password
   are consumed to create this secret, but other resources such as MySQLUser
   still consume the generated secret file.
2021-07-11 11:29:03 -07:00
Christian Muirhead d4b08030a1
Ensure DB connections are closed when we've finished with them (#1619)
* postgresqluser: Close DBs to prevent leaking connections

This is much simpler than a cache of DBs. I started going down that
path but as always it's removing no-longer needed DBs from the cache
that makes it more complicated. For now this will fix the leak and if
we have a problem with opening and closing connections being too slow
we can fix that then.

* mysql[aad]user: Close DB when we're finished with it

This is much simpler than trying to use a DB cache for it.

* azuresql: Close DBs when finished with them

In the azuresqlaction, azuresqlmanageduser and azuresqluser
reconcilers.

* Change region used for MySQL test

The ASO CI subscription can't create servers in eastus2 but westus2 is
allowed at the moment.
2021-07-07 06:04:22 +12:00
Christian Muirhead a4d3a51843
Add AZURE_TARGET_NAMESPACES to restrict the namespaces the operator watches (#1559)
* Add a target namespaces config, only watch resources therein

* Initial work on target namespace test

* Get target namespace test working in both cases

* More useful logging when creating test RG fails

* Run the no-target-namespaces test in the CI pipeline

This is handled in the same way as the secret naming version setting,
but the more settings we add (some more are on the way), the more
unwieldy it's going to be. We need to come up with a better way of
making different settings testable.

* Rework install- targets so they don't trample go.mod & .sum

Renamed them to install-tools and install-test-tools, since they're
installing binaries used in the build process rather than code
dependencies.

Run the `go get` commands in a temp directory and dummy module so that
they don't update the ASO go.mod and .sum files with dependencies that
our code doesn't actually depend on.

* Use the unfiltered API reader when looking for AAD identities

When target namespaces are set, there's no guarantee that the
operator's namespace is included. The identity finder always needs to
look in the operator namespace so pass it the API reader which
bypasses the filtered cache.

* Review tweaks, thanks @matthchr!
2021-06-16 08:05:17 -07:00
Matthew Christopher d28ea4bd2a
Helm chart update 1.5.0 (#1552)
* Small comment fix

* Update Helm chart
2021-06-09 16:48:08 -07:00
Matthew Christopher 2f6cc6f1a4
Add new CosmosDBSQLDatabase CRD (#1549)
* Update CosmosDB SDK version
* Refactor CosmosDB folder structure
  - This is in preparation for adding new CosmosDB resources.
* Rename HandleEnsureError with a clearer name
  - Also add documentation.
* Add new CosmosDBSQLDatabase resource
* Add PollURLKind to status
  - Use it to differentiate between Create/Delete polling.
2021-06-08 14:17:05 -07:00
Matthew Christopher f6330bb323
Use config.Enviornment() to find MySQL AAD resource ID (#1529)
Co-authored-by: George Pollard <gpollard@microsoft.com>
2021-06-01 13:03:06 -07:00
cpflaume ba5905383e
use shorter name for keyVaultName (#1536)
Co-authored-by: Bevan Arps <bevan.arps@microsoft.com>
Co-authored-by: Matthew Christopher <matthchr@microsoft.com>
2021-06-01 09:51:39 -07:00
Matthew Christopher 6ba28a50ff
Use correct DNS suffix for MySQLAADUser (#1499)
Co-authored-by: George Pollard <gpollard@microsoft.com>
2021-05-20 20:11:03 -07:00
George Pollard 0a633f5c13 Handle err in DeleteNamespace 2021-05-17 23:38:28 +00:00
George Pollard 381289d1d4 Remove use of satori/uuid package 2021-05-17 22:58:34 +00:00
Matthew Christopher b4dd8c0378
Cleanup more dead code (#1476) 2021-05-17 13:39:36 -07:00
Christian Muirhead 62e0885127
Update patch targets to CRD v1 (#1428)
* Update webhook/CA injection patches to apply to CRD v1

* Updated go.mod/.sum with changed deps from upgrading controller-tools

* Run go mod tidy in hack/*

And remove a dead file.

Co-authored-by: George Pollard <gpollard@microsoft.com>
2021-05-17 15:48:53 +12:00
George Pollard 86f6970f5d Remove dead code 2021-05-12 21:41:29 +00:00
George Pollard 7cbdb61ec4 Fix header-check failures 2021-05-12 03:25:51 +00:00
George Pollard caa673f863 Move everything to the right place 2021-05-12 03:25:47 +00:00
Matthew Christopher 0c94d5a517
Make AzureSQL KeyVault secret deletion best effort (#1412)
- It already was best effort in most places but we missed one.
2021-04-20 14:52:23 -07:00
Christian Muirhead 2f68b47d25
mysqlserver: Keep track of the polling URL when creating (#1407)
* Keep track of the polling URL when creating a MySQL server

Previously this was being dropped on the floor unless the create call
returned an AsyncOpIncompleteError. This works fine except in the
case of creating a replica at the same time as the leader server (or
very quickly after). In that case the create server call returns no
error, but querying the poll URL shows that the creation failed
because the SourceServerID didn't match anything. Without capturing
the poll URL on the initial creation the reconciliation gets stuck
because it thinks that the 404 it gets when checking for the
server indicates that it's just not ready yet - provisioning never goes
back to false and it doesn't retry the creation.

* Review tweaks, thanks @matthchr!
2021-04-13 14:33:14 +12:00
Matthew Christopher f95b976055
Minor Azure SQL FailoverGroup improvements (#1403)
* Validate FailoverGroup policy has valid values
* Fix AzureSQLFailoverGroup sample
* Fix AzureSQLFailoverGroup test
2021-04-07 16:38:24 -07:00
Christian Muirhead 8d221d21d9
RedisCache - ensure FailedProvisioning=false when Provisioned=true (#1395)
* Ensure FailedProvisioning=false when Provisioned=true

A user reported a case where a RedisCache was provisioned and working
but was marked as FailedProvisioning=true. This seems to have happened
because it initially failed (possibly a temporary error that we aren't
checking for), and then on a subsequent periodic reconciliation the
ARM query reported that it was deployed successfully. Use the
SetProvisioned helper method to prevent this state.
2021-04-07 15:00:00 +12:00
Matthew Christopher 78e493ca41
Fix v1 secret naming (#1380)
* Fix v1 secret naming

  - Fix issue where namespace was mistakenly included in v1 secret
    naming key generation. Some resources are not expected to have
    namespace prefix in certain KeyVault scenarios.

* Increase build timeout a bit

* Don't create many different randoms in test

* SecretClient should not be modified

* Change region VM tests are run in

  - Due to capacity constraints. We can move back later.
2021-02-17 12:48:29 -08:00
Matthew Christopher 34453a0f2a
Bug fixes for release 1.0.19504 (#1376)
* Fix webhook injection patch

* Stop pre-checking for KV access
2021-02-10 21:50:10 -08:00
Matthew Christopher 4958aa1ca6
Prevent deadlocks in reconcilation loop (#1371)
* Some fixes

* Add timeout for all reconciles

  - Also ensure that connection timeout is specified for
    AzureSQL when connecting to the server.

* Randomize KV name
2021-02-08 14:42:35 -08:00
Matthew Christopher 876b1c7aa4
Fix bugs related to secret management and improve documentation (#1358)
* Fix typo in readme

* Improve secrets documentation

* Return proper error if we cannot deserialize secret

* Add new AZURE_SECRET_NAMING_VERSION mode

The new mode allows us to fix inconsitencies in how secrets
were named without making a breaking change.

  - AppInsights created secrets in the same namespace
    as the resource but with name:
    "appinsights-<resourceGroup>-<resourceName>"
  - Storage created secrets in the same namespace
    as the resource but with name:
    "storage-<resourceGroup>-<resourceName>"
  - AzureSQL resources created resources with
    a different naming scheme as well.
  - Other resources created a secret in the same
    namespace with the secret name being the
    resource name.

The new V2 mode ensures that all resources create secrets
in KeyVault and/or Kubernetes with a consistent naming pattern.

* Update Helm chart (but don't generate new package)

* Fix bug where SQLManagedUser Namespace could be empty

  - This would prevent secrets from being created in Kubernetes

* Enable V2 secrets for EnvTest tests

* Use v1beta1 explicitly with controller-gen

* PR feedback

* PR feedback

* Better testing
2021-02-05 10:05:48 -08:00
Christian Muirhead 7991802c7b
Add MySQLUser and MySQLAADUser v1alpha2 (#1357)
* Add v1alpha2 MySQLUser

This removes DbName from MySQLUser and adds DatabaseRoles to store
per-database permissions. Roles will now only store server-wide
permissions.

Add conversions between v1alpha1 and v1alpha2 versions.

* Add v1alpha2 MySQLAADUser

This removes DBName from MySQLAADUser and adds DatabaseRoles to store
per-database permissions. Roles will now only store server-wide
permissions.

Add conversions between v1alpha1 and v1alpha2 versions.

* Set up conversion webhooks for MySQLUser and MySQLAADUser

* Review feedback, thanks @matthchr!

* Ensure `preserveUnknownFields: false` is set in all webhook patches

These were set for all types with version conversions but not the
others (which aren't in use since they are still commented out in
kustomization.yaml). Turning them on in the rest to remove one step in
the process of adding conversion webhooks to types in the future.

This setting is required for conversion to work - it seems like the
only reason it's not set in the patches is that they were generated by
kubebuilder before the setting was mandatory.

* Add provisioning state methods to v1alpha2 ASOStatus

* Reimplement MySQLUser and MySQLAADUser reconciliation with v1alpha2

They now check server-level (in USER_PRIVILEGES) and
database-level (SCHEMA_PRIVILEGES) permissions.

* Update controller tests to work with v1alpha2 MySQLUser

* Move system database constant to mysql.SystemDatabase

Also rename the ServerPort and DriverName constants so they don't
repeat the name of the package.

* Change EnsureUserDatabaseRoles to return just an error

And change the reconciliation code for user and aad user to just treat
that as a provisioning failure, rather than saying that it had
succeeded but there were some errors which is just confusing. We still
try to apply changes to all databases even if there is an error for
one of them.

Also other review changes, thanks @matthchr!
2021-02-01 10:55:56 -08:00
Matthew Christopher c446f1d91e
Azure SQL FailoverGroup improvements (#1361)
* Azure SQL FailoverGroup improvements

 - Fix bug preventing reconciliation of updates after a FailoverGroup
   was created.
 - Fix bug where status of long running operation was not properly
   monitored.

* Add unit tests to CI
2021-01-20 13:22:43 -08:00
Matthew Christopher 10e3c6e5b2
Add AzureSQL short term retention policies (#1355)
* Add AzureSQL short term retention policies
2021-01-13 14:17:27 -08:00
Matthew Christopher 892b3624ae
Provisioning AccessPolicy and KeyVault at same time (#1352)
The operator was originally reconciling AccessPolicy's after the rest of the KV
had been created (see: #1158). This isn't actually required because even doing
this there are tons of reasons that this can fail. I've filed #1351 to track
removing ClientID from the CRD in a future API version as there are a ton of
obscure ways that we can fail to translate that ID into an ObjectID.
2021-01-12 12:35:39 -08:00
Matthew Christopher cdbb8aeefe
Fix 0.1.0 Helm chart to refer to correct container image version (#1349)
* Fix README to refer to current version of helm chart

 - Don't specify using :latest for the controller image
   in the README either as that defeats the purpose of
   hardcoding the specific image in the Helm chart.

* Fix 0.1.0 Helm chart to refer to correct container image version

 - Using :latest is not correct as that means it will always be
   pulling the latest version of the docker container.

* Fix possible null reference error
2021-01-11 13:22:28 -08:00
Christian Muirhead b3110322d8
Continue reconciling Azure SQL managed users for unknown errors (#1336)
These could be setup issues like the AAD admin not being set on the
server - giving up immediately means the only way to get the user
created successfully is to edit the resource to remove the finalizer,
delete it, then re-add. The reconcile loop for regular users doesn't
use this pattern of returning true, nil when it can't reach the server.
2021-01-08 09:37:27 +13:00
Christian Muirhead f6f847be8f
Don't ignore errors checking whether a being-deleted DB exists (#1338)
This can mean that if there's a communication error when checking with
Azure then we just remove the k8s database resource without trying to
delete the Azure one.
2020-12-21 16:02:58 +13:00
Colin D Murphy a50a59e020
Add optional VNET Subscription ID to VNET rules. (#1333)
* Add optional VNET Subscription ID to VNET rules.

* Update pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule.go
2020-12-17 10:10:53 +13:00
Christian Muirhead 82f75eab23
Clarify documentation for sample MySQLAdministrator (#1334)
* Clarify that Sid should be client ID for managed identities

* Add more detail to logging for errors connecting to MySQL

Co-authored-by: Bevan Arps <bevan.arps@microsoft.com>
2020-12-16 10:17:55 +13:00
Matthew Christopher c3fa70488c
Update to support AAD users and groups too (#1319) 2020-11-25 16:41:08 -08:00