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

pkg/actuators/machine/utils: Client-side state filtering in getInstanceByID and getInstances #268

Conversation

wking
Copy link
Member

@wking wking commented Nov 13, 2019

We're already using server-side ID filtering, which means we should only ever have a single matching instance come back. By keeping the state filtering local, we can log more interesting stuff like:

instance i-123 state terminated is not in running, pending, stopped, stopping, shutting-down

/assign @enxebre

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 13, 2019
@wking wking force-pushed the getInstanceByID-client-side-state-filter branch 5 times, most recently from 0436c6e to 1192cda Compare November 14, 2019 03:27
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 14, 2019
@wking wking force-pushed the getInstanceByID-client-side-state-filter branch 2 times, most recently from a9f3c3a to b9d61a7 Compare November 14, 2019 05:28
…ancesOutput

So we can create pending, terminated, etc. instances for testing.
This should scale better than
stub{State}InstanceDescribeInstancesOutput from
openshift/cluster-api-provider-aws@c8e341f22f (Stop retieving
instances by state on API call, 2019-11-14,
openshift#269).
…ceByID

openshift/cluster-api-provider-aws@c8e341f22f (Stop retieving
instances by state on API call, 2019-11-14,
openshift#269) did part of this.  This commit:

* Restores the instanceStateFilter argument to getInstanceByID, to
  avoid having two definitions (existingInstanceStates and a local !=
  Terminated in getExistingInstanceByID) that define what it means to
  exist.  This will also give us logged error messages like:

    instance i-123 state terminated is not in running, pending, stopped, stopping, shutting-down

  which will make it easier to find and fix omissions in
  existingInstanceStates.

* Adds a -running suffix to has-status-search-by-id, so it's easier to
  distinguish from the terminated case.

* Converts to the hyphenated has-status-search-by-id-terminated,
  instead of mixing hyphens and spaces in a case name.

* Uses inline argument for the DescribeInstances mocks, so we don't
  have to use request and request2.  These aren't so big that inlining
  them makes the mock setup unreadable.

* Returns an empty set of instances in the instance-listing fallback
  call in has-status-search-by-id-terminated (which we now require to
  happen after the by-ID call).  The list call is filtered by state,
  so it wouldn't return a terminated instance.
@wking wking force-pushed the getInstanceByID-client-side-state-filter branch from b9d61a7 to e4e94b1 Compare November 14, 2019 16:21
@wking
Copy link
Member Author

wking commented Nov 14, 2019

Rebased around #269 with b9d61a730 -> e4e94b1. Details on why I think we want these additional pivots in the commit messages.

@enxebre
Copy link
Member

enxebre commented Nov 14, 2019

@enxebre
Copy link
Member

enxebre commented Nov 14, 2019

/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enxebre

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 14, 2019
@wking
Copy link
Member Author

wking commented Nov 14, 2019

what do you think about dropping...

Good idea, since the name filter should already give us a pretty reasonable cap one the response size even without the state filters. Rerollling...

Like openshift/cluster-api-provider-aws@e4e94b1e08
(pkg/actuators/machine/utils: Client-side state filtering in
getInstanceByID, 2019-11-13, openshift#268),
but for getInstances.  The cluster/name filtering is already enough to
limit the list response to a reasonable size, so we can perform the
state filtering locally in order to produce useful error messages.

Also fix a bug in TestGetMachineInstances about the expected return
type of getMachineInstances; it's a slice, not a single instance.

Also, fix a few "Running" -> InstanceStateNameRunning bugs; the AWS
string is "running", but we shouldn't care either way.
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 14, 2019
@wking
Copy link
Member Author

wking commented Nov 14, 2019

what do you think about dropping...

Done with e4e94b1 -> 382b1df.

@enxebre
Copy link
Member

enxebre commented Nov 14, 2019

/lgtm
thanks

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 14, 2019
@wking wking changed the title pkg/actuators/machine/utils: Client-side state filtering in getInstanceByID pkg/actuators/machine/utils: Client-side state filtering in getInstanceByID and getInstances Nov 14, 2019
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 0ee2017 into openshift:master Nov 14, 2019
@wking wking deleted the getInstanceByID-client-side-state-filter branch November 18, 2019 19:26
enxebre pushed a commit to enxebre/cluster-api-provider-aws-2 that referenced this pull request Feb 20, 2020
Like openshift/cluster-api-provider-aws@e4e94b1e08
(pkg/actuators/machine/utils: Client-side state filtering in
getInstanceByID, 2019-11-13, openshift#268),
but for getInstances.  The cluster/name filtering is already enough to
limit the list response to a reasonable size, so we can perform the
state filtering locally in order to produce useful error messages.

Also fix a bug in TestGetMachineInstances about the expected return
type of getMachineInstances; it's a slice, not a single instance.

Also, fix a few "Running" -> InstanceStateNameRunning bugs; the AWS
string is "running", but we shouldn't care either way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants