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

Implement events #17

Merged

Conversation

michaelgugino
Copy link
Contributor

No description provided.

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 15, 2019
CoreClient: fake.NewFakeClient(),
EventRecorder: recorder,
})
if machineActuator == nil {
Copy link
Member

Choose a reason for hiding this comment

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

the way it's right now In a follow up we can may be allow to create a secret with credentials, which will be used to create a computeService which won't work and so we validate failure event.
Then if we want to validate success we'd need to allow computeservice injection at this level

Copy link
Contributor

@frobware frobware left a comment

Choose a reason for hiding this comment

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

Need to address the comments left by alberto @ #17 (comment)

@frobware
Copy link
Contributor

frobware commented May 15, 2019

I also think the location where events are emitted should be at source. So in the implementation calls to (lowercase) create, delete, et al and not in the wrapper calls. That way you could [probably] dispense with "noEventAction" too.

@frobware
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2019
@@ -47,10 +68,17 @@ func (a *Actuator) Create(ctx context.Context, cluster *clusterv1.Cluster, machi
machine: machine,
})
if err != nil {
return fmt.Errorf(scopeFailFmt, machine.Name, err)
fmtErr := fmt.Errorf(scopeFailFmt, machine.Name, err)
return a.handleMachineError(machine, apierrors.InvalidMachineConfiguration("error decoding MachineProviderConfig: %v", fmtErr), createEventAction)
Copy link
Member

Choose a reason for hiding this comment

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

s/error decoding MachineProviderConfig/error creating machine scope would be more appropriate

Copy link
Member

Choose a reason for hiding this comment

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

InvalidMachineConfiguration and error decoding MachineProviderConfig are not appropriate here

@@ -93,7 +128,12 @@ func (a *Actuator) Delete(ctx context.Context, cluster *clusterv1.Cluster, machi
machine: machine,
})
if err != nil {
return fmt.Errorf(scopeFailFmt, machine.Name, err)
fmtErr := fmt.Errorf(scopeFailFmt, machine.Name, err)
return a.handleMachineError(machine, apierrors.InvalidMachineConfiguration("error decoding MachineProviderConfig: %v", fmtErr), deleteEventAction)
Copy link
Member

Choose a reason for hiding this comment

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

s/error decoding MachineProviderConfig/error creating machine scope would be more appropriate

Copy link
Member

Choose a reason for hiding this comment

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

InvalidMachineConfiguration does not seem appropriate here

cmd/manager/main.go Outdated Show resolved Hide resolved
@ingvagabund
Copy link
Member

/refresh
/retest

@ingvagabund
Copy link
Member

/test unit

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2019
@michaelgugino michaelgugino force-pushed the event-actuator branch 2 times, most recently from 2570836 to 46d00fa Compare June 18, 2019 13:59
@@ -47,10 +68,15 @@ func (a *Actuator) Create(ctx context.Context, cluster *clusterv1.Cluster, machi
machine: machine,
})
if err != nil {
return fmt.Errorf(scopeFailFmt, machine.Name, err)
fmtErr := fmt.Sprintf(scopeFailFmt, machine.Name, err)
return a.handleMachineError(machine, apierrors.InvalidMachineConfiguration(fmtErr), createEventAction)
Copy link
Member

@enxebre enxebre Jun 18, 2019

Choose a reason for hiding this comment

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

why InvalidMachineConfiguration ? this seems misleading to me, same for all appearences

Copy link
Member

Choose a reason for hiding this comment

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

InvalidMachineConfiguration is generic error type (see https://github.com/kubernetes-sigs/cluster-api/blob/master/pkg/errors/machines.go#L42). Also see https://github.com/kubernetes-sigs/cluster-api/blob/master/pkg/apis/cluster/common/consts.go#L24-L29:

// Represents that the combination of configuration in the MachineSpec
// is not supported by this cluster. This is not a transient error, but
// indicates a state that must be fixed before progress can be made.
//
// Example: the ProviderSpec specifies an instance type that doesn't exist,
InvalidConfigurationMachineError MachineStatusError = "InvalidConfiguration"

newMachineScope might fail due to internal errors. Though, configuration is quite generic and not just about machine configuration. It's fine to consider even internal failures caused by invalid configuration.

Copy link
Member

Choose a reason for hiding this comment

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

regardless what the comment says, that would print "InvalidConfiguration" which seems misleading to me. I would expect "InvalidConfiguration" to be used by a validate() func that as the comment says check that e.g instance type that doesn't exist. We are not forced to be using apierrors.* if they don't fit. IMHO All the abstractions here obfuscate what's actually being printed to the user for the sake of not duplicating a few lines.
This is not a blocker to me though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally, I don't think there's much utility in capture negative events. 99/100 they will be transient. We should probably only record successful events as they're the only things that are useful with our current setup. InvalidConfiguration I think is pretty useful here though; we're unlikely to recover if we fail to get a valid scope except for the infrequent case of GCP API outage.

Copy link
Member

Choose a reason for hiding this comment

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

It's also fine to just use return a.handleMachineError(machine, apierrors.CreateMachine("failed to create scope: %v", err), createEventAction)

@ingvagabund
Copy link
Member

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ingvagabund

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 Jun 19, 2019
@frobware
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 20, 2019
@openshift-merge-robot openshift-merge-robot merged commit eda13f8 into openshift:master Jun 20, 2019
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants