Skip to content

Commit

Permalink
Late-initialize spec.forProvider.user of Broker.mq iff spec.initProvi…
Browse files Browse the repository at this point in the history
…der.user is not specified

- Move spec.forProvider.user of the Broker.mq dependency to spec.initProvider.user in the
  User.mq example manifest.

Signed-off-by: Alper Rifat Ulucinar <[email protected]>
  • Loading branch information
ulucinar committed May 24, 2024
1 parent 1ff091d commit 29aa8ba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions apis/mq/v1beta1/zz_broker_terraformed.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions config/mq/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ func Configure(p *config.Provider) {
}
return conn, nil
}
// we need to prevent a race between the Broker.mq & User.mq
// controllers when the users are specified under the spec.forProvider.
// This configuration will prevent the upjet runtime from
// late-initializing spec.forProvider.user when the bootstrap users
// are specified under spec.initProvider. Without this configuration,
// spec.forProvider gets initialized even if the bootstrap users are
// specified under spec.initProvider.
r.LateInitializer = config.LateInitializer{
ConditionalIgnoredFields: []string{
"user",
},
}
})

p.AddResourceConfigurator("aws_mq_user", func(r *config.Resource) {
Expand Down
12 changes: 11 additions & 1 deletion examples/mq/v1alpha1/user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ kind: User
metadata:
annotations:
meta.upbound.io/example-id: mq/v1alpha1/user
upjet.upbound.io/manual-intervention: "Note that there is a race between Broker and User controllers."
labels:
testing.upbound.io/example-name: example
name: example
Expand Down Expand Up @@ -47,6 +46,17 @@ spec:
engineType: ActiveMQ
engineVersion: 5.17.6
hostInstanceType: mq.t3.micro
# bootstrap users must be specified under spec.initProvider if the Broker.mq
# MR is to be used together with User.mq MRs, as the controllers for these
# MRs race on the external ActiveMQ broker users if the bootstrap users are
# specified under spec.forProvider, and the AWS CreateBroker/mq
# REST operation requires at least one user to be specified while
# provisioning a broker. Other techniques, such as pausing reconciliations
# for the Broker.mq object using the pause annotation, or preventing updates
# using the management policies will also prevent this race between
# the controllers but the "XRM way" is to use the spec.initProvider API in
# this situation.
initProvider:
user:
- passwordSecretRef:
key: password
Expand Down

0 comments on commit 29aa8ba

Please sign in to comment.