-
Notifications
You must be signed in to change notification settings - Fork 169
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
Refactor adminUpdate steps #3376
Conversation
pkg/cluster/install.go
Outdated
// Block 8 | ||
steps.Action(m.renewMDSDCertificate), |
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 step has been added to the all/everything steps.
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 think it was a bug that it wasn't in everything)
pkg/cluster/install.go
Outdated
) | ||
|
||
func concatMultipleSlices[T any](slices ...[]T) []T { |
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.
Is there a better place for super generic helpers like this?
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.
Maybe somewhere like https://github.com/Azure/ARO-RP/tree/master/pkg/util/stringutils but with a rename to utils, but that nested utils folder makes me sad, so dunno
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.
something something rename to 'common' something something
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.
Looks like a good use of generics here.
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.
Golang 1.22 includes the new slices.Concat
method which would replace this function. I recommend we include the implementation ourselves for now. Nothing stands out immediately as something that can't be done in Go 1.20.
As far as function placement is concerned, I'd recommend pkg/util
maybe under a folder like generics
or helpers
although that can end up being a bucket for everything.
3ad3651
to
d595c41
Compare
"[Action startVMs-fm]", | ||
"[Condition apiServersReady-fm, timeout 30m0s]", |
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.
These now happen earlier in the ordering.
pkg/cluster/install.go
Outdated
) | ||
|
||
func concatMultipleSlices[T any](slices ...[]T) []T { | ||
result := []T{} |
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.
Nit: if the final size of the result array is known, we could use make
to preallocate the capacity. This will avoid unnecessary new slice memory allocations.
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.
So I considered something like this but I think I would need to loop over the slices twice. Once, to get the length, then build the array, then loop over the slices again to populate the array. My heuristic is that more looping is bad and dynamically adding to a slice would be better.
- Did you have a different implementation in mind?
- Is my heuristic just plain wrong?
d595c41
to
68b23ca
Compare
steps.Action(m.fixSSH), | ||
// steps.Action(m.removePrivateDNSZone), // TODO(mj): re-enable once we communicate this out | ||
) | ||
// Generic fix-up actions that are fairly safe to always take, and don't require a running cluster |
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.
Curious about why the fixInfraID
action is outside the list above. The actions in that list also comply with the description of the comment for this action (in the old code, the comment was actually for all of them).
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.
My thinking was that before there were several generic tasks that happened for every path. These were all clearly bootstrapping tasks apart from this one which is actually changing the state of the cluster.
steps.Action(m.fixSREKubeconfig), | ||
steps.Action(m.fixUserAdminKubeconfig), | ||
steps.Action(m.createOrUpdateRouterIPFromCluster), |
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.
The actionpopulateDatabaseIntIP
that populates the internal LB IP for the API into the DB was run before these 3 actions in the old code. I wonder if there was any requirement for that, since these 3 steps will require the API to be accessible.
Same wonder with the apiServersReady
condition after starting the VMs which is now in getZerothSteps
function before the DB IP fix runs, but it used to be after.
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.
The reason I moved this down is because populateDatabaseIntIP
patches doc.OpenShiftCluster.Properties.APIServerProfile.IntIP
. This property in only 2 other tasks:
For the startVMs
task I moved that back into bootstrapping because it seems to fit there better conceptually and I'm assuming the tasks that come before it in the if blocks can't be pre-requisites because we start the VMs in each path but only run some tasks before we start the VMs in isEverything
.
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.
Mostly LGTM, just one point on the slice concat. Noting that I think it should be a public function.
pkg/cluster/install.go
Outdated
) | ||
|
||
func concatMultipleSlices[T any](slices ...[]T) []T { |
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.
Golang 1.22 includes the new slices.Concat
method which would replace this function. I recommend we include the implementation ourselves for now. Nothing stands out immediately as something that can't be done in Go 1.20.
As far as function placement is concerned, I'd recommend pkg/util
maybe under a folder like generics
or helpers
although that can end up being a bucket for everything.
Closing in favour of: #3449 |
Which issue this PR addresses:
A refactor to lay the groundwork for: https://issues.redhat.com/browse/ARO-5327
What this PR does / why we need it:
I've smashed all the various
if
blocks to give us another view on what this is doing and hopefully, this is clearer. I've preserved the step execution order (mostly) because it's not clear to me what exactly what dependencies are involved. Functionally, I believe this is identical to what we had before but now there is some extra repeats of certain idempotent steps.Note: I noticed that in the
everything
path weren't actually running them.renewMDSDCertificate
step. This PR fixes this.Some questions:
Is it valid to run this with all flags set to false? Technically, it would have done bootstrap 0 & 1 and step 0 but here I set it to panic.It is valid according to the unit tests.
Is the hive stuff dependant oninitializeOperatorDeployer
?No.
Related PUCM scipt PR: https://msazure.visualstudio.com/AzureRedHatOpenShift/_git/ARO-Scripts/pullrequest/9515547
Test plan for issue:
I've tested this and it's using my local RP to prove that:
Is there any documentation that needs to be updated for this PR?
https://msazure.visualstudio.com/AzureRedHatOpenShift/_git/WIKI-Designs/pullrequest/9515543
Future Ideas/Thoughts:
GeneralFixesSteps
This is now a kind of dumping ground of random things that we should stop adding to IMO. It's only going to snowball and hopefully what I have done here shows how we could define extra groups and add them with correct context.
GeneralFixesSteps
This would involve understanding the dependencies between steps and more understanding than me to group them better conceptually.