Skip to content

Commit

Permalink
Merge pull request #111 from dprince/related_images
Browse files Browse the repository at this point in the history
Support disconnected network environments
  • Loading branch information
openshift-merge-robot authored Sep 14, 2023
2 parents 1009618 + 499a109 commit 116f307
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
name: tools
namespace: openstack-k8s-operators
tag: ci-build-root-golang-1.19-sdk-1.26
tag: ci-build-root-golang-1.19-sdk-1.31
60 changes: 2 additions & 58 deletions .github/create_bundle.sh
Original file line number Diff line number Diff line change
@@ -1,69 +1,13 @@
#!/bin/bash
set -e

CLUSTER_BUNDLE_FILE="bundle/manifests/infra-operator.clusterserviceversion.yaml"

echo "Creating openstack operator bundle"
echo "Creating infra operator bundle"
cd ..
echo "${GITHUB_SHA}"
echo "${BASE_IMAGE}"
skopeo --version

echo "Calculating image digest for docker://${REGISTRY}/${BASE_IMAGE}:${GITHUB_SHA}"
DIGEST=$(skopeo inspect docker://${REGISTRY}/${BASE_IMAGE}:${GITHUB_SHA} | jq '.Digest' -r)
# Output:
# Calculating image digest for docker://quay.io/openstack-k8s-operators/infra-operator:d03f2c1c362c04fc5ef819f92a218f9ea59bbd0c
# Digest: sha256:1d5b578fd212f8dbd03c0235f1913ef738721766f8c94236af5efecc6d8d8cb1
echo "Digest: ${DIGEST}"

RELEASE_VERSION=$(grep "^VERSION" Makefile | awk -F'?= ' '{ print $2 }')
OPERATOR_IMG_WITH_DIGEST="${REGISTRY}/${BASE_IMAGE}@${DIGEST}"

echo "New Operator Image with Digest: $OPERATOR_IMG_WITH_DIGEST"
echo "Release Version: $RELEASE_VERSION"

echo "Creating bundle image..."
VERSION=$RELEASE_VERSION IMG=$OPERATOR_IMG_WITH_DIGEST make bundle

echo "Bundle file images:"
cat "${CLUSTER_BUNDLE_FILE}" | grep "image:"
# FIXME: display any ENV variables once we have offline support implemented
#grep -A1 IMAGE_URL_DEFAULT "${CLUSTER_BUNDLE_FILE}"

# We do not want to exit here. Some images are in different registries, so
# error will be reported to the console.
set +e
for csv_image in $(cat "${CLUSTER_BUNDLE_FILE}" | grep "image:" | sed -e "s|.*image:||" | sort -u); do
digest_image=""
echo "CSV line: ${csv_image}"

# case where @ is in the csv_image image
if [[ "$csv_image" =~ .*"@".* ]]; then
delimeter='@'
else
delimeter=':'
fi

base_image=$(echo $csv_image | cut -f 1 -d${delimeter})
tag_image=$(echo $csv_image | cut -f 2 -d${delimeter})

if [[ "$base_image:$tag_image" == "controller:latest" ]]; then
echo "$base_image:$tag_image becomes $OPERATOR_IMG_WITH_DIGEST"
sed -e "s|$base_image:$tag_image|$OPERATOR_IMG_WITH_DIGEST|g" -i "${CLUSTER_BUNDLE_FILE}"
else
digest_image=$(skopeo inspect docker://${base_image}${delimeter}${tag_image} | jq '.Digest' -r)
echo "Base image: $base_image"
if [ -n "$digest_image" ]; then
echo "$base_image${delimeter}$tag_image becomes $base_image@$digest_image"
sed -i "s|$base_image$delimeter$tag_image|$base_image@$digest_image|g" "${CLUSTER_BUNDLE_FILE}"
else
echo "$base_image${delimeter}$tag_image not changed"
fi
fi
done

echo "Resulting bundle file images:"
cat "${CLUSTER_BUNDLE_FILE}" | grep "image:"

# FIXME: display any ENV variables once we have offline support implemented
#grep -A1 IMAGE_URL_DEFAULT "${CLUSTER_BUNDLE_FILE}"
USE_IMAGE_DIGESTS=true VERSION=$RELEASE_VERSION IMG=${REGISTRY}/${BASE_IMAGE}:${GITHUB_SHA} make bundle
2 changes: 1 addition & 1 deletion .github/workflows/build-infra-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
uses: redhat-actions/openshift-tools-installer@v1
with:
source: github
operator-sdk: '1.23.0'
operator-sdk: '1.31.0'

- name: Log in to Quay Registry
uses: redhat-actions/podman-login@v1
Expand Down
1 change: 1 addition & 0 deletions .prow_ci.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export USE_IMAGE_DIGESTS=true
2 changes: 1 addition & 1 deletion apis/memcached/v1beta1/memcached_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (instance Memcached) RbacResourceName() string {
func SetupDefaults() {
// Acquire environmental defaults and initialize Memcached defaults with them
memcachedDefaults := MemcachedDefaults{
ContainerImageURL: util.GetEnvVar("INFRA_MEMCACHED_IMAGE_URL_DEFAULT", MemcachedContainerImage),
ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_INFRA_MEMCACHED_IMAGE_URL_DEFAULT", MemcachedContainerImage),
}

SetupMemcachedDefaults(memcachedDefaults)
Expand Down
2 changes: 1 addition & 1 deletion apis/network/v1beta1/dnsmasq_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (s DNSMasqStatus) GetConditions() condition.Conditions {
func SetupDefaults() {
// Acquire environmental defaults and initialize DNSMasq defaults with them
dnsMasqDefaults := DNSMasqDefaults{
ContainerImageURL: util.GetEnvVar("INFRA_DNSMASQ_IMAGE_URL_DEFAULT", DNSMasqContainerImage),
ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_INFRA_DNSMASQ_IMAGE_URL_DEFAULT", DNSMasqContainerImage),
}

SetupDNSMasqDefaults(dnsMasqDefaults)
Expand Down
2 changes: 1 addition & 1 deletion apis/redis/v1beta1/redis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (instance Redis) RbacResourceName() string {
func SetupDefaults() {
// Acquire environmental defaults and initialize Redis defaults with them
redisDefaults := RedisDefaults{
ContainerImageURL: util.GetEnvVar("INFRA_REDIS_IMAGE_URL_DEFAULT", RedisContainerImage),
ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_INFRA_REDIS_IMAGE_URL_DEFAULT", RedisContainerImage),
}

SetupRedisDefaults(redisDefaults)
Expand Down
6 changes: 3 additions & 3 deletions config/default/manager_default_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ spec:
containers:
- name: manager
env:
- name: INFRA_MEMCACHED_IMAGE_URL_DEFAULT
- name: RELATED_IMAGE_INFRA_MEMCACHED_IMAGE_URL_DEFAULT
value: quay.io/podified-antelope-centos9/openstack-memcached:current-podified
- name: INFRA_REDIS_IMAGE_URL_DEFAULT
- name: RELATED_IMAGE_INFRA_REDIS_IMAGE_URL_DEFAULT
value: registry.redhat.io/rhel9/redis-6:latest
# TODO create its own container image, instead of using neutron one
- name: INFRA_DNSMASQ_IMAGE_URL_DEFAULT
- name: RELATED_IMAGE_INFRA_DNSMASQ_IMAGE_URL_DEFAULT
value: quay.io/podified-antelope-centos9/openstack-neutron-server:current-podified
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
annotations:
alm-examples: '[]'
capabilities: Basic Install
operators.openshift.io/infrastructure-features: '["disconnected"]'
operators.operatorframework.io/operator-type: non-standalone
name: infra-operator.v0.0.0
namespace: placeholder
Expand Down
1 change: 0 additions & 1 deletion tests/kuttl/tests/memcached/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ kind: Memcached
metadata:
name: memcached
spec:
containerImage: quay.io/podified-antelope-centos9/openstack-memcached:current-podified
replicas: 1
status:
readyCount: 1
Expand Down

0 comments on commit 116f307

Please sign in to comment.