Skip to content

Commit

Permalink
Merge pull request #350 from UffizziCloud/feature/#339_sleeping_mode
Browse files Browse the repository at this point in the history
[339] added cluster sleep/wake commands
  • Loading branch information
moklidia authored Oct 19, 2023
2 parents d5af6cd + 633133a commit 0efcdf6
Show file tree
Hide file tree
Showing 12 changed files with 298 additions and 10 deletions.
72 changes: 65 additions & 7 deletions lib/uffizzi/cli/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def list
run('list')
end

desc 'create [NAME]', 'Create a cluster'
desc 'create [CLUSTER_NAME]', 'Create a cluster'
method_option :name, type: :string, required: false, aliases: '-n'
method_option :kubeconfig, type: :string, required: false, aliases: '-k'
method_option :manifest, type: :string, required: false, aliases: '-m'
Expand All @@ -34,13 +34,13 @@ def create(name = nil)
run('create', { name: name })
end

desc 'describe [NAME]', 'Describe a cluster'
desc 'describe [CLUSTER_NAME]', 'Describe a cluster'
method_option :output, required: false, type: :string, aliases: '-o', enum: ['json', 'pretty-json']
def describe(name)
run('describe', cluster_name: name)
end

desc 'delete [NAME]', 'Delete a cluster'
desc 'delete [CLUSTER_NAME]', 'Delete a cluster'
method_option :'delete-config', required: false, type: :boolean, default: true
def delete(name)
run('delete', cluster_name: name)
Expand All @@ -61,6 +61,16 @@ def disconnect
run('disconnect')
end

desc 'sleep [CLUSTER_NAME]', 'Scales a Uffizzi cluster down to zero resource utilization'
def sleep(name = nil)
run('sleep', cluster_name: name)
end

desc 'wake [CLUSTER_NAME]', 'Scales up a Uffizzi cluster to its original resource'
def wake(name = nil)
run('wake', cluster_name: name)
end

private

def run(command, command_args = {})
Expand All @@ -81,6 +91,10 @@ def run(command, command_args = {})
handle_update_kubeconfig_command(project_slug, command_args)
when 'disconnect'
ClusterDisconnectService.handle(options)
when 'sleep'
handle_sleep_command(project_slug, command_args)
when 'wake'
handle_wake_command(project_slug, command_args)
end
end

Expand Down Expand Up @@ -131,7 +145,7 @@ def handle_create_command(project_slug, command_args)

if ClusterService.failed?(cluster_data[:state])
spinner.error
Uffizzi.ui.say_error_and_exit("Cluster with name: #{cluster_name} failed to be created.")
Uffizzi.ui.say_error_and_exit("Cluster #{cluster_name} failed to be created.")
end

spinner.success
Expand Down Expand Up @@ -196,7 +210,8 @@ def handle_delete_cluster(project_slug, cluster_name)

def handle_update_kubeconfig_command(project_slug, command_args)
kubeconfig_path = options[:kubeconfig] || KubeconfigService.default_path
cluster_data = fetch_cluster_data(project_slug, command_args[:cluster_name])
cluster_name = command_args[:cluster_name]
cluster_data = fetch_cluster_data(project_slug, cluster_name)

unless cluster_data[:kubeconfig].present?
say_error_update_kubeconfig(cluster_data)
Expand All @@ -218,13 +233,48 @@ def handle_update_kubeconfig_command(project_slug, command_args)
new_kubeconfig
end

update_clusters_config(cluster_data[:id], kubeconfig_path: kubeconfig_path)
update_clusters_config(cluster_data[:id], name: cluster_name, kubeconfig_path: kubeconfig_path)

return if options[:quiet]

Uffizzi.ui.say("Kubeconfig was updated by the path: #{kubeconfig_path}")
end

def handle_sleep_command(project_slug, command_args)
cluster_name = command_args[:cluster_name] || ConfigFile.read_option(:current_cluster)&.fetch(:name)
return handle_missing_cluster_name_error if cluster_name.nil?

response = scale_down_cluster(ConfigFile.read_option(:server), project_slug, cluster_name)
return ResponseHelper.handle_failed_response(response) unless ResponseHelper.ok?(response)

spinner = TTY::Spinner.new("[:spinner] Scaling down cluster #{cluster_name}...", format: :dots)
spinner.auto_spin
ClusterService.wait_cluster_scale_down(project_slug, cluster_name)

spinner.success
Uffizzi.ui.say("Cluster #{cluster_name} was successfully scaled down")
end

def handle_wake_command(project_slug, command_args)
cluster_name = command_args[:cluster_name] || ConfigFile.read_option(:current_cluster)&.fetch(:name)
return handle_missing_cluster_name_error if cluster_name.nil?

response = scale_up_cluster(ConfigFile.read_option(:server), project_slug, cluster_name)
return ResponseHelper.handle_failed_response(response) unless ResponseHelper.ok?(response)

spinner = TTY::Spinner.new("[:spinner] Waking up cluster #{cluster_name}...", format: :dots)
spinner.auto_spin
cluster_data = ClusterService.wait_cluster_scale_up(project_slug, cluster_name)

if ClusterService.failed_scaling_up?(cluster_data[:state])
spinner.error
Uffizzi.ui.say_error_and_exit("Failed to wake up cluster #{cluster_name}.")
end

spinner.success
Uffizzi.ui.say("Cluster #{cluster_name} was successfully scaled up")
end

def say_error_update_kubeconfig(cluster_data)
if ClusterService.failed?(cluster_data[:state])
Uffizzi.ui.say_error_and_exit('Kubeconfig is empty because cluster failed to be created.')
Expand Down Expand Up @@ -321,6 +371,7 @@ def handle_succeed_create_response(cluster_data)
is_update_current_context = options[:'update-current-context']
parsed_kubeconfig = parse_kubeconfig(cluster_data[:kubeconfig])
rendered_cluster_data = render_cluster_data(cluster_data)
cluster_name = cluster_data[:name]

Uffizzi.ui.enable_stdout
Uffizzi.ui.say("Cluster with name: #{rendered_cluster_data[:name]} was created.")
Expand All @@ -332,7 +383,7 @@ def handle_succeed_create_response(cluster_data)
Uffizzi.ui.say(rendered_cluster_data) if Uffizzi.ui.output_format

save_kubeconfig(parsed_kubeconfig, kubeconfig_path)
update_clusters_config(cluster_data[:id], kubeconfig_path: kubeconfig_path)
update_clusters_config(cluster_data[:id], name: cluster_name, kubeconfig_path: kubeconfig_path)
GithubService.write_to_github_env(rendered_cluster_data) if GithubService.github_actions_exists?
end

Expand Down Expand Up @@ -362,6 +413,7 @@ def save_kubeconfig(kubeconfig, kubeconfig_path)
def update_clusters_config(id, params)
clusters_config = Uffizzi::ConfigHelper.update_clusters_config_by_id(id, params)
ConfigFile.write_option(:clusters, clusters_config)
ConfigFile.write_option(:current_cluster, ConfigHelper.cluster_config_by_id(id))
end

def render_cluster_data(cluster_data)
Expand Down Expand Up @@ -400,5 +452,11 @@ def save_previous_current_context(kubeconfig_path, current_context)
previous_current_contexts = Uffizzi::ConfigHelper.set_previous_current_context_by_path(kubeconfig_path, current_context)
ConfigFile.write_option(:previous_current_contexts, previous_current_contexts)
end

def handle_missing_cluster_name_error
Uffizzi.ui.say("No kubeconfig found at #{KubeconfigService.default_path}")
Uffizzi.ui.say('Please update the current context or provide a cluster name.')
Uffizzi.ui.say('$uffizzi cluster sleep my-cluster')
end
end
end
5 changes: 3 additions & 2 deletions lib/uffizzi/cli/dev.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ def wait_cluster_creation(cluster_name)
def handle_succeed_cluster_creation(cluster_data)
kubeconfig_path = options[:kubeconfig] || KubeconfigService.default_path
parsed_kubeconfig = parse_kubeconfig(cluster_data[:kubeconfig])
cluster_name = cluster_data[:name]

Uffizzi.ui.say("Cluster with name: #{cluster_data[:name]} was created.")
Uffizzi.ui.say("Cluster with name: #{cluster_name} was created.")

save_kubeconfig(parsed_kubeconfig, kubeconfig_path)
update_clusters_config(cluster_data[:id], kubeconfig_path: kubeconfig_path)
update_clusters_config(cluster_data[:id], name: cluster_name, kubeconfig_path: kubeconfig_path)
end

def save_kubeconfig(kubeconfig, kubeconfig_path)
Expand Down
14 changes: 14 additions & 0 deletions lib/uffizzi/clients/api/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,20 @@ def create_cluster(server, project_slug, params)
build_response(response)
end

def scale_down_cluster(server, project_slug, cluster_name)
uri = scale_down_cluster_uri(server, project_slug, cluster_name)
response = http_client.make_put_request(uri)

build_response(response)
end

def scale_up_cluster(server, project_slug, cluster_name)
uri = scale_up_cluster_uri(server, project_slug, cluster_name)
response = http_client.make_put_request(uri)

build_response(response)
end

def create_access_token(server, session_id)
uri = access_tokens_url(server)

Expand Down
8 changes: 8 additions & 0 deletions lib/uffizzi/clients/api/api_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ def cluster_uri(server, project_slug, cluster_name:, oidc_token:)
"#{server}/api/cli/v1/projects/#{project_slug}/clusters/#{cluster_name}?token=#{oidc_token}"
end

def scale_up_cluster_uri(server, project_slug, cluster_name)
"#{server}/api/cli/v1/projects/#{project_slug}/clusters/#{cluster_name}/scale_up"
end

def scale_down_cluster_uri(server, project_slug, cluster_name)
"#{server}/api/cli/v1/projects/#{project_slug}/clusters/#{cluster_name}/scale_down"
end

def access_token_url(server, code)
"#{server}/api/cli/v1/access_tokens/#{code}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/uffizzi/helpers/config_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Uffizzi
module ConfigHelper
CLUSTER_PARAMS = [:kubeconfig_path].freeze
CLUSTER_PARAMS = [:kubeconfig_path, :name].freeze

class ConfigParamsError < StandardError
def initialize(unavailable_params, key)
Expand Down
47 changes: 47 additions & 0 deletions lib/uffizzi/services/cluster_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ClusterService
CLUSTER_STATE_DEPLOYING_NAMESPACE = 'deploying_namespace'
CLUSTER_STATE_DEPLOYING = 'deploying'
CLUSTER_STATE_DEPLOYED = 'deployed'
CLUSTER_STATE_SCALING_DOWN = 'scaling_down'
CLUSTER_STATE_SCALING_UP = 'scaling_up'
CLUSTER_FAILED_SCALING_UP = 'failed_scaling_up'
CLUSTER_STATE_FAILED_DEPLOY_NAMESPACE = 'failed_deploy_namespace'
CLUSTER_STATE_FAILED = 'failed'
CLUSTER_NAME_MAX_LENGTH = 15
Expand All @@ -26,6 +29,18 @@ def failed?(cluster_state)
[CLUSTER_STATE_FAILED_DEPLOY_NAMESPACE, CLUSTER_STATE_FAILED].include?(cluster_state)
end

def scaling_up?(cluster_state)
cluster_state === CLUSTER_STATE_SCALING_UP
end

def scaling_down?(cluster_state)
cluster_state === CLUSTER_STATE_SCALING_DOWN
end

def failed_scaling_up?(cluster_state)
cluster_state === CLUSTER_FAILED_SCALING_UP
end

def wait_cluster_deploy(project_slug, cluster_name, oidc_token)
loop do
params = {
Expand All @@ -43,6 +58,38 @@ def wait_cluster_deploy(project_slug, cluster_name, oidc_token)
end
end

def wait_cluster_scale_up(project_slug, cluster_name)
loop do
params = {
cluster_name: cluster_name,
}
response = get_cluster(Uffizzi::ConfigFile.read_option(:server), project_slug, params)
return Uffizzi::ResponseHelper.handle_failed_response(response) unless Uffizzi::ResponseHelper.ok?(response)

cluster_data = response.dig(:body, :cluster)

return cluster_data unless scaling_up?(cluster_data[:state])

sleep(5)
end
end

def wait_cluster_scale_down(project_slug, cluster_name)
loop do
params = {
cluster_name: cluster_name,
}
response = get_cluster(Uffizzi::ConfigFile.read_option(:server), project_slug, params)
return Uffizzi::ResponseHelper.handle_failed_response(response) unless Uffizzi::ResponseHelper.ok?(response)

cluster_data = response.dig(:body, :cluster)

return unless scaling_down?(cluster_data[:state])

sleep(3)
end
end

def generate_name
name = Faker::Internet.domain_word[0..CLUSTER_NAME_MAX_LENGTH]

Expand Down
30 changes: 30 additions & 0 deletions man/uffizzi-cluster-sleep.ronn
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$ uffizzi cluster sleep -h
uffizzi-cluster-sleep - put a cluster to sleep (non-destructive)
================================================================

## SYNOPSIS
uffizzi cluster sleep [CLUSTER_NAME]

## DESCRIPTION
Scales a Uffizzi cluster down to zero resource utilization
while keeping the namespace and any stateful resources,
like persistent volume claims. If no CLUSTER_NAME is
specified, the kubeconfig current context is used.

For more information on Uffizzi clusters, see:
https://docs.uffizzi.com/references/cli/

## OPTIONS
CLUSTER_NAME
The name of the target Uffizzi cluster

## EXAMPLES
To put the Uffizzi cluster in the current context to
sleep, run:

$ uffizzi cluster sleep

To put a Uffizzi cluster outside the current context to
sleep, run:

$ uffizzi cluster sleep my-cluster
28 changes: 28 additions & 0 deletions man/uffizzi-cluster-wake.ronn
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
$ uffizzi cluster wake -h
uffizzi-cluster-wake - wake a cluster that is sleeping
================================================================

## SYNOPSIS
uffizzi cluster wake [CLUSTER_NAME]

## DESCRIPTION
Scales up a Uffizzi cluster to its original resource
utilization from zero (see 'uffizzi cluster sleep -h').
If no CLUSTER_NAME is specified, the kubeconfig current
context is used.

For more information on Uffizzi clusters, see:
https://docs.uffizzi.com/references/cli/

## OPTIONS
CLUSTER_NAME
The name of the target Uffizzi cluster

## EXAMPLES
To wake the Uffizzi cluster in the current context, run:

$ uffizzi cluster wake

To wake a Uffizzi cluster outside the current context, run:

$ uffizzi cluster wake my-cluster
6 changes: 6 additions & 0 deletions man/uffizzi-cluster.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ uffizzi-cluster - manage clusters
list
List all clusters

sleep
Put a cluster to sleep (non-destructive)

wake
Wake a cluster that is sleeping

update-kubeconfig
Update kubeconfig file

Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/files/uffizzi/uffizzi_cluster_scaled_down.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"cluster": {
"id": 1,
"name": "uffizzi-test-cluster-vcluster",
"state": "scaled_down",
"created_at": "2023-07-15T15:33:41.590Z",
"host": "some-host.cluster.com",
"kubeconfig": "YXBpVmVyc2lvbjogdjEKY2x1c3RlcnM6Ci0gY2x1c3RlcjoKICAgIGNlcnRpZmljYXRlLWF1dGhvcml0eS1kYXRhOiBMUzB0TFMxQ1JVZEpUaUJEUlZKVVNVWkpRMEZVUlMwdExTMHRDazFKU1VKa2VrTkRRVkl5WjBGM1NVSkJaMGxDUVVSQlMwSm5aM0ZvYTJwUFVGRlJSRUZxUVdwTlUwVjNTSGRaUkZaUlVVUkVRbWh5VFROTmRHTXlWbmtLWkcxV2VVeFhUbWhSUkVVeVQwUlpORTVFUlhkTlJFRjNTR2hqVGsxcVRYZE9ha1V4VFZSUk1VNXFVWGRYYUdOT1RYcE5kMDVxUlhsTlZGRXhUbXBSZHdwWGFrRnFUVk5GZDBoM1dVUldVVkZFUkVKb2NrMHpUWFJqTWxaNVpHMVdlVXhYVG1oUlJFVXlUMFJaTkU1RVJYZE5SRUYzVjFSQlZFSm5ZM0ZvYTJwUENsQlJTVUpDWjJkeGFHdHFUMUJSVFVKQ2QwNURRVUZTZEhac2FqUjJlakl4T0VSMWVFdFNkVlp6Y0VFNVZ6Wk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yVldSa2NYcGhPQ3M0WkRsSVpERTVVemR2UVc5SFEwTnhSMU5OTkRrS1FYZEZTRzlWVVVSUlowRkZUM2RyWmxscFZHMVpaakE1VGtZMmRXdzNUazFZU2xKcVVtUTBSakpRTlZseWVWcFVWM2xqYkhOMVZtbEhZemhWYldWb01BcG9MMGxQZDNCV1Uyb3lUMVprUjFwdGNVOW9ielF2UlhFdlowWnNOSFk0U0cxUlBUMEtMUzB0TFMxRlRrUWdSVU1nVUZKSlZrRlVSU0JMUlZrdExTMHRMUW89Cg=="
}
}
12 changes: 12 additions & 0 deletions test/support/uffizzi_stub_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ def stub_uffizzi_delete_cluster(project_slug)
stub_request(:delete, uri).to_return(status: 204)
end

def stub_uffizzi_scale_down_cluster(body, project_slug, cluster_name:)
uri = scale_down_cluster_uri(Uffizzi.configuration.server, project_slug, cluster_name)

stub_request(:put, uri).to_return(status: 200, body: body.to_json)
end

def stub_uffizzi_scale_up_cluster(body, project_slug, cluster_name:)
uri = scale_up_cluster_uri(Uffizzi.configuration.server, project_slug, cluster_name)

stub_request(:put, uri).to_return(status: 200, body: body.to_json)
end

def stub_get_token_request(body)
uri = %r{#{Uffizzi.configuration.server}/api/cli/v1/access_tokens/([A-Za-z0-9\-_]+)}

Expand Down
Loading

0 comments on commit 0efcdf6

Please sign in to comment.