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

Supplemental update for v1alpha2 #896

Merged
merged 19 commits into from
Jul 16, 2019

Conversation

vincepri
Copy link
Member

Signed-off-by: Vince Prignano [email protected]

What this PR does / why we need it:
This PR is a supplemental update for #892 and adds the following:

  • Refactors the controller tests to follow CAPI.
  • Adds a MapFunc to trigger AWSMachine updates from Machines.
  • Updates manager/main.go to include the new controller and API types.
  • Add the AWSMachineTemplate type to be used with MachineSets.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:


@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 12, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 12, 2019
@vincepri vincepri force-pushed the supplemental-v1alpha2 branch 5 times, most recently from 00340df to 2596d19 Compare July 12, 2019 19:00
Copy link
Contributor

@chuckha chuckha left a comment

Choose a reason for hiding this comment

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

this looks fine to me, one q about the rbac though

- apiGroups:
- ""
- cluster.sigs.k8s.io
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 the v1a1 api group for clusters?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is CAPI v1a2 group

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. no, it's not
  2. i solved my rbac issue thanks to this 😂

Copy link
Contributor

Choose a reason for hiding this comment

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

oops sorry didn't see your response, i was responding to myself, not you!

@vincepri vincepri force-pushed the supplemental-v1alpha2 branch 2 times, most recently from edb1cb2 to 5bdf1d1 Compare July 12, 2019 20:16
@vincepri
Copy link
Member Author

/test pull-cluster-api-provider-aws-bazel-integration

@vincepri vincepri force-pushed the supplemental-v1alpha2 branch from 5bdf1d1 to ac34e79 Compare July 13, 2019 16:08
@vincepri
Copy link
Member Author

/test pull-cluster-api-provider-aws-bazel-integration

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 15, 2019
vincepri added 4 commits July 15, 2019 14:25
Signed-off-by: Vince Prignano <[email protected]>
Signed-off-by: Vince Prignano <[email protected]>
Signed-off-by: Vince Prignano <[email protected]>
@vincepri vincepri force-pushed the supplemental-v1alpha2 branch from 6a88e5a to 59ab908 Compare July 15, 2019 21:25
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 15, 2019
Copy link
Contributor

@chuckha chuckha left a comment

Choose a reason for hiding this comment

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

b031db8

this commit looks fine. the code is removed as it should be in CABPK

Signed-off-by: Vince Prignano <[email protected]>
@vincepri vincepri force-pushed the supplemental-v1alpha2 branch from a5bf3c8 to d0e1047 Compare July 16, 2019 16:47
@vincepri
Copy link
Member Author

/test pull-cluster-api-provider-aws-bazel-integration

CoreClient: coreClient,
Client: cs.ClusterV1alpha2(),
ClusterClient: cs.ClusterV1alpha2(),
Copy link
Member

Choose a reason for hiding this comment

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

Not needed currently, but as we continue to refine for v1alpha2, since we have access to the manager client, we should probably remove the typed clients.

Copy link
Member Author

Choose a reason for hiding this comment

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

Totally agree, once the Cluster actuator is also out, we might be able to get rid of them easily

items:
description: AWSMachineProviderCondition is a condition in a AWSMachineProviderStatus
description: NodeAddress contains information for the node's address.
Copy link
Member

Choose a reason for hiding this comment

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

s/NodeAddress/MachineAddresses or InstanceAddresses since we said that these do not need to align with the reported NodeAddresses from the Cloud Provider integration.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need to fork/copy the NodeAddress struct?

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking it wouldn't hurt to create our own with inspiration from the NodeAddress struct, since we could very well end up with different requirements down the line.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll open a PR to CAPI to fork the type, so other providers can use it as well. I can follow-up in a new PR to fixup the CRD/dependency or fix it here, which do you prefer?

Copy link
Member

Choose a reason for hiding this comment

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

followup is good

@@ -25,6 +25,12 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
AnnotationClusterInfrastructureReady = "aws.cluster.sigs.k8s.io/infrastructure-ready"
Copy link
Member

Choose a reason for hiding this comment

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

Should this be: aws.infrastructure.cluster.sigs.k8s.io instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes :)

Copy link
Member Author

Choose a reason for hiding this comment

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

(For v1alpha2)

pkg/apis/infrastructure/v1alpha2/types.go Outdated Show resolved Hide resolved
pkg/controller/awsmachine/awsmachine_controller.go Outdated Show resolved Hide resolved
}

// create creates a machine and is invoked by the machine controller.
func (r *ReconcileAWSMachine) create(scope *actuators.MachineScope) error {
Copy link
Member

Choose a reason for hiding this comment

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

Since this is eventually calling CreateOrGetMachine should this be named createOrGet instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so, I copied the old actuator code. But this create call only happens if the exist call doesn't succeed

Copy link
Member

Choose a reason for hiding this comment

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

We probably need to clean this up quite a bit down the line, no need to do additional queries against the AWS api if we've already verified the existence.

Copy link
Member Author

Choose a reason for hiding this comment

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

Completely agree


scope.SetInstanceID(i.ID)
scope.SetInstanceState(i.State)
scope.SetAnnotation("cluster-api-provider-aws", "true")
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this annotation be namespaced?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can definitely namespace it, I copied it from the old codebase

case infrav1.InstanceStateRunning:
scope.Info("Machine instance is running", "instance-id", *scope.GetInstanceID())
case infrav1.InstanceStatePending:
scope.Info("Machine instance is pending", "instance-id", *scope.GetInstanceID())
Copy link
Member

Choose a reason for hiding this comment

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

We said that the Machine should enter an error state if the underlying instance is no longer available, should that be taken into account here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll follow-up with more logic changes in later PRs, how does that sound? There is a bunch of things to take care of, e.g. Ready/Addresses/etc

vincepri added 6 commits July 16, 2019 11:28
Signed-off-by: Vince Prignano <[email protected]>
Signed-off-by: Vince Prignano <[email protected]>
Signed-off-by: Vince Prignano <[email protected]>
Signed-off-by: Vince Prignano <[email protected]>
}

// AWSMachineStatus defines the observed state of AWSMachine
type AWSMachineStatus struct {
// InstanceID is the instance ID of the machine created in AWS
// Ready is true when the provider resource is ready.
Ready *bool `json:"ready,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Remind me why this is optional?

Copy link
Member Author

Choose a reason for hiding this comment

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

We went for *bool on Status.InfrastructureReady, didn't we want to keep all of them consistent? I honestly don't remember anymore why we decided to go that route, I'll need to dig some CAPI PR

@detiber
Copy link
Member

detiber commented Jul 16, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 16, 2019
@k8s-ci-robot k8s-ci-robot merged commit 8347a46 into kubernetes-sigs:master Jul 16, 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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants