@@ -11,9 +11,9 @@ source ./cluster-up/hack/common.sh
1111source ./cluster-up/cluster/${KUBEVIRT_PROVIDER} /provider.sh
1212
1313if [ " ${KUBEVIRT_PROVIDER} " = " external" ]; then
14- CDI_SYNC_PROVIDER=" external"
14+ CDI_SYNC_PROVIDER=" external"
1515else
16- CDI_SYNC_PROVIDER=" kubevirtci"
16+ CDI_SYNC_PROVIDER=" kubevirtci"
1717fi
1818
1919source ./cluster-sync/${CDI_SYNC_PROVIDER} /provider.sh
@@ -68,8 +68,8 @@ function kill_running_operator {
6868 out=$( _kubectl get pods -n $CDI_NAMESPACE )
6969 out=($out )
7070 length=${# out[@]}
71- for (( idx= 0 ; idx< ${# out[@]} ; idx= idx+ 5 )) ; do
72- if [[ ${out[idx]} == cdi-operator-* ]] && [[ ${out[idx+ 2]} == " Running" ]]; then
71+ for (( idx = 0 ; idx < ${# out[@]} ; idx = idx + 5 )) ; do
72+ if [[ ${out[idx]} == cdi-operator-* ]] && [[ ${out[idx + 2]} == " Running" ]]; then
7373 _kubectl delete pod ${out[idx]} -n $CDI_NAMESPACE --grace-period=0 --force
7474 return
7575 fi
@@ -132,25 +132,25 @@ NEW_CDI_VER_PODS="./_out/tests/new_cdi_ver_pods"
132132# Note it will fail update to the same version
133133function wait_cdi_pods_updated {
134134 echo " Waiting $CDI_PODS_UPDATE_TIMEOUT seconds for all CDI pods to update"
135- if [ -f $NEW_CDI_VER_PODS ] ; then
135+ if [ -f $NEW_CDI_VER_PODS ]; then
136136 mv $NEW_CDI_VER_PODS $OLD_CDI_VER_PODS
137137 fi
138138 wait_time=0
139139 ret=0
140140 while [[ $ret -eq 0 ]] && [[ $wait_time -lt ${CDI_PODS_UPDATE_TIMEOUT} ]]; do
141141 wait_time=$(( wait_time + 5 ))
142- _kubectl get pods -n $CDI_NAMESPACE -l ' !cdi.kubevirt.io/testing' -o=jsonpath=' {range .items[*]}{.metadata.name}{"\n"}{.metadata.uid}{"\n"}{.spec.containers[*].image}{"\n"}{end}' > $NEW_CDI_VER_PODS
143- if [ -f $OLD_CDI_VER_PODS ] ; then
142+ _kubectl get pods -n $CDI_NAMESPACE -l ' !cdi.kubevirt.io/testing' -o=jsonpath=' {range .items[*]}{.metadata.name}{"\n"}{.metadata.uid}{"\n"}{.spec.containers[*].image}{"\n"}{end}' > $NEW_CDI_VER_PODS
143+ if [ -f $OLD_CDI_VER_PODS ]; then
144144 grep -qFxf $OLD_CDI_VER_PODS $NEW_CDI_VER_PODS || ret=$?
145- if [ $ret -eq 0 ] ; then
145+ if [ $ret -eq 0 ]; then
146146 sleep 5
147147 fi
148148 else
149149 ret=1
150150 fi
151151 done
152152 echo " Waited $wait_time seconds"
153- if [ $ret -eq 0 ] ; then
153+ if [ $ret -eq 0 ]; then
154154 echo " Not all pods updated"
155155 exit 1
156156 fi
@@ -168,7 +168,7 @@ function dump_upgrade_info {
168168# Setup some datavolumes in older version for testing upgrades
169169# Done unconditionally to make it easier to write tests.
170170function setup_for_upgrade_testing {
171- if _kubectl get namespace cdi-testing-old-version-artifacts ; then
171+ if _kubectl get namespace cdi-testing-old-version-artifacts; then
172172 echo " Old version testing environment already setup"
173173 return
174174 fi
@@ -199,6 +199,9 @@ function setup_for_upgrade_testing {
199199# Start functional test HTTP server.
200200# We skip the functional test additions for external provider for now, as they're specific
201201if [ " ${CDI_SYNC} " == " test-infra" ]; then
202+ if [ " ${CDI_DEPLOY_NP} " == true ]; then
203+ _kubectl apply -n ${CDI_NAMESPACE} -f " ./cluster-sync/networkpolicies/cdi-testing-np.yaml"
204+ fi
202205 configure_storage
203206 _kubectl apply -f " ./_out/manifests/cdi-testing-sa.yaml"
204207 _kubectl apply -f " ./_out/manifests/bad-webserver.yaml"
@@ -227,10 +230,11 @@ if [ "${CDI_SYNC}" == "test-infra" ]; then
227230 # vCenter (VDDK) test service:
228231 _kubectl apply -f " ./_out/manifests/vcenter.yaml"
229232 fi
230-
233+
231234 if _kubectl get crd securitycontextconstraints.security.openshift.io > /dev/null 2>&1 ; then
232235 _kubectl apply -f " ./_out/manifests/cdi-testing-scc.yaml"
233236 fi
237+
234238 exit 0
235239fi
236240
@@ -249,7 +253,7 @@ wait_cdi_crd_installed $CDI_INSTALL_TIMEOUT
249253
250254# If we are upgrading, verify our current value.
251255if [[ ! -z " $UPGRADE_FROM " ]]; then
252- UPGRADE_FROM_LIST=( $UPGRADE_FROM )
256+ UPGRADE_FROM_LIST=($UPGRADE_FROM )
253257 for VERSION in ${UPGRADE_FROM_LIST[@]} ; do
254258 echo $VERSION
255259 if [ " $VERSION " != " ${UPGRADE_FROM_LIST[0]} " ]; then
@@ -265,10 +269,10 @@ if [[ ! -z "$UPGRADE_FROM" ]]; then
265269 retry_counter=0
266270 kill_count=0
267271 while [[ $retry_counter -lt $CDI_UPGRADE_RETRY_COUNT ]] && [ " $operator_version " != " $VERSION " ]; do
268- cdi_cr_phase=` _kubectl get CDI -o=jsonpath=' {.items[*].status.phase}{"\n"}' `
269- observed_version=` _kubectl get CDI -o=jsonpath=' {.items[*].status.observedVersion}{"\n"}' `
270- target_version=` _kubectl get CDI -o=jsonpath=' {.items[*].status.targetVersion}{"\n"}' `
271- operator_version=` _kubectl get CDI -o=jsonpath=' {.items[*].status.operatorVersion}{"\n"}' `
272+ cdi_cr_phase=$( _kubectl get CDI -o=jsonpath=' {.items[*].status.phase}{"\n"}' )
273+ observed_version=$( _kubectl get CDI -o=jsonpath=' {.items[*].status.observedVersion}{"\n"}' )
274+ target_version=$( _kubectl get CDI -o=jsonpath=' {.items[*].status.targetVersion}{"\n"}' )
275+ operator_version=$( _kubectl get CDI -o=jsonpath=' {.items[*].status.operatorVersion}{"\n"}' )
272276 echo " Phase: $cdi_cr_phase , observedVersion: $observed_version , operatorVersion: $operator_version , targetVersion: $target_version "
273277 retry_counter=$(( retry_counter + 1 ))
274278 if [[ $kill_count -lt 1 ]]; then
@@ -292,20 +296,20 @@ if [[ ! -z "$UPGRADE_FROM" ]]; then
292296 retry_counter=0
293297 _kubectl apply -f " ./_out/manifests/release/cdi-operator.yaml"
294298 while [[ $retry_counter -lt $CDI_UPGRADE_RETRY_COUNT ]] && [ " $observed_version " != " latest" ]; do
295- cdi_cr_phase=` _kubectl get CDI -o=jsonpath=' {.items[*].status.phase}{"\n"}' `
296- observed_version=` _kubectl get CDI -o=jsonpath=' {.items[*].status.observedVersion}{"\n"}' `
297- target_version=` _kubectl get CDI -o=jsonpath=' {.items[*].status.targetVersion}{"\n"}' `
298- operator_version=` _kubectl get CDI -o=jsonpath=' {.items[*].status.operatorVersion}{"\n"}' `
299+ cdi_cr_phase=$( _kubectl get CDI -o=jsonpath=' {.items[*].status.phase}{"\n"}' )
300+ observed_version=$( _kubectl get CDI -o=jsonpath=' {.items[*].status.observedVersion}{"\n"}' )
301+ target_version=$( _kubectl get CDI -o=jsonpath=' {.items[*].status.targetVersion}{"\n"}' )
302+ operator_version=$( _kubectl get CDI -o=jsonpath=' {.items[*].status.operatorVersion}{"\n"}' )
299303 echo " Phase: $cdi_cr_phase , observedVersion: $observed_version , operatorVersion: $operator_version , targetVersion: $target_version "
300304 retry_counter=$(( retry_counter + 1 ))
301305 _kubectl get pods -n $CDI_NAMESPACE
302306 sleep 5
303307 done
304308 if [ $retry_counter -eq $CDI_UPGRADE_RETRY_COUNT ]; then
305- echo " Unable to deploy to latest version"
306- cdi_obj=$( _kubectl get CDI -o yaml)
307- echo $cdi_obj
308- exit 1
309+ echo " Unable to deploy to latest version"
310+ cdi_obj=$( _kubectl get CDI -o yaml)
311+ echo $cdi_obj
312+ exit 1
309313 fi
310314 wait_cdi_available
311315 wait_cdi_pods_updated
@@ -323,6 +327,13 @@ if [ "${KUBEVIRT_PROVIDER}" != "external" ]; then
323327 configure_prometheus
324328fi
325329
330+ # Network policies
331+ if [ " ${CDI_DEPLOY_NP} " == true ]; then
332+ _kubectl apply -n ${CDI_NAMESPACE} -f " ./cluster-sync/networkpolicies/cluster-services-np.yaml"
333+ _kubectl apply -n ${CDI_NAMESPACE} -f " ./_out/manifests/release/network-policies.yaml"
334+ fi
335+
336+
326337# Grab all the CDI crds so we can check if they are structural schemas
327338cdi_crds=$( _kubectl get crd -l cdi.kubevirt.io -o jsonpath={.items[* ].metadata.name})
328339crds=($cdi_crds )
0 commit comments