LoginSignup
0
0

More than 3 years have passed since last update.

gcloudコマンド実行時のWARNINGを非表示にする

Last updated at Posted at 2020-12-22

はじめに

最近になってGCPを触り始めたインフラエンジニアです。
gcloudコマンド実行時に、WARNING表示される時があるのですが、必要なさそうな時はを非表示にしたいと思い試してみました。

どのようなときにでるか

たとえばVMインスタンス作成時に以下のようなWARNINGメッセージが表示されます。

gcloud
$ gcloud compute instances create test001 \
> --image=centos-7-v20201216 --boot-disk-size=30GB --image-project=centos-cloud \
> --machine-type=f1-micro \
> --shielded-secure-boot \
> --address="xxx.xxx.xxx.xxx" \
> --zone=us-west1-a
WARNING: You have selected a disk size of under [200GB]. This may result in poor I/O performance. For more information, see: https://developers.google.com/compute/docs/disks#performance.
Created [https://www.googleapis.com/compute/v1/projects/xxxxxxx-xxxxx-xxxxxx/zones/us-west1-a/instances/test001].
WARNING: Some requests generated warnings:
 - Disk size: '30 GB' is larger than image size: '20 GB'. You might need to resize the root repartition manually if the operating system does not support automatic resizing. See https://cloud.google.com/compute/docs/disks/add-persistent-disk#resize_pd for details.

NAME     ZONE        MACHINE_TYPE  PREEMPTIBLE  INTERNAL_IP      EXTERNAL_IP      STATUS
test001  us-west1-a  f1-micro                   10.xxx.xxx.xxx   xxx.xxx.xxx.xxx  RUNNING

今回の場合は内容的にWARNINGメッセージなくても良さそう。

WARNING非表示を調べる

たぶんコンフィグの設定あたりで、できるだろうと思いヘルプを見たり

gcloud
$ gcloud help config

公式ドキュメント見たり
gcloud config set

公式ドキュメントに以下のように記載があります。

verbosity

Default logging verbosity for gcloud commands. This is the equivalent of using the global --verbosity flag. Supported verbosity levels: debug, info, warning, error, critical, and none.

デフォルトはwarningのようなので、errorに変更します。

WARNING非表示の方法

以下のコマンドで変更します。

gcloud
$ gcloud config set core/verbosity error

コンフィグにverbosity = error追加されていることを確認します。

gcloud
$ gcloud config list
[compute]
region = asia-northeast1
zone = asia-northeast1-a
[core]
account = *****
disable_usage_reporting = False
project = xxxxxxx-xxxxx-xxxxxx
verbosity = error

Your active configuration is: [default]

確認

再度VMインスタンス作成して、WARNINGが表示されないことを確認してみます。

gcloud
gcloud compute instances create test002 \
> --image=centos-7-v20201216 --boot-disk-size=30GB --image-project=centos-cloud \
> --machine-type=f1-micro \
> --shielded-secure-boot \
> --address="xxx.xxx.xxx.xxx" \
> --zone=us-west1-a
Created [https://www.googleapis.com/compute/v1/projects/xxxxxxx-xxxxx-xxxxxx/zones/us-west1-a/instances/test002].
NAME     ZONE        MACHINE_TYPE  PREEMPTIBLE  INTERNAL_IP       EXTERNAL_IP      STATUS
test002  us-west1-a  f1-micro                   10.xxx.xxxx.xxx   xxx.xxx.xxx.xxx  RUNNING

OK!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0