Skip to content

Commit e94ff74

Browse files
committed
CI: Hide errors for expected failures
The CI script should not show errors for expected failures, such as when checking if a resource exists. This commit redirects the standard error to standard output, which is in turn redirected to `/dev/null`.
1 parent fbce63d commit e94ff74

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

hack/ci/gce-project.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function cloud_init {
3939

4040
function init_infrastructure() {
4141
if [[ ${GCP_NETWORK_NAME} != "default" ]]; then
42-
if ! gcloud compute networks describe "$GCP_NETWORK_NAME" --project "$GCP_PROJECT" >/dev/null; then
42+
if ! gcloud compute networks describe "$GCP_NETWORK_NAME" --project "$GCP_PROJECT" >/dev/null 2>&1; then
4343
gcloud compute networks create --project "$GCP_PROJECT" "$GCP_NETWORK_NAME" --subnet-mode custom
4444
gcloud compute networks subnets create "$GCP_NETWORK_NAME" --project "$GCP_PROJECT" \
4545
--network="$GCP_NETWORK_NAME" --range="$PRIVATE_NETWORK_CIDR" --region "$GCP_REGION"
@@ -64,12 +64,12 @@ function init_infrastructure() {
6464
gcloud compute networks list --project="$GCP_PROJECT"
6565
gcloud compute networks describe "$GCP_NETWORK_NAME" --project="$GCP_PROJECT"
6666

67-
if ! gcloud compute routers describe "${CLUSTER_NAME}-myrouter" --project="$GCP_PROJECT" --region="$GCP_REGION" >/dev/null; then
67+
if ! gcloud compute routers describe "${CLUSTER_NAME}-myrouter" --project="$GCP_PROJECT" --region="$GCP_REGION" >/dev/null 2>&1; then
6868
gcloud compute routers create "${CLUSTER_NAME}-myrouter" --project="$GCP_PROJECT" \
6969
--region="$GCP_REGION" --network="$GCP_NETWORK_NAME"
7070
fi
7171
if ! gcloud compute routers nats describe --router="$CLUSTER_NAME-myrouter" "$CLUSTER_NAME-mynat" \
72-
--project="$GCP_PROJECT" --region="${GCP_REGION}" >/dev/null; then
72+
--project="$GCP_PROJECT" --region="${GCP_REGION}" >/dev/null 2>&1; then
7373
gcloud compute routers nats create "${CLUSTER_NAME}-mynat" --project="$GCP_PROJECT" \
7474
--router-region="$GCP_REGION" --router="${CLUSTER_NAME}-myrouter" \
7575
--nat-all-subnet-ip-ranges --auto-allocate-nat-external-ips
@@ -89,7 +89,7 @@ function create_vm {
8989
# Loop over all zones in the GCP region to ignore a full zone.
9090
# We are not able to use 'gcloud compute zones list' as the gcloud.compute.zones.list permission is missing.
9191
for GCP_ZONE in "${GCP_REGION}-a" "${GCP_REGION}-b" "${GCP_REGION}-c"; do
92-
if ! gcloud compute instances describe "$servername" --project "$GCP_PROJECT" --zone "$GCP_ZONE" >/dev/null; then
92+
if ! gcloud compute instances describe "$servername" --project "$GCP_PROJECT" --zone "$GCP_ZONE" >/dev/null 2>&1; then
9393
if gcloud compute instances create "$servername" \
9494
--project "$GCP_PROJECT" \
9595
--zone "$GCP_ZONE" \

0 commit comments

Comments
 (0)