-
Notifications
You must be signed in to change notification settings - Fork 81
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
CLOUDP-280230: Network peering controller and CRD #1930
base: main
Are you sure you want to change the base?
Conversation
3e4d019
to
a1ae865
Compare
f2a35cc
to
1d71818
Compare
) | ||
|
||
func TestNetworkPeeringProjectRefCELValidations(t *testing.T) { | ||
launchProjectRefCELTests( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: what is being asserted here? launchProjectRefCELTests
has no indication what test cases are being executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting, because all cases were always the same for all the using structs. The thing is, the only change was the dual reference was used by one or another underlying CRD type, but that does not change the behaviour or correctness of how the dual ref is handled.
We could fix this in a separate PR, I think we can have a single test for this in a single place and just keep on adding underlaying CRDs to test as carriers of the dual reference to be tested.
WDYT?
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec AtlasNetworkPeeringSpec `json:"spec,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: are we following the rules described in https://ahmet.im/blog/crd-generation-pitfalls/index.html#explicit-required-or-optional-on-every-field for all spec fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will double check that for when we surface this again, both for the NetworkContainer and the PeeringConnection CRDs.
@@ -219,6 +220,18 @@ func (b *Builder) Build(ctx context.Context) (cluster.Cluster, error) { | |||
return nil, fmt.Errorf("unable to create indexers: %w", err) | |||
} | |||
|
|||
npeReconciler := atlasnetworkpeering.NewAtlasNetworkPeeringsReconciler( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking: this needs to be in the controller registry https://github.com/mongodb/mongodb-atlas-kubernetes/blob/main/internal/controller/registry.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hint: just add the constructor below https://github.com/mongodb/mongodb-atlas-kubernetes/blob/main/internal/controller/registry.go#L79
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! yep I also need to fix this for comply with the new Cluster support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in next update
atlasPeer = peer | ||
} | ||
inAtlas := atlasPeer != nil | ||
deleted := req.networkPeering.DeletionTimestamp != nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking: this doesn't catch the case of deletion timestamp being zero. Please use the IsZero()
method which asserts both nil and zero time.
//+kubebuilder:rbac:groups=atlas.mongodb.com,resources=atlasnetworkpeerings/status,verbs=get;update;patch | ||
//+kubebuilder:rbac:groups=atlas.mongodb.com,resources=atlasnetworkpeerings/finalizers,verbs=update | ||
|
||
// Reconcile is part of the main kubernetes reconciliation loop which aims to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking: this seems to be a scaffold comment, please fix ;-)
internal/indexer/indexer.go
Outdated
@@ -18,9 +18,9 @@ type Indexer interface { | |||
// RegisterAll registers all known indexers to the given manager. | |||
// It uses the given logger to create a new named "indexer" logger, | |||
// passing that to each indexer. | |||
func RegisterAll(ctx context.Context, c cluster.Cluster, logger *zap.Logger) error { | |||
func RegisterAll(ctx context.Context, mgr manager.Manager, logger *zap.Logger) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking: undo this change, we need to retain c cluster.Cluster
as a parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! I missed this detail on the rebase, I will fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted on next update
).ReconcileResult() | ||
} | ||
|
||
func (r *AtlasNetworkPeeringReconciler) sync(req *reconcileRequest, atlasPeer *networkpeering.NetworkPeer) ctrl.Result { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking: what is being sync
'ed here? as I read the code, updates in the spec are silently ignored. If the spec is immutable, we should talk w/ PM whether it makes sense to make the whole spec immutable (guarded via CEL) if Atlas doesn't support updates to network peers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we have updates in Atlas for both connections https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Network-Peering/operation/updatePeeringConnection and containers https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Network-Peering/operation/updatePeeringContainer.
Why aren't we leveraging that?
// Atlas Network Peering reasons | ||
const ( | ||
NetworkPeeringConnectionCreating ConditionReason = "NetworkPeeringConnectionCreating" | ||
NetworkPeeringConnectionResetting ConditionReason = "NetworkPeeringConnectionResetting" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking: this status condition is unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in next update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple of comments, great work! 👏
Making this a draft again, as we plan to re-design the Peering Connection - Network Container relationship, to make Networks a first class CRD as well. Still I would like to address most of the comments as I will be using this branch for continuing work and this and will need it to be rebase-able as close to main as possible. |
Signed-off-by: jose.vazquez <[email protected]>
Signed-off-by: jose.vazquez <[email protected]>
c147102
to
f3ac29e
Compare
Network peering support is sliced into 3 logical changes:
All Submissions: