Model allocations #7114

Merged
merged 1 commit into from Mar 21, 2017

Conversation

Projects
None yet
5 participants
Member

tasdomas commented Mar 16, 2017

Description of change

This changes the behavior of juju commands that manage budgets and allocations.
The juju update-allocation command is removed. The juju allocate command now allows to change allocations associated with models, not applications. The juju show-budget command also no longer provides per-application break-down of usage.

This change is needed to implement the changed approach to managing budgets in juju models.

QA steps

After creating a juju model, run juju sla standard --budget 500. Then run juju allocate 1000.
The output of juju show-budget should reflect that the allocation of the current model is 1000.

Documentation changes

This change will need to be documented along with juju sla support.

Bug reference

None.

LGTM modulo a few conceptual questions..

cmd/juju/model/destroy.go
+ return budget.NewClient(bakeryClient)
+}
+
+type BudgetAPIClient interface {
@alesstimec

alesstimec Mar 20, 2017

Member

godoc, please

return &cmd.Info{
Name: "allocate",
- Args: "<budget>:<value> <application> [<application2> ...]",
- Purpose: "Allocate budget to applications.",
+ Args: "<value>",
@alesstimec

alesstimec Mar 20, 2017

Member

do we not allow changing the budget as well? Moving an allocation from one budget to another? we used to have : as an argument...

@tasdomas

tasdomas Mar 20, 2017

Member

Not for now.

- s.mockAPI.resp = "allocation updated"
- ctx, err := s.run(c, "name:100", "db")
+func (s *updateAllocationSuite) TestUpdateAllocation(c *gc.C) {
+ s.mockAPI.resp = "budget set to 5"
@alesstimec

alesstimec Mar 20, 2017

Member

allocation set to 5?

cmars approved these changes Mar 20, 2017

LGTM!

- c.Services = args[1:]
- return nil
+func (c *updateAllocationCommand) modelUUID() (string, error) {
@wallyworld

wallyworld Mar 21, 2017

Owner

this would be nice as a method on ModelCommandBase
i wonder if there's a helper there already?

@tasdomas

tasdomas Mar 21, 2017

Member

Could not find one.

@@ -136,31 +135,14 @@ func formatTabular(writer io.Writer, value interface{}) error {
table.RightAlign(col)
}
- table.AddRow("MODEL", "SERVICES", "SPENT", "ALLOCATED", "BY", "USAGE")
+ table.AddRow("MODEL", "SPENT", "ALLOCATED", "BY", "USAGE")
@wallyworld

wallyworld Mar 21, 2017

Owner

Current standard is to use Title case for table headers

Member

tasdomas commented Mar 21, 2017

$$merge$$

Contributor

jujubot commented Mar 21, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Mar 21, 2017

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/10509

Owner

cmars commented Mar 21, 2017

@tasdomas Test failures are legit:

---------------------------------------------------------------------
FAIL: main_test.go:551: MainSuite.TestHelpCommands

command output: "actions                    List actions defined for an application.\nadd-cloud                  Adds a user-defined cloud to Juju from among known cloud types.\nadd-credential             Adds or replaces credentials for a cloud.\nadd-machine                Start a new, empty machine and optionally a container, or add a container to a machine.\nadd-model                  Adds a hosted model.\nadd-relation               Add a relation between two application endpoints.\nadd-space                  Add a new network space\nadd-ssh-key                Adds a public SSH key to a model.\nadd-storage                Adds unit storage dynamically.\nadd-subnet                 Add an existing subnet to Juju.\nadd-unit                   Adds one or more units to a deployed application.\nadd-user                   Adds a Juju user to a controller.\nagree                      Agree to terms.\nagreements                 List user's agreements.\nallocate                   Update an allocation.\nattach-storage             Attaches existing storage to a unit.\nautoload-credentials       Attempts to automatically add or replace credentials for a cloud.\nbackups                    Displays information about all backups.\nbootstrap                  Initializes a cloud environment.\nbudgets                    List budgets.\ncached-images              Shows cached os images.\nchange-user-password       Changes the password for the current or specified Juju user\ncharm                      Interact with charms.\nclouds                     Lists all clouds available to Juju.\ncollect-metrics            Collect metrics on the given unit/application.\nconfig                     Gets, sets, or resets configuration for a deployed application.\ncontroller-config          Displays configuration settings for a controller.\ncontrollers                Lists all controllers.\ncreate-backup              Create a backup.\ncreate-budget              Create a new budget.\ncreate-storage-pool        Create or define a storage pool.\ncredentials                Lists credentials for a cloud.\ndebug-hooks                Launch a tmux session to debug a hook.\ndebug-log                  Displays log messages for a model.\ndeploy                     Deploy a new application or bundle.\ndestroy-controller         Destroys a controller.\ndestroy-model              Terminate all machines and resources for a non-controller model.\ndetach-storage             Detaches storage from units.\ndisable-command            Disable commands for the model.\ndisable-user               Disables a Juju user.\ndisabled-commands          List disabled commands.\ndownload-backup            Get an archive file.\nenable-command             Enable commands that had been previously disabled.\nenable-destroy-controller  Enable destroy-controller by removing disabled commands in the controller.\nenable-ha                  Ensure that sufficient controllers exist to provide redundancy.\nenable-user                Re-enables a previously disabled Juju user.\nexpose                     Makes an application publicly available over the network.\nget-constraints            Displays machine constraints for an application.\nget-model-constraints      Displays machine constraints for a model.\ngrant                      Grants access level to a Juju user for a model or controller.\ngui                        Print the Juju GUI URL, or open the Juju GUI in the default browser.\nhelp                       show help on a command or other topic\nhelp-tool                  Show help on a Juju charm tool.\nimport-ssh-key             Adds a public SSH key from a trusted identity source to a model.\nkill-controller            Forcibly terminate all machines and other associated resources for a Juju controller.\nlist-actions               Alias for 'actions'.\nlist-agreements            Alias for 'agreements'.\nlist-backups               Alias for 'backups'.\nlist-budgets               Alias for 'budgets'.\nlist-cached-images         Alias for 'cached-images'.\nlist-clouds                Alias for 'clouds'.\nlist-controllers           Alias for 'controllers'.\nlist-credentials           Alias for 'credentials'.\nlist-disabled-commands     Alias for 'disabled-commands'.\nlist-machines              Alias for 'machines'.\nlist-models                Alias for 'models'.\nlist-plans                 Alias for 'plans'.\nlist-regions               Alias for 'regions'.\nlist-spaces                Alias for 'spaces'.\nlist-ssh-keys              Alias for 'ssh-keys'.\nlist-storage               Alias for 'storage'.\nlist-storage-pools         Alias for 'storage-pools'.\nlist-subnets               Alias for 'subnets'.\nlist-users                 Alias for 'users'.\nlogin                      Logs a user in to a controller.\nlogout                     Logs a Juju user out of a controller.\nmachines                   Lists machines in a model.\nmetrics                    Retrieve metrics collected by specified entities.\nmigrate                    Migrate a hosted model to another controller.\nmodel-config               Displays or sets configuration values on a model.\nmodel-defaults             Displays or sets default configuration settings for a model.\nmodels                     Lists models a user can access on a controller.\nplans                      List plans.\nregions                    Lists regions for a given cloud.\nregister                   Registers a controller.\nrelate                     Alias for 'add-relation'.\nremove-application         Remove an application from the model.\nremove-backup              Remove the spcified backup from remote storage.\nremove-cached-images       Remove cached OS images.\nremove-cloud               Removes a user-defined cloud from Juju.\nremove-credential          Removes credentials for a cloud.\nremove-machine             Removes one or more machines from a model.\nremove-relation            Removes an existing relation between two applications.\nremove-ssh-key             Removes a public SSH key (or keys) from a model.\nremove-storage             Removes storage from the model.\nremove-unit                Remove application units from the model.\nremove-user                Deletes a Juju user from a controller.\nresolved                   Marks unit errors resolved and re-executes failed hooks\nrestore-backup             Restore from a backup archive to a new controller.\nretry-provisioning         Retries provisioning for failed machines.\nrevoke                     Revokes access from a Juju user for a model or controller\nrun                        Run the commands on the remote targets specified.\nrun-action                 Queue an action for execution.\nscp                        Transfers files to/from a Juju machine.\nset-budget                 Set the budget limit.\nset-constraints            Sets machine constraints for an application.\nset-default-credential     Sets the default credentials for a cloud.\nset-default-region         Sets the default region for a cloud.\nset-meter-status           Sets the meter status on an application or unit.\nset-model-constraints      Sets machine constraints on a model.\nset-plan                   Set the plan for an application.\nshow-action-output         Show results of an action by ID.\nshow-action-status         Show results of all actions filtered by optional ID prefix.\nshow-backup                Show metadata for the specified backup.\nshow-budget                Show details about a budget.\nshow-cloud                 Shows detailed information on a cloud.\nshow-controller            Shows detailed information of a controller.\nshow-machine               Show a machine's status.\nshow-model                 Shows information about the current or specified model.\nshow-status                Reports the current status of the model, machines, applications and units.\nshow-status-log            Output past statuses for the specified entity.\nshow-storage               Shows storage instance information.\nshow-user                  Show information about a user.\nsla                        Set the support level for a model.\nspaces                     List known spaces, including associated subnets\nssh                        Initiates an SSH session or executes a command on a Juju machine.\nssh-keys                   Lists the currently known SSH keys for the current (or specified) model.\nstatus                     Alias for 'show-status'.\nstorage                    Lists storage details.\nstorage-pools              List storage pools.\nsubnets                    List subnets known to Juju.\nsupport                    Alias for 'sla'.\nswitch                     Selects or identifies the current controller and model.\nsync-tools                 Copy tools from the official tool store into a local model.\nunexpose                   Removes public availability over the network for an application.\nunregister                 Unregisters a Juju controller\nupdate-clouds              Updates public cloud information available to Juju.\nupdate-credential          Updates a credential for a cloud.\nupgrade-charm              Upgrade an application's charm.\nupgrade-gui                Upgrade to a new Juju GUI version.\nupgrade-juju               Upgrades Juju on all machines in a model.\nupload-backup              Store a backup archive file remotely in Juju.\nusers                      Lists Juju users allowed to connect to a controller or model.\nversion                    print the current version\nwhoami                     Print current login details\n"
main_test.go:568:
    c.Assert(missing, jc.DeepEquals, set.NewStrings())
... obtained set.Strings = set.Strings{"update-allocation":true}
... expected set.Strings = set.Strings{}
... mismatch at top level: length mismatch, 1 vs 0; obtained set.Strings{"update-allocation":true}; expected set.Strings{}


----------------------------------------------------------------------
PASS: main_test.go:612: MainSuite.TestHelpGlobalOptions	3.289s
PASS: main_test.go:678: MainSuite.TestModelCommands	0.001s
PASS: main_test.go:255: MainSuite.TestNoWarn1xWith2xData	0.495s
PASS: main_test.go:288: MainSuite.TestNoWarnWithNo1xOr2xData	1.282s

----------------------------------------------------------------------
FAIL: main_test.go:635: MainSuite.TestRegisterCommands

main_test.go:659:
    c.Check(registry.names, jc.DeepEquals, expected)
... obtained []string = []string{"actions", "add-cloud", "add-credential", "add-machine", "add-model", "add-relation", "add-space", "add-ssh-key", "add-storage", "add-subnet", "add-unit", "add-user", "agree", "agreements", "allocate", "attach-storage", "autoload-credentials", "backups", "bootstrap", "budgets", "cached-images", "change-user-password", "charm", "clouds", "cmd-a", "cmd-b", "collect-metrics", "config", "controller-config", "controllers", "create-backup", "create-budget", "create-storage-pool", "credentials", "debug-hooks", "debug-log", "deploy", "destroy-controller", "destroy-model", "detach-storage", "disable-command", "disable-user", "disabled-commands", "download-backup", "enable-command", "enable-destroy-controller", "enable-ha", "enable-user", "expose", "get-constraints", "get-model-constraints", "grant", "gui", "help", "help-tool", "import-ssh-key", "kill-controller", "list-actions", "list-agreements", "list-backups", "list-budgets", "list-cached-images", "list-clouds", "list-controllers", "list-credentials", "list-disabled-commands", "list-machines", "list-models", "list-plans", "list-regions", "list-spaces", "list-ssh-keys", "list-storage", "list-storage-pools", "list-subnets", "list-users", "login", "logout", "machines", "metrics", "migrate", "model-config", "model-defaults", "models", "plans", "regions", "register", "relate", "remove-application", "remove-backup", "remove-cached-images", "remove-cloud", "remove-credential", "remove-machine", "remove-relation", "remove-ssh-key", "remove-storage", "remove-unit", "remove-user", "resolved", "restore-backup", "retry-provisioning", "revoke", "run", "run-action", "scp", "set-budget", "set-constraints", "set-default-credential", "set-default-region", "set-meter-status", "set-model-constraints", "set-plan", "show-action-output", "show-action-status", "show-backup", "show-budget", "show-cloud", "show-controller", "show-machine", "show-model", "show-status", "show-status-log", "show-storage", "show-user", "sla", "spaces", "ssh", "ssh-keys", "status", "storage", "storage-pools", "subnets", "support", "switch", "sync-tools", "unexpose", "unregister", "update-clouds", "update-credential", "upgrade-charm", "upgrade-gui", "upgrade-juju", "upload-backup", "users", "version", "whoami"}
... expected []string = []string{"actions", "add-cloud", "add-credential", "add-machine", "add-model", "add-relation", "add-space", "add-ssh-key", "add-storage", "add-subnet", "add-unit", "add-user", "agree", "agreements", "allocate", "attach-storage", "autoload-credentials", "backups", "bootstrap", "budgets", "cached-images", "change-user-password", "charm", "clouds", "cmd-a", "cmd-b", "collect-metrics", "config", "controller-config", "controllers", "create-backup", "create-budget", "create-storage-pool", "credentials", "debug-hooks", "debug-log", "deploy", "destroy-controller", "destroy-model", "detach-storage", "disable-command", "disable-user", "disabled-commands", "download-backup", "enable-command", "enable-destroy-controller", "enable-ha", "enable-user", "expose", "get-constraints", "get-model-constraints", "grant", "gui", "help", "help-tool", "import-ssh-key", "kill-controller", "list-actions", "list-agreements", "list-backups", "list-budgets", "list-cached-images", "list-clouds", "list-controllers", "list-credentials", "list-disabled-commands", "list-machines", "list-models", "list-plans", "list-regions", "list-spaces", "list-ssh-keys", "list-storage", "list-storage-pools", "list-subnets", "list-users", "login", "logout", "machines", "metrics", "migrate", "model-config", "model-defaults", "models", "plans", "regions", "register", "relate", "remove-application", "remove-backup", "remove-cached-images", "remove-cloud", "remove-credential", "remove-machine", "remove-relation", "remove-ssh-key", "remove-storage", "remove-unit", "remove-user", "resolved", "restore-backup", "retry-provisioning", "revoke", "run", "run-action", "scp", "set-budget", "set-constraints", "set-default-credential", "set-default-region", "set-meter-status", "set-model-constraints", "set-plan", "show-action-output", "show-action-status", "show-backup", "show-budget", "show-cloud", "show-controller", "show-machine", "show-model", "show-status", "show-status-log", "show-storage", "show-user", "sla", "spaces", "ssh", "ssh-keys", "status", "storage", "storage-pools", "subnets", "support", "switch", "sync-tools", "unexpose", "unregister", "update-allocation", "update-clouds", "update-credential", "upgrade-charm", "upgrade-gui", "upgrade-juju", "upload-backup", "users", "version", "whoami"}
... mismatch at top level: length mismatch, 147 vs 148; obtained []string{"actions", "add-cloud", "add-credential", "add-machine", "add-model", "add-relation", "add-space", "add-ssh-key", "add-storage", "add-subnet", "add-unit", "add-user", "agree", "agreements", "allocate", "attach-storage", "autoload-credentials", "backups", "bootstrap", "budgets", "cached-images", "change-user-password", "charm", "clouds", "cmd-a", "cmd-b", "collect-metrics", "config", "controller-config", "controllers", "create-backup", "create-budget", "create-storage-pool", "credentials", "debug-hooks", "debug-log", "deploy", "destroy-controller", "destroy-model", "detach-storage", "disable-command", "disable-user", "disabled-commands", "download-backup", "enable-command", "enable-destroy-controller", "enable-ha", "enable-user", "expose", "get-constraints", "get-model-constraints", "grant", "gui", "help", "help-tool", "import-ssh-key", "kill-controller", "list-actions", "list-agreements", "list-backups", "list-budgets", "list-cached-images", "list-clouds", "list-controllers", "list-credentials", "list-disabled-commands", "list-machines", "list-models", "list-plans", "list-regions", "list-spaces", "list-ssh-keys", "list-storage", "list-storage-pools", "list-subnets", "list-users", "login", "logout", "machines", "metrics", "migrate", "model-config", "model-defaults", "models", "plans", "regions", "register", "relate", "remove-application", "remove-backup", "remove-cached-images", "remove-cloud", "remove-credential", "remove-machine", "remove-relation", "remove-ssh-key", "remove-storage", "remove-unit", "remove-user", "resolved", "restore-backup", "retry-provisioning", "revoke", "run", "run-action", "scp", "set-budget", "set-constraints", "set-default-credential", "set-default-region", "set-meter-status", "set-model-constraints", "set-plan", "show-action-output", "show-action-status", "show-backup", "show-budget", "show-cloud", "show-controller", "show-machine", "show-model", "show-status", "show-status-log", "show-storage", "show-user", "sla", "spaces", "ssh", "ssh-keys", "status", "storage", "storage-pools", "subnets", "support", "switch", "sync-tools", "unexpose", "unregister", "update-clouds", "update-credential", "upgrade-charm", "upgrade-gui", "upgrade-juju", "upload-backup", "users", "version", "whoami"}; expected []string{"actions", "add-cloud", "add-credential", "add-machine", "add-model", "add-relation", "add-space", "add-ssh-key", "add-storage", "add-subnet", "add-unit", "add-user", "agree", "agreements", "allocate", "attach-storage", "autoload-credentials", "backups", "bootstrap", "budgets", "cached-images", "change-user-password", "charm", "clouds", "cmd-a", "cmd-b", "collect-metrics", "config", "controller-config", "controllers", "create-backup", "create-budget", "create-storage-pool", "credentials", "debug-hooks", "debug-log", "deploy", "destroy-controller", "destroy-model", "detach-storage", "disable-command", "disable-user", "disabled-commands", "download-backup", "enable-command", "enable-destroy-controller", "enable-ha", "enable-user", "expose", "get-constraints", "get-model-constraints", "grant", "gui", "help", "help-tool", "import-ssh-key", "kill-controller", "list-actions", "list-agreements", "list-backups", "list-budgets", "list-cached-images", "list-clouds", "list-controllers", "list-credentials", "list-disabled-commands", "list-machines", "list-models", "list-plans", "list-regions", "list-spaces", "list-ssh-keys", "list-storage", "list-storage-pools", "list-subnets", "list-users", "login", "logout", "machines", "metrics", "migrate", "model-config", "model-defaults", "models", "plans", "regions", "register", "relate", "remove-application", "remove-backup", "remove-cached-images", "remove-cloud", "remove-credential", "remove-machine", "remove-relation", "remove-ssh-key", "remove-storage", "remove-unit", "remove-user", "resolved", "restore-backup", "retry-provisioning", "revoke", "run", "run-action", "scp", "set-budget", "set-constraints", "set-default-credential", "set-default-region", "set-meter-status", "set-model-constraints", "set-plan", "show-action-output", "show-action-status", "show-backup", "show-budget", "show-cloud", "show-controller", "show-machine", "show-model", "show-status", "show-status-log", "show-storage", "show-user", "sla", "spaces", "ssh", "ssh-keys", "status", "storage", "storage-pools", "subnets", "support", "switch", "sync-tools", "unexpose", "unregister", "update-allocation", "update-clouds", "update-credential", "upgrade-charm", "upgrade-gui", "upgrade-juju", "upload-backup", "users", "version", "whoami"}
Member

tasdomas commented Mar 21, 2017

$$merge$$

Contributor

jujubot commented Mar 21, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 21f5245 into juju:rising-sun Mar 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment