Esempio n. 1
0
def pause_autoscaler(context):
    dynamodb.put_item(TableName=CLUSTERMAN_STATE_TABLE,
                      Item={
                          'state': {
                              'S': AUTOSCALER_PAUSED
                          },
                          'entity': {
                              'S': 'mesos-test.bar.mesos'
                          },
                          'expiration_timestamp': {
                              'N': str(time.time() + 100000)
                          }
                      })
Esempio n. 2
0
def disable(args: argparse.Namespace) -> None:
    state = {
        'state': {
            'S': AUTOSCALER_PAUSED
        },
        'entity': {
            'S': f'{args.cluster}.{args.pool}.{args.scheduler}'
        },
    }
    if args.until:
        state['expiration_timestamp'] = {
            'N': str(parse_time_string(args.until).timestamp)
        }

    dynamodb.put_item(
        TableName=staticconf.read('aws.state_table',
                                  default=CLUSTERMAN_STATE_TABLE),
        Item=state,
    )
Esempio n. 3
0
def disable(args: argparse.Namespace) -> None:
    ensure_account_id(args.cluster)

    state = {
        'state': {
            'S': AUTOSCALER_PAUSED
        },
        'entity': {
            'S': f'{args.cluster}.{args.pool}.{args.scheduler}'
        },
        'timestamp': {
            'N': str(int(time.time()))
        },
    }

    if args.until:
        state['expiration_timestamp'] = {
            'N': str(parse_time_string(args.until).timestamp)
        }

    dynamodb.put_item(
        TableName=staticconf.read('aws.state_table',
                                  default=CLUSTERMAN_STATE_TABLE),
        Item=state,
    )

    time.sleep(1)  # Give DynamoDB some time to settle

    now = parse_time_string('now').to('local')

    if not autoscaling_is_paused(args.cluster, args.pool, args.scheduler, now):
        print('Something went wrong!  The autoscaler is NOT paused')
    else:
        s = f'The autoscaler for {args.cluster}.{args.pool}.{args.scheduler} was paused at {now}'

        if args.until:
            until_str = str(parse_time_string(args.until).to('local'))
            s += f' until {until_str}'

        print(s)