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

Refactor adminUpdate steps #3376

Closed
wants to merge 12 commits into from
Closed

Conversation

mociarain
Copy link
Collaborator

@mociarain mociarain commented Feb 2, 2024

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 the m.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 on initializeOperatorDeployer?
    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:

  • The everything step runs everything happily.
  • The individual "branches" can be ran successfully.

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:

  1. Don't grow 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.
  2. Break up GeneralFixesSteps
    This would involve understanding the dependencies between steps and more understanding than me to group them better conceptually.

Comment on lines 107 to 108
// Block 8
steps.Action(m.renewMDSDCertificate),
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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)

@mociarain mociarain changed the title [WIP] Lay it out clearly Refactor adminUpdate steps Feb 5, 2024
)

func concatMultipleSlices[T any](slices ...[]T) []T {
Copy link
Collaborator Author

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?

Copy link

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

Copy link

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Comment on lines +39 to +40
"[Action startVMs-fm]",
"[Condition apiServersReady-fm, timeout 30m0s]",
Copy link
Collaborator Author

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.

)

func concatMultipleSlices[T any](slices ...[]T) []T {
result := []T{}
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

  1. Did you have a different implementation in mind?
  2. Is my heuristic just plain wrong?

@mociarain mociarain added ready-for-review go Pull requests that update Go code labels Feb 8, 2024
@mociarain mociarain requested a review from nwnt February 21, 2024 09:12
pkg/cluster/install.go Show resolved Hide resolved
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
Copy link
Contributor

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).

Copy link
Collaborator Author

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.

Comment on lines +119 to +121
steps.Action(m.fixSREKubeconfig),
steps.Action(m.fixUserAdminKubeconfig),
steps.Action(m.createOrUpdateRouterIPFromCluster),
Copy link
Contributor

@tiguelu tiguelu Mar 8, 2024

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

@jaitaiwan jaitaiwan left a 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.

)

func concatMultipleSlices[T any](slices ...[]T) []T {
Copy link
Contributor

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.

@mociarain mociarain mentioned this pull request Mar 11, 2024
2 tasks
@mociarain mociarain closed this Mar 11, 2024
@mociarain
Copy link
Collaborator Author

Closing in favour of: #3449

@mociarain mociarain deleted the tidy-up-adminUpdate branch March 11, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code ready-for-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants