Skip to content

Commit

Permalink
fix: empty target keda workload
Browse files Browse the repository at this point in the history
  • Loading branch information
revoltez committed Mar 20, 2024
1 parent 6973e7a commit f683e01
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
9 changes: 8 additions & 1 deletion pkg/kubernetes/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ func ApplyPodRequest(
case *pb.Container_Port_HostHttpHost:
httpSO.Spec.ScaleTargetRef.Service = service.ObjectMeta.Name
httpSO.Spec.ScaleTargetRef.Port = servicePort
httpSO.Spec.ScaleTargetRef.APIVersion = "apps/v1"

multiaddrPart = fmt.Sprintf("http/%s", httpSO.Spec.Hosts[0])
case *pb.Container_Port_HostTcpPort:
multiaddrPart = fmt.Sprintf("tcp/%d", service.Spec.Ports[0].NodePort)
Expand Down Expand Up @@ -237,7 +239,8 @@ func ApplyPodRequest(
activeResource = append(activeResource, deploymentName)

if httpSO.Spec.ScaleTargetRef.Service != "" {
httpSO.Spec.ScaleTargetRef.Kind = deployment.ObjectMeta.Name
httpSO.Spec.ScaleTargetRef.Kind = "Deployment"
httpSO.Spec.ScaleTargetRef.Name = deploymentName
minReplicas := int32(podManifest.Replicas.GetMin())
maxReplicas := int32(podManifest.Replicas.GetMax())
targetPendingRequests := int32(podManifest.Replicas.GetTargetPendingRequests())
Expand All @@ -250,6 +253,10 @@ func ApplyPodRequest(
if targetPendingRequests > 0 {
httpSO.Spec.TargetPendingRequests = &targetPendingRequests
}
// update status
httpSO.Status = kedahttpv1alpha1.HTTPScaledObjectStatus{}
httpSO.Status.TargetWorkload = fmt.Sprintf("%s/%s/%s", httpSO.Spec.ScaleTargetRef.APIVersion, httpSO.Spec.ScaleTargetRef.Kind, httpSO.Spec.ScaleTargetRef.Name)
httpSO.Status.TargetService = fmt.Sprintf("%s:%d", httpSO.Spec.ScaleTargetRef.Service, httpSO.Spec.ScaleTargetRef.Port)

err := updateOrCreate(ctx, httpSoName, "HttpSo", namespace, httpSO, client, update)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/constellation/qemu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ sed -i.bak -e "/^\s*4:/ {n;s/\( *expected: \).*$/\1$PCR4/}" \
-e "/^\s*11:/ {n;s/\( *expected: \).*$/\1$PCR11/}" constellation-conf.yaml
# Replace the control plance count & nodes to 1
sed -i 's/initialCount: [0-9]*/initialCount: 1/' "constellation-conf.yaml"
sed -i 's/vcpus: [0-9]*/vcpus: 4/' "constellation-conf.yaml"
sed -i 's/memory: [0-9]*/memory: 4096/' "constellation-conf.yaml"

output=$(constellation version)
version=$(echo "$output" | grep -oP 'Version:\s+\K\S+' | head -n 1)
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/constellation/qemu/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ echo -e "---\e[0m"

## 1: Start the constellation cluster
cd "$WORKSPACE_PATH"*
constellation terminate
constellation apply -y

## 1.1: wait for the setup
Expand All @@ -44,14 +45,13 @@ kubectl wait --namespace trustedpods --for=condition=available deployment/tpodse

[ "$PORT_8545" == "" ] && { PORT_8545="yes" ; kubectl port-forward --namespace eth svc/eth-rpc 8545:8545 & }

sleep 2

DEPLOYER_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 #TODO= anvil.accounts[0]

TOKEN_CONTRACT=0x5fbdb2315678afecb367f032d93f642f64180aa3 # TODO= result of forge create

forge create --root ../../../../contracts MockToken --private-key $DEPLOYER_KEY
forge create --root ../../../../contracts Payment --private-key $DEPLOYER_KEY --constructor-args $TOKEN_CONTRACT
forge create --root ../../../../contracts Registry --private-key $DEPLOYER_KEY

( cd ../../../../contracts; forge script script/Deploy.s.sol --private-key "$DEPLOYER_KEY" --rpc-url http://127.0.0.1:8545 --broadcast)

## 2.1: Register the provider
[ "$PORT_5004" == "" ] && { PORT_5004="yes" ; kubectl port-forward --namespace ipfs svc/ipfs-rpc 5004:5001 & sleep 0.5; }
Expand Down Expand Up @@ -118,7 +118,7 @@ set -x
sudo chmod o+rw /run/containerd/containerd.sock


go run ../../../../cmd/trustedpods/ pod deploy ../../common/manifest-redmine-nostorage.yaml \
go run ../../../../cmd/trustedpods/ pod deploy ../../common/manifest-nginx.yaml \
--ethereum-key "$PUBLISHER_KEY" \
--payment-contract "$PAYMENT_CONTRACT" \
--registry-contract "$REGISTRY_CONTRACT" \
Expand All @@ -134,7 +134,7 @@ TOKEN_CONTRACT=$(cat ../../../contracts/broadcast/Deploy.s.sol/31337/run-latest.
NODE_ADDRESS=$(kubectl get no -o json | jq -r '.items[].status.addresses[] | select(.type == "InternalIP") | .address' | head -n 1)
INGRESS_PORT=$(kubectl get svc -n keda ingress-nginx-controller -o json | jq -r '.spec.ports[] | select(.name == "http") | .nodePort' | head -n 1)
INGRESS_URL="http://$NODE_ADDRESS:$INGRESS_PORT"; echo $INGRESS_URL
MANIFEST_HOST=guestbook.localhost # From manifest-guestbook.yaml
MANIFEST_HOST=example.local # From manifest-guestbook.yaml

[ "$PORT_8545" == "" ] && { PORT_8545="yes" ; kubectl port-forward --namespace eth svc/eth-rpc 8545:8545 & }

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/minikube/helmfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ releases:
- 'keda'
- '--for=condition=available'
- 'deployment/ingress-nginx-controller'
- '--timeout=800s'
- '--timeout=1600s'
- name: keda-http-addon
namespace: keda
chart: kedacore/keda-add-ons-http
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/minikube/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ go run ../../../cmd/trustedpods/ pod deploy ../common/manifest-nginx.yaml \
--payment-contract "$PAYMENT_CONTRACT" \
--registry-contract "$REGISTRY_CONTRACT" \
--funds "$FUNDS" \
--upload-images=false \
--upload-images=true \
--mint-funds

set +x
Expand All @@ -165,14 +165,14 @@ set -v
WITHDRAW_ETH=0x90F79bf6EB2c4f870365E785982E1f101E93b906 #TODO copied from trustedpods/tpodserver.yml
TOKEN_CONTRACT=$(cat ../../../contracts/broadcast/Deploy.s.sol/31337/run-latest.json | jq -r '.returns.token.value')
INGRESS_URL=$(minikube service -n keda ingress-nginx-controller --url=true | head -n 1); echo $INGRESS_URL
MANIFEST_HOST=example.local # From manifest-guestbook.yaml
MANIFEST_HOST=example.local # From manifest-nginx.yaml

echo "Provider balance before:" $(cast call "$TOKEN_CONTRACT" "balanceOf(address)" "$WITHDRAW_ETH" | cast to-fixed-point 18)

set -x

while ! curl --connect-timeout 40 -H "Host: $MANIFEST_HOST" $INGRESS_URL --fail-with-body; do sleep 10; done
curl -H "Host: $MANIFEST_HOST" $INGRESS_URL/test.html --fail-with-body
curl -H "Host: $MANIFEST_HOST" $INGRESS_URL --fail-with-body

set +x

Expand Down

0 comments on commit f683e01

Please sign in to comment.