Skip to content

Commit

Permalink
Merge pull request #843 from ciecierski/update-target
Browse files Browse the repository at this point in the history
Add openstack_update_run target
  • Loading branch information
openshift-merge-bot[bot] authored Jul 4, 2024
2 parents 8457415 + 1a1489c commit e05abca
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,12 @@ openstack_deploy_cleanup: namespace netconfig_deploy_cleanup ## cleans up the se
oc kustomize ${DEPLOY_DIR} | oc delete --ignore-not-found=true -f - || true
${CLEANUP_DIR_CMD} ${OPERATOR_BASE_DIR}/openstack-operator ${DEPLOY_DIR}

.PHONY: openstack_update_run
openstack_update_run:
$(eval $(call vars,$@,openstack))
bash scripts/openstack-update.sh


.PHONY: edpm_deploy_generate_keys
edpm_deploy_generate_keys:
$(eval $(call vars,$@,dataplane))
Expand Down
109 changes: 109 additions & 0 deletions scripts/openstack-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/bin/bash
#
# Copyright 2024 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

set -ex
CONTAINERS_NAMESPACE=${CONTAINERS_NAMESPACE:-podified-antelope-centos9}
CONTAINERS_TARGET_TAG=${CONTAINERS_TARGET_TAG:-current-podified}
FAKE_UPDATE=${FAKE_UPDATE:-false}
OPENSTACK_VERSION=${OPENSTACK_VERSION:-0.0.2}
OUTFILE=${OUTFILE:-csv.yaml}
TIMEOUT=${TIMEOUT:-300s}

if [ -z "$OPERATOR_NAMESPACE" ]; then
echo "Please set OPERATOR_NAMESPACE"; exit 1
fi
if [ -z "$NAMESPACE" ]; then
echo "Please set NAMESPACE"; exit 1
fi

OPENSTACK_OPERATOR_CSV=$(oc get csv -n $OPERATOR_NAMESPACE -o name | grep openstack-operator)
OPENSTACK_VERSION_CR=$(oc get openstackversion -n $NAMESPACE -o name)

if [ ${FAKE_UPDATE} = "true" ]; then
oc get $OPENSTACK_OPERATOR_CSV -o yaml -n $OPERATOR_NAMESPACE > $OUTFILE
sed -i $OUTFILE -e "s|value: .*/$CONTAINERS_NAMESPACE/\(.*\)@.*|value: quay.io/$CONTAINERS_NAMESPACE/\1:$CONTAINERS_TARGET_TAG|g"
OPENSTACK_DEPLOYED_VERSION=$(oc get -n $NAMESPACE $OPENSTACK_VERSION_CR --template={{.spec.targetVersion}})
sed -i $OUTFILE -e "s|value: $OPENSTACK_DEPLOYED_VERSION|value: $OPENSTACK_VERSION|"

oc apply -f $OUTFILE
fi

oc project $NAMESPACE
# wait until openstackVersion cr completes reconcile, status.availableVersion should be the same as VERSION
oc wait $OPENSTACK_VERSION_CR --for=jsonpath='{.status.availableVersion}'=$OPENSTACK_VERSION --timeout=$TIMEOUT


OPENSTACK_DEPLOYED_VERSION=$(oc get $OPENSTACK_VERSION_CR --template={{.spec.targetVersion}})

cat <<EOF >openstackversionpatch.yaml
"spec": {
"targetVersion": "$OPENSTACK_VERSION"
}
EOF

oc patch $OPENSTACK_VERSION_CR --type=merge --patch-file openstackversionpatch.yaml

# wait for ovn update on control plane
oc wait $OPENSTACK_VERSION_CR --for=condition=MinorUpdateOVNControlplane --timeout=$TIMEOUT

# start ovn update on data plane
DATAPLANE_NODESET=$(oc get openstackdataplanenodeset -o name | awk -F'/' '{print $2}')
DATAPLANE_DEPLOYMENT=$(oc get openstackdataplanedeployment -o name | awk -F'/' '{print $2}')

cat <<EOF >edpm-deployment-ovn-update.yaml
apiVersion: dataplane.openstack.org/v1beta1
kind: OpenStackDataPlaneDeployment
metadata:
name: $DATAPLANE_DEPLOYMENT-ovn-update
spec:
nodeSets:
- $DATAPLANE_NODESET
servicesOverride:
- ovn
EOF

oc create -f edpm-deployment-ovn-update.yaml

oc get openstackdataplanedeployment
# wait for ovn dataplane completes
oc wait $OPENSTACK_VERSION_CR --for=condition=MinorUpdateOVNDataplane --timeout=$TIMEOUT
echo "MinorUpdateOVNDataplane completed"

# wait for control plane update to complete
oc wait $OPENSTACK_VERSION_CR --for=condition=MinorUpdateControlplane --timeout=$TIMEOUT
echo "MinorUpdateControlplane completed"

# start data plane plane update for rest of edpm services
cat <<EOF >edpm-deployment-update.yaml
apiVersion: dataplane.openstack.org/v1beta1
kind: OpenStackDataPlaneDeployment
metadata:
name: $DATAPLANE_DEPLOYMENT-update
spec:
nodeSets:
- $DATAPLANE_NODESET
servicesOverride:
- update
EOF

oc create -f edpm-deployment-update.yaml

# wait for completion of minor update
oc wait $OPENSTACK_VERSION_CR --for=condition=MinorUpdateDataplane --timeout=$TIMEOUT
echo "MinorUpdate completed"

# check for the status of edpm update
oc get openstackdataplanedeployment ${DATAPLANE_DEPLOYMENT}-update -o yaml

0 comments on commit e05abca

Please sign in to comment.