Skip to content

Faster GCP Auto attach disk logic #128

@shaigbdb

Description

@shaigbdb

shuffling the disks to check for an unattached volume wastes time.
We should try to have the syntax filter only the unattached disks and then wait for one to appear (looks like we're already doing this for AWS:

UNATTACHED_VOLUME_ID="$(aws ec2 describe-volumes --region $aws_region --filters Name=tag:ClusterName,Values=$es_cluster Name=tag:AutoAttachGroup,Values=$INSTANCE_ROLE Name=availability-zone,Values=$AV_ZONE | jq -r '.Volumes[] | select(.Attachments | length == 0) | .VolumeId' | shuf -n 1)"
)

If we can't filter, then we should iterate on the list of disks, and then get the list again in case a new disk has appeared.
https://github.com/BigDataBoutique/elasticsearch-cloud-deploy/blob/master/assets/scripts/aws/autoattach-disk.sh

UNATTACHED_VOLUME_ID="$(gcloud compute disks list --filter="zone=$GCP_ZONE AND labels.cluster-name=$es_cluster AND labels.auto-attach-group=$INSTANCE_ROLE" --format json | jq -r '.[] | .name' | shuf -n 1)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions