-
Notifications
You must be signed in to change notification settings - Fork 242
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 & cleanup kclient generators code before migrating to devfile/parser #4134
Refactor & cleanup kclient generators code before migrating to devfile/parser #4134
Conversation
Skipping CI for Draft Pull Request. |
c781bb5
to
c152ca3
Compare
0cb83f8
to
269efe1
Compare
} | ||
objectMeta := generator.CreateObjectMeta(componentName, a.Client.Namespace, labels, nil) | ||
supervisordInitContainer := kclient.AddBootstrapSupervisordInitContainer() | ||
initContainers := utils.GetPreStartInitContainers(a.Devfile, containers) |
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.
why we need to pass containers to get init containers?
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.
containers
is all the component containers returned from the devfile. PreStart events reference a command(which in turn reference a container component). So we scan thru all the containers that we have and append to initContainers
// Add PVC and Volume Mounts to the podTemplateSpec | ||
err = kclient.AddPVCAndVolumeMount(podTemplateSpec, volumeNameToPVCName, containerNameToVolumes) | ||
// Get PVC volumes and Volume Mounts | ||
containers, pvcVolumes, err := kclient.GetPVCVolAndVolMount(containers, volumeNameToPVCName, containerNameToVolumes) |
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.
can we do the volume mount part while generating the containers?
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.
Probably can, but that should be done with GetVolumes refactoring. I have not touched those volume logic in this PR.
Pls see the commend below regd Volume refactoring
} | ||
|
||
// Get the container info for the given component | ||
if container, ok := containersMap[component]; ok { |
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.
little confused here, what's the benefit of overriding here? we are not returning containers
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've cleaned this up a little bit and I removed the map; this is basically the same comment as I have mentioned here #4134 (comment) - we pass in containers that we get from devfile to loop thru and append it to initcontainers.
pkg/kclient/generator/generators.go
Outdated
|
||
const ( | ||
// DevfileSourceVolume is the constant containing the name of the emptyDir volume containing the project source | ||
DevfileSourceVolume = "devfile-projects" |
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.
do the other projects follows the concept of source volume?
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 have asked this question on the forum-devfile Slack channel, lets wait for the outcome. I think all devfile consumers should sync the project somewhere in the pod.
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've moved the odo-projects
vol mount code out of the generators and made it odo specific
pkg/kclient/generator/generators.go
Outdated
} | ||
|
||
// GenerateContainer creates a container spec that can be used when creating a pod | ||
func GenerateContainer(containerParams ContainerParams) *corev1.Container { |
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.
we do not need to expose this method
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.
updated
|
||
// GeneratePVCSpec creates a pvc spec | ||
func GeneratePVCSpec(quantity resource.Quantity) *corev1.PersistentVolumeClaimSpec { | ||
|
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.
devfile should be input here and generate pvc specs according to volume component
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 left this untouched due to the GetVolume refactoring I was talking about. CreatePVC just takes corev1.PersistentVolumeClaimSpec
spec to create the pvc. The pvc name is tied with other logic and would need a separate PR to refactor it. I think thats going to be a bigger change.
pkg/kclient/generator/generators.go
Outdated
} | ||
|
||
// GenerateServiceSpec creates a service spec | ||
func GenerateServiceSpec(serviceSpecParams ServiceSpecParams) *corev1.ServiceSpec { |
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 should not be exposed
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.
updated
Codecov Report
@@ Coverage Diff @@
## master #4134 +/- ##
==========================================
+ Coverage 42.23% 42.57% +0.34%
==========================================
Files 155 156 +1
Lines 13204 13258 +54
==========================================
+ Hits 5577 5645 +68
+ Misses 7020 7012 -8
+ Partials 607 601 -6
Continue to review full report at Codecov.
|
bbc7ec6
to
d3f2ffa
Compare
6bfc498
to
2908742
Compare
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Stephanie <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
Signed-off-by: Maysun J Faisal <[email protected]>
84b72f1
to
60aaf7f
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
/retest Please review the full test history for this PR and help us cut down flakes. |
What type of PR is this?
/kind cleanup
/kind code-refactoring
What does does this PR do / why we need it:
This PR cleans up kclient generators code so that it can be exported out to devfile/parser repo:
createOrUpdateComponent()
logic around kclient refactoringWhich issue(s) this PR fixes:
Fixes #4131
PR acceptance criteria:
Unit test
Integration test
Documentation
I have read the test guidelines
How to test changes / Special notes to the reviewer: