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

WIP: HIVE-2433: add a new privatelink controller #2290

Closed
wants to merge 1 commit into from

Conversation

jstuever
Copy link
Contributor

Add a new privatelink controller to eventually replace the awsprivatelink controller with a more modular approach. This will enable private link functionality to be extended to other platforms as well as between different platforms.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 21, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented May 21, 2024

@jstuever: This pull request references HIVE-2433 which is a valid jira issue.

In response to this:

Add a new privatelink controller to eventually replace the awsprivatelink controller with a more modular approach. This will enable private link functionality to be extended to other platforms as well as between different platforms.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 21, 2024
@openshift-ci openshift-ci bot requested review from 2uasimojo and lleshchi May 21, 2024 20:02
Copy link
Contributor

openshift-ci bot commented May 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jstuever

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 21, 2024
Copy link

codecov bot commented May 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.54%. Comparing base (f910c9b) to head (95c45cb).
Report is 10 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2290   +/-   ##
=======================================
  Coverage   58.54%   58.54%           
=======================================
  Files         182      182           
  Lines       25829    25830    +1     
=======================================
+ Hits        15122    15123    +1     
  Misses       9431     9431           
  Partials     1276     1276           
Files Coverage Δ
pkg/constants/constants.go 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

Copy link
Member

@2uasimojo 2uasimojo left a comment

Choose a reason for hiding this comment

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

Great start ❤️

Comment on lines +92 to 93
privatelink.ControllerName: privatelink.Add,
awsprivatelink.ControllerName: awsprivatelink.Add,
Copy link
Member

Choose a reason for hiding this comment

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

Right away we'll want logic to mutex these two, probably here-ish, possibly at the behest of a FeatureGate; but I'd be just as happy doing it with an env var since we'll probably cut over as soon as the new thing is proven for AWS.

pkg/constants/constants.go Outdated Show resolved Hide resolved
pkg/controller/privatelink/conditions/conditions.go Outdated Show resolved Hide resolved
pkg/controller/privatelink/conditions/conditions.go Outdated Show resolved Hide resolved
pkg/controller/privatelink/privatelink_controller.go Outdated Show resolved Hide resolved
logger log.FieldLogger) error {

curr := &hivev1.ClusterDeployment{}
errGet := client.Get(context.TODO(), types.NamespacedName{Namespace: cd.Namespace, Name: cd.Name}, curr)
Copy link
Member

Choose a reason for hiding this comment

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

"

return reconcile.Result{}, nil
}
privateLinkEnabled = cd.Spec.Platform.AWS.PrivateLink.Enabled
clientActuator, err = r.GetActuator(configv1.AWSPlatformType, logger)
Copy link
Member

Choose a reason for hiding this comment

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

I suspect it'll wind up being easier to make all of the actuators part of the reconciler struct vs trying to pass them around as func args. It also may make it easier to mock them out for UT.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The (now) spokeActuator is specific to each individual CD, having cloud-specific code and client service account credentials. We could create actuators for each cloud and pass around a client instead.

Copy link
Member

Choose a reason for hiding this comment

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

As discussed, two actuators:

  • Hub actuator for the RH-owned infra that hive is running on. Only AWS supported for the current pass.
  • Spoke actuator tied to the cloud the spoke is running on, with two cloud clients:
    • RH-owned infra for the "link"
    • Customer-owned infra for the, uhh, "endpoint"?

...and we can't do what I suggested here because the reconciler is a singleton for the controller instance, and sharing it among CDs would be Bad™.

// Add finalizer if not already present
if !controllerutils.HasFinalizer(cd, finalizer) {
logger.Debug("adding finalizer to ClusterDeployment")
controllerutils.AddFinalizer(cd, finalizer)
Copy link
Member

Choose a reason for hiding this comment

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

We're going to have to think about how to transition a pre-existing CD managed by the awsprivatelink controller, which is going to include replacing the hive.openshift.io/aws-private-link finalizer with this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We discussed having the privatelink and awsprivatelink operators be mutually exclusive, with the active one always migrating the finalizer and conditions to itself. In other words, the privatelink operator, when active, would migrate the awsprivatelink finalizer and conditions to privatelink finalizer and conditions. At the same time, when the awsprivatelink operator is active, it would migrate the privatelink finalizer and conditions back to awsprivatelink finalizer and conditions. This would enable admins to switch between the two to test and easily revert while also making sure the migration happens.

return reconcile.Result{}, nil
}

// SpokePlatformValidate validates a cluster deployment in relation to the spoke platform.
Copy link
Member

Choose a reason for hiding this comment

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

I know these are stubs right now, but we'll eventually want to document more of the contract. For example, reading through where this one is called by the reconciler, it seems like it'll be expected to update the cd status rather than the caller being responsible for that. (Though I'm not sure that's the best contract, as it would result in some duplication in the impls...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the status being platform specific, the privatelink controller wouldn't know what information to add. At a minimum, the actuators would have to provide the data. We could have them return a status and have the controller apply that.

Copy link
Member

Choose a reason for hiding this comment

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

Cool cool, whatever shakes out cleanest; but whatever that is, let's make sure this comment spells it out. I don't want future-us to have to crack open impls and read code to find out which objects get updated therein.

Copy link
Contributor

openshift-ci bot commented Jun 7, 2024

@jstuever: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Comment on lines +374 to +380
if err != nil {
return reconcileResult, err
}

if !reconcileResult.IsZero() {
return reconcileResult, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

or:

Suggested change
if err != nil {
return reconcileResult, err
}
if !reconcileResult.IsZero() {
return reconcileResult, nil
}
if err != nil || !reconcileResult.IsZero() {
return reconcileResult, err
}

Comment on lines 535 to 539
// Incorporate the AWSPrivateLink configmap hash
confighash = computeHash("", confighash, awsPlConfigHash)

// Incorporate the PrivateLink configmap hash
confighash = computeHash("", confighash, plConfigHash)
Copy link
Member

Choose a reason for hiding this comment

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

the hashes arg is variadic, so we can combine these:

Suggested change
// Incorporate the AWSPrivateLink configmap hash
confighash = computeHash("", confighash, awsPlConfigHash)
// Incorporate the PrivateLink configmap hash
confighash = computeHash("", confighash, plConfigHash)
// Incorporate the [AWS]PrivateLink configmap hashes
confighash = computeHash("", confighash, awsPlConfigHash, plConfigHash)

That said, we could check which controller is active by inspecting the controllersConfig and only process (above) and incorporate the hash (here) for the active one. The benefit being that we don't reroll all the hive pods if the inactive one changes. I don't know if we want to try to be that clever though :)

@@ -142,6 +142,7 @@ func (r *ReconcileHiveConfig) deployHiveAdmission(hLog log.FieldLogger, h resour

addConfigVolume(&hiveAdmDeployment.Spec.Template.Spec, managedDomainsConfigMapInfo, hiveAdmContainer)
addConfigVolume(&hiveAdmDeployment.Spec.Template.Spec, awsPrivateLinkConfigMapInfo, hiveAdmContainer)
addConfigVolume(&hiveAdmDeployment.Spec.Template.Spec, privateLinkConfigMapInfo, hiveAdmContainer)
Copy link
Member

Choose a reason for hiding this comment

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

TODO: Adapt webhook validation to consume from the new configmap, when applicable. (And of course ultimately to do whatever necessary validation on the GCP incarnation of the config when it exists.)

And again, we could decide to only add the configmap for the active controller here.

@jstuever
Copy link
Contributor Author

jstuever commented Jul 2, 2024

These changes are being included in HIVE-2435 pr #2340

@jstuever jstuever closed this Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants