Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action-set: a jujuc command for Actions to send values back to state #415

Closed
wants to merge 9 commits into from

Conversation

binary132
Copy link
Contributor

action-set permits action hooks to define an arbitrary map of params
which will be returned to the state server at the end of the Action.

@@ -38,7 +38,14 @@ func (dummyHookContext) ConfigSettings() (charm.Settings, error) {
func (dummyHookContext) ActionParams() map[string]interface{} {
return nil
}

func (dummyHookContext) ActionResults() interface{} {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map[string]interface{} perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

action-set "ipso facto"?

@binary132
Copy link
Contributor Author

I've updated this with some of the requests @fwereade made:

  • action-failed will be moved to another PR.
  • bare values are now treated as values in a map with auto-created keys.
  • the map can be added to from one invocation to another.

However, I wasn't able to remove the methods from Context since several of the methods on ActionSetCommand take Context interface arguments, meaning the methods needed have to be defined on Context.

@bz2
Copy link
Contributor

bz2 commented Jul 31, 2014

LGTM overall. As discussed, we probably want the addition to Context to be just a struct actionResult with a sub map[string]interface{} for the results set, other keys for other result metadata such as the error, process return code and so on.

@binary132
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Jul 31, 2014

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

@jujubot
Copy link
Collaborator

jujubot commented Jul 31, 2014

Build failed: Does not match ['fixes-1350911', 'fixes-1347715']
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/196

}

// ActionSetFailed sets an error value for the Action and makes it unable to
// add more values unless SetFailed(nil) is passed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely once it's failed, it's failed?

But I think there's still a use case for setting values -- comprehensive debug information might actually be kinda super-awesome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me like a fail state could be something reversible; for example, if a web API is busy, the Action might poll it until it receives a good response, at which point the error could be reset, or for 5 minutes. If the 5 minutes are up before the failure is cleared, the final result will be a fail; otherwise, it seems like it could be cleared.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it shouldn't tell us it's failed -- it might happily block for a bit, but it hasn't failed while it's still retrying. When it's run out of attempts, sure, it fails: "I tried 5 times, still didn't work, sorry".

c.Assert(err, gc.IsNil)
hctx := s.getHookContext(c, uuid.String(), -1, "", noProxies)
hctx.SetActionData(names.ActionTag{}, map[string]interface{}(nil))
com, err := jujuc.NewCommand(hctx, "action-set")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not testing UpdateActionResults, it's testing action-set. (which might call UAR under the hood, or it might not -- who knows? ;p)

@fwereade
Copy link
Contributor

fwereade commented Sep 3, 2014

Few more comments -- fwiw, breaking the changes to Context out and doing it separately from action-set itself would make it easier to review and possibly quicker to merge ;).

action-set permits action hooks to define an arbitrary map of params
which will be returned to the state server at the end of the Action.
This commit moves the Action results update method into the Context
implementation, so that client code is not changing the results map
on its own.
Addressed:
 - need to keep Action results map segregated from jujuc
 - testing Context interface mock to support this change
 - removed old Context methods
 - changed actionResults inner "error" type to string rather than error
action-set now has a test in worker/uniter/uniter.  This test
demonstrates how action-set overwrites existing values in the
results map.
This commit revises action-set behavior to interact correctly with new
ActionFinish logic on worker uniter.
[]string{"map1", "key", "val"},
[]string{"map1", "val"},
},
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a failing test with an invalid key. And one for mykey=. Here I'm not sure if returning an empty values string is specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@themue
Copy link
Contributor

themue commented Sep 29, 2014

Mostly fine, only missing tests of error situations.

This commit wraps up the changes to `action-set` now that ActionFinish
has landed in core.
@binary132
Copy link
Contributor Author

$$shipit$$

@binary132 binary132 closed this Sep 29, 2014
@binary132 binary132 mentioned this pull request Sep 29, 2014
jujubot added a commit that referenced this pull request Sep 29, 2014
Action set

action-set permits action hooks to define an arbitrary map of params
which will be returned to the state server at the end of the Action.

This is a reopen of #415.  415 failed to
land due to too many pages of comments.
@binary132 binary132 deleted the action-set branch September 29, 2014 19:18
laszlokajtar pushed a commit to laszlokajtar/juju that referenced this pull request Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants