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.
why we need to pass containers to get init containers?
There was a problem hiding this comment.
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.
can we do the volume mount part while generating the containers?
There was a problem hiding this comment.
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.
little confused here, what's the benefit of overriding here? we are not returning containers
There was a problem hiding this comment.
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.
|
|
||
| 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.
do the other projects follows the concept of source volume?
There was a problem hiding this comment.
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.
I've moved the odo-projects vol mount code out of the generators and made it odo specific
| } | ||
|
|
||
| // 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.
we do not need to expose this method
|
|
||
| // GeneratePVCSpec creates a pvc spec | ||
| func GeneratePVCSpec(quantity resource.Quantity) *corev1.PersistentVolumeClaimSpec { | ||
|
|
There was a problem hiding this comment.
devfile should be input here and generate pvc specs according to volume component
There was a problem hiding this comment.
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.
| } | ||
|
|
||
| // GenerateServiceSpec creates a service spec | ||
| func GenerateServiceSpec(serviceSpecParams ServiceSpecParams) *corev1.ServiceSpec { |
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 <yangcao@redhat.com>
Signed-off-by: Stephanie <yangcao@redhat.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Stephanie <yangcao@redhat.com>
Signed-off-by: Stephanie <yangcao@redhat.com>
Signed-off-by: Stephanie <yangcao@redhat.com>
Signed-off-by: Stephanie <yangcao@redhat.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
84b72f1 to
60aaf7f
Compare
|
/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: