Skip to content

Commit

Permalink
Fix the sidecar e2e test.
Browse files Browse the repository at this point in the history
Signed-off-by: Ye Cao <[email protected]>
  • Loading branch information
dashanji committed Feb 19, 2024
1 parent c85cca3 commit a8126d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions k8s/pkg/webhook/sidecar/sidecar_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (r *Injector) Handle(ctx context.Context, req admission.Request) admission.
sidecar := &v1alpha1.Sidecar{}
templatePod := &corev1.Pod{}
pod := &corev1.Pod{}
namespace := req.Namespace
if err := r.decoder.Decode(req, pod); err != nil {
return admission.Errored(http.StatusBadRequest, err)
}
Expand Down Expand Up @@ -93,7 +94,7 @@ func (r *Injector) Handle(ctx context.Context, req admission.Request) admission.
// replace the invalid characters in the name
re := regexp.MustCompile(`[^a-zA-Z0-9.-]+`)
sidecar.Name = re.ReplaceAllString(sidecar.Name, "-")
sidecar.Namespace = pod.Namespace
sidecar.Namespace = namespace
sidecar.OwnerReferences = pod.OwnerReferences
err := r.Get(
ctx,
Expand All @@ -107,9 +108,9 @@ func (r *Injector) Handle(ctx context.Context, req admission.Request) admission.
// if the default sidecar cr doesn't exist, create it
if apierrors.IsNotFound(err) {
sidecar.Spec.Replicas = 1
sidecar.Namespace = namespace
// use default configurations
sidecar.Spec.Selector = keys[0] + "=" + l[keys[0]]

if err := r.Create(ctx, sidecar); err != nil {
logger.Error(err, "failed to create default sidecar cr")
return admission.Errored(http.StatusInternalServerError, err)
Expand All @@ -135,7 +136,7 @@ func (r *Injector) Handle(ctx context.Context, req admission.Request) admission.
// get the sidecar cr
if err := r.Get(
ctx,
types.NamespacedName{Name: v, Namespace: pod.Namespace},
types.NamespacedName{Name: v, Namespace: namespace},
sidecar,
); err != nil {
logger.Error(err, "get custom sidecar cr failed")
Expand Down
6 changes: 3 additions & 3 deletions k8s/test/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,21 @@ publish-repartition-images: push-dask-repartition push-dask-repartition-job1 pus
dask-repartition:
docker build repartition-demo/ -f Dockerfile \
--build-arg APP=dask-repartition.py \
--build-arg PYPI_DEPENDENCIES="msgpack==1.0.4 numpy==1.23.2 pandas==1.4.3 dask==2022.8.1 distributed==2022.8.1 lz4==4.0.0 cloudpickle==2.1.0 vineyard-dask" \
--build-arg PYPI_DEPENDENCIES="msgpack==1.0.4 numpy==1.23.2 toolz==0.12.0 pandas==1.4.3 dask==2022.8.1 distributed==2022.8.1 lz4==4.0.0 cloudpickle==2.1.0 vineyard-dask" \
-t $(REGISTRY)/dask-repartition:$(TAG)
.PHONY: dask-repartition

dask-repartition-job1:
docker build repartition-demo/ -f Dockerfile \
--build-arg APP=job1.py \
--build-arg PYPI_DEPENDENCIES="msgpack==1.0.4 numpy==1.23.2 pandas==1.4.3 dask==2022.8.1 distributed==2022.8.1 lz4==4.0.0 cloudpickle==2.1.0 vineyard-dask" \
--build-arg PYPI_DEPENDENCIES="msgpack==1.0.4 numpy==1.23.2 toolz==0.12.0 pandas==1.4.3 dask==2022.8.1 distributed==2022.8.1 lz4==4.0.0 cloudpickle==2.1.0 vineyard-dask" \
-t $(REGISTRY)/dask-repartition-job1:$(TAG)
.PHONY: dask-repartition-job1

dask-repartition-job2:
docker build repartition-demo/ -f Dockerfile \
--build-arg APP=job2.py \
--build-arg PYPI_DEPENDENCIES="msgpack==1.0.4 numpy==1.23.2 pandas==1.4.3 dask==2022.8.1 distributed==2022.8.1 lz4==4.0.0 cloudpickle==2.1.0 vineyard-dask" \
--build-arg PYPI_DEPENDENCIES="msgpack==1.0.4 numpy==1.23.2 toolz==0.12.0 pandas==1.4.3 dask==2022.8.1 distributed==2022.8.1 lz4==4.0.0 cloudpickle==2.1.0 vineyard-dask" \
-t $(REGISTRY)/dask-repartition-job2:$(TAG)
.PHONY: dask-repartition-job2

Expand Down
10 changes: 5 additions & 5 deletions k8s/test/e2e/assembly/local-assembly-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ setup:
sed 's/$job/job1/' k8s/test/e2e/assembly-demo/assembly-job.yaml | \
gomplate -d config=k8s/test/e2e/assembly-demo/assembly-job-config.yaml | \
kubectl apply -f -
wait:
- namespace: vineyard-job
resource: deployment/assembly-job1
for: condition=Available
while [[ -z $(kubectl logs -l app=assembly-job1 -n vineyard-job | grep "writer finished") ]]; \
do \
sleep 1; \
done
- name: install job2
command: |
sed 's/$job/job2/' k8s/test/e2e/assembly-demo/assembly-job.yaml | \
Expand All @@ -45,7 +45,7 @@ setup:

cleanup:
# always never success failure
on: success
on: always

verify:
# verify with retry strategy
Expand Down

0 comments on commit a8126d1

Please sign in to comment.