Skip to content

Commit

Permalink
fix(webhook): populate admissionReviewVersions as a required value (#…
Browse files Browse the repository at this point in the history
…1799)

Signed-off-by: prateekpandey14 <[email protected]>
  • Loading branch information
prateekpandey14 authored Apr 8, 2021
1 parent 892f231 commit 2de0303
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 42 deletions.
49 changes: 20 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,35 @@ addons:
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq
- sudo apt-get install --yes -qq gcc jq
- sudo apt-get install --yes -qq gcc jq zip conntrack
- sudo apt-get install --yes -qq libudev-dev

install: true
- make bootstrap
- make format

before_script:
# Install build/test dependencies for each platform
# Download kubectl, which is a requirement for using minikube.
# Download minikube.
# Wait for Kubernetes to be up and ready.
- if [ "$TRAVIS_CPU_ARCH" == "amd64" ]; then
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/;
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.35.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/;
mkdir -p $HOME/.kube $HOME/.minikube;
touch $KUBECONFIG;
sudo minikube start --vm-driver=none --kubernetes-version=v1.13.0;
sudo chown -R travis /home/travis/.minikube/;
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done;
fi
# install zip package for arm64
- if [[ "$TRAVIS_CPU_ARCH" == "arm64" || "$TRAVIS_CPU_ARCH" == "ppc64le" ]]; then
sudo apt-get install --yes zip;
fi
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl
&& chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.8.1/minikube-linux-amd64
&& chmod +x minikube && sudo mv minikube /usr/local/bin/
- mkdir -p $HOME/.kube $HOME/.minikube
- touch $KUBECONFIG
- sudo minikube start --profile=minikube --vm-driver=none --kubernetes-version=v1.18.1
- minikube update-context --profile=minikube
- "sudo chown -R travis: /home/travis/.minikube/"
- eval "$(minikube docker-env --profile=minikube)" && export DOCKER_CLI='docker'
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
sleep 1; done
script:
# Verify kube-addon-manager.
# kube-addon-manager is responsible for managing other kubernetes components, such as kube-dns, dashboard, storage-provisioner.
- if [ "$TRAVIS_CPU_ARCH" == "amd64" ]; then
kubectl cluster-info;
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done;
kubectl get deployment;
fi
- kubectl cluster-info
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH"
2>&1 | grep -q "Ready=True"; do sleep 1;echo "waiting for kube-dns to
be available"; kubectl get pods --all-namespaces; done
- ./buildscripts/travis-build.sh
- if [ "$TRAVIS_CPU_ARCH" == "amd64" ]; then
./ci/travis-ci.sh;
fi
- make deploy-images
- ./ci/travis-ci.sh;
# If this build is running due to travis release tag, and
# this job indicates to push the release downstream, then
# go ahead and tag the dependent repo.
Expand Down
15 changes: 7 additions & 8 deletions ci/build-maya.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ IMAGE_ORG=${IMAGE_ORG:-openebs}
set -e
# If any of the images aren't present the script will exit returning
# a non zero exit code, which will result in a build failure.
if [ ${CI_TAG} != "ci" ]; then
sudo docker tag ${IMAGE_ORG}/m-apiserver-amd64:ci ${IMAGE_ORG}/m-apiserver:${CI_TAG}
sudo docker tag ${IMAGE_ORG}/cstor-pool-mgmt-amd64:ci ${IMAGE_ORG}/cstor-pool-mgmt:${CI_TAG}
sudo docker tag ${IMAGE_ORG}/cstor-volume-mgmt-amd64:ci ${IMAGE_ORG}/cstor-volume-mgmt:${CI_TAG}
fi
sudo docker tag "${IMAGE_ORG}"/m-apiserver-amd64:ci "${IMAGE_ORG}"/m-apiserver:${CI_TAG}
sudo docker tag "${IMAGE_ORG}"/cstor-pool-mgmt-amd64:ci "${IMAGE_ORG}"/cstor-pool-mgmt:${CI_TAG}
sudo docker tag "${IMAGE_ORG}"/cstor-volume-mgmt-amd64:ci "${IMAGE_ORG}"/cstor-volume-mgmt:${CI_TAG}
sudo docker tag "${IMAGE_ORG}"/admission-server-amd64:ci "${IMAGE_ORG}"/admission-server:${CI_TAG}

#Tag the images with quay.io, since the operator can either have quay or docker images
#Note the quay tags are hard-coded to help with CI scripts that might use the quay.io/openebs prefix
# The quay images tagged here are not pushed.
sudo docker tag ${IMAGE_ORG}/m-apiserver-amd64:ci quay.io/openebs/m-apiserver:${CI_TAG}
sudo docker tag ${IMAGE_ORG}/cstor-pool-mgmt-amd64:ci quay.io/openebs/cstor-pool-mgmt:${CI_TAG}
sudo docker tag ${IMAGE_ORG}/cstor-volume-mgmt-amd64:ci quay.io/openebs/cstor-volume-mgmt:${CI_TAG}
sudo docker tag "${IMAGE_ORG}"/m-apiserver-amd64:ci quay.io/openebs/m-apiserver:"${CI_TAG}"
sudo docker tag "${IMAGE_ORG}"/cstor-pool-mgmt-amd64:ci quay.io/openebs/cstor-pool-mgmt:"${CI_TAG}"
sudo docker tag "${IMAGE_ORG}"/cstor-volume-mgmt-amd64:ci quay.io/openebs/cstor-volume-mgmt:"${CI_TAG}"

## install iscsi pkg
echo "Installing iscsi packages"
Expand Down
9 changes: 5 additions & 4 deletions pkg/webhook/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,10 @@ func createValidatingWebhookConfig(
},
CABundle: signingCert,
},
TimeoutSeconds: &five,
FailurePolicy: failurePolicy(),
SideEffects: &SideEffectClassNone,
TimeoutSeconds: &five,
FailurePolicy: failurePolicy(),
AdmissionReviewVersions: []string{"v1"},
SideEffects: &SideEffectClassNone,
}

validator := &v1.ValidatingWebhookConfiguration{
Expand Down Expand Up @@ -666,7 +667,7 @@ func preUpgrade(openebsNamespace string) error {
for _, config := range webhookConfigList.Items {
if config.Labels[string(apis.OpenEBSVersionKey)] != version.Current() {
if config.Labels[string(apis.OpenEBSVersionKey)] == "" ||
util.IsCurrentLessThanNewVersion(config.Labels[string(apis.OpenEBSVersionKey)], "1.12.0") {
util.IsCurrentLessThanNewVersion(config.Labels[string(apis.OpenEBSVersionKey)], "2.8.0") {
err = validate.KubeClient().Delete(config.Name, &metav1.DeleteOptions{})
if err != nil {
return fmt.Errorf("failed to delete older webhook config %s: %s", config.Name, err.Error())
Expand Down
7 changes: 6 additions & 1 deletion pkg/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,12 @@ func (wh *webhook) Serve(w http.ResponseWriter, r *http.Request) {
}
}

admissionReview := admissionv1.AdmissionReview{}
admissionReview := admissionv1.AdmissionReview{
TypeMeta: metav1.TypeMeta{
APIVersion: admissionv1.SchemeGroupVersion.String(),
Kind: "AdmissionReview",
},
}
if admissionResponse != nil {
admissionReview.Response = admissionResponse
if ar.Request != nil {
Expand Down

0 comments on commit 2de0303

Please sign in to comment.