-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 test/framework: improve the way we inject the ci-artifacts script #4420
🌱 test/framework: improve the way we inject the ci-artifacts script #4420
Conversation
0f420ff
to
8c42b45
Compare
DEBIAN_FRONTEND=noninteractive apt-get install -y apt-transport-https curl | ||
export DEBIAN_FRONTEND=noninteractive | ||
# sometimes the network is not immediately available, so we have to retry the apt-get update | ||
retry 10 5 "apt-get 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.
I had to do this because the network did not immediately work after boot in our case. It's fine if we don't want this in the main repo, I can move it to a provider-specific script which is run before in CAPO.
//go:embed data/kustomization.yaml | ||
kustomizationYamlBytes []byte | ||
//go:embed data/debian_injection_script_control_plane.envsubst.sh | ||
debianInjectionScriptControlPlaneBytes string |
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.
An alternative to duplicating the script would have been to template the images we pull (that's the only difference between the two scripts). I just thought another layer of templating would be a bad idea.
I'm not sure if there is a good way to auto-discover if the script runs on a control plane or worker node.
// * scriptPath: is the path where the script will be stored at | ||
// * scriptContent: content of the script | ||
func generateInjectScriptJSONPatch(sourceTemplate []byte, objectKind, objectName, jsonPatchPathPrefix, scriptPath, scriptContent string) ([]byte, error) { | ||
filesPathExists, preKubeadmCommandsPathExists, err := checkIfArraysAlreadyExist(sourceTemplate, objectKind, objectName, jsonPatchPathPrefix) |
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 where it gets pretty hacky. I couldn't find a way via JSON patch to just "create an array if it isn't there". That's why I have to check first if the arrays already exist and only add them if they don't exist before.
I could have always set the arrays to an empty array but this would have overwritten every preexisting array elements.
I thought about just parsing the relevant objects, changing them and generating a JSON patch for the diff, maybe that would be better.
What do you think?
8c42b45
to
c552b88
Compare
c552b88
to
90a96a2
Compare
36a0f59
to
2eb0e2b
Compare
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.
/lgtm
/assign @fabriziopandini
Would be also good to get a review from some CAPA folks as CAPA is using the old version of this util at the moment. P.S. Fyi, I'm using a 100% exact copy of this package in CAPO on the main branch and it works fine there. |
@fabriziopandini @vincepri @CecileRobertMichon What do you think we should do to get this PR merged? :) Anyone to cc/ping for further review? |
lgtm waiting for someone from CAPA to review |
@sbueringer
For the sake of maintaining them easier, is there a way to combine these? |
/lgtm |
Let's rebase on top of #4922 and then I can test it again. |
ba9c0a5
to
0c3182f
Compare
Included the changes from #4922 and squashed. |
testing now |
Seems to be working I would amend your commit to add @jackfrancis as a co-author and then can lgtm. |
Here's the generated CAPA template https://gist.github.com/randomvariable/0b8e4d4334fcaf120c2ad902b1ff4510 |
b816733
to
5f95ba2
Compare
Signed-off-by: Stefan Büringer [email protected] Co-authored-by: Jack Francis <[email protected]>
5f95ba2
to
b2d9539
Compare
Good point, should be correct now. |
/lgtm |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon 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 |
If you're not going to use |
Opened #4958 (not using gsutil means we don't need to reference GCS bucket names anymore, which would be awesome) |
Nice, I removed gsutil because it took a bit long to install, so that wasn't really worth it. Good to see that it also helps with getting rid of references to the bucket |
What this PR does / why we need it:
This PR changes the way we patch the
ci-artifacts.sh
script. Up until now we used strategic merge patch. This overwrote thefiles
andpreKubeadmCommands
arrays. That was the reason this functionality could not be reused in CAPO and CAPZ (kubernetes-sigs/cluster-api-provider-azure#1018 (comment)). The new version is implemented with JSON patch and just appends the script to the arrays. Because we append the script, it's also possible to run some provider-specific scripts before.Further improvements:
Some more details on the linked issue.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #4386
Notes: