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

Convert create into async #23

Merged
merged 1 commit into from May 28, 2019

Conversation

enxebre
Copy link
Member

@enxebre enxebre commented May 28, 2019

This mimics aws behaviour for async creation by relying on the instance.Status.

Staging:

apiVersion: machine.openshift.io/v1beta1
kind: Machine
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"machine.openshift.io/v1beta1","kind":"Machine","metadata":{"annotations":{},"labels":{"machine.openshift.io/cluster-api-cluster":"agl060519-rnvnt","machine.openshift.io/cluster-api-machine-role":"test-gcp","machine.openshift.io/cluster-api-machine-type":"test-gcp"},"name":"agl060519-rnvnt-test-gcp-34","namespace":"test-gcp"},"spec":{"providerSpec":{"value":{"apiVersion":"gcpproviderconfig.openshift.io/v1beta1","canIPForward":true,"credentialsSecret":{"name":"test"},"deletionProtection":false,"disks":[{"autoDelete":true,"boot":true,"image":"projects/coreos-cloud/global/images/coreos-stable-2079-3-0-v20190423","sizeGb":10,"type":"pd-standard"}],"machineType":"n1-standard-1","networkInterfaces":[{"subnetwork":"gcp-actuator-test-subnet"}],"region":"us-east1","zone":"us-east1-b"}}}}
  creationTimestamp: "2019-05-28T10:33:15Z"
  finalizers:
  - machine.machine.openshift.io
  generation: 3
  labels:
    machine.openshift.io/cluster-api-cluster: agl060519-rnvnt
    machine.openshift.io/cluster-api-machine-role: test-gcp
    machine.openshift.io/cluster-api-machine-type: test-gcp
  name: agl060519-rnvnt-test-gcp-34
  namespace: test-gcp
  resourceVersion: "342025"
  selfLink: /apis/machine.openshift.io/v1beta1/namespaces/test-gcp/machines/agl060519-rnvnt-test-gcp-34
  uid: 006cf633-8134-11e9-a208-0a129cf3cc42
spec:
  metadata:
    creationTimestamp: null
  providerID: gce://openshift-gce-devel/us-east1-b/agl060519-rnvnt-test-gcp-34
  providerSpec:
    value:
      apiVersion: gcpproviderconfig.openshift.io/v1beta1
      canIPForward: true
      credentialsSecret:
        name: test
      deletionProtection: false
      disks:
      - autoDelete: true
        boot: true
        image: projects/coreos-cloud/global/images/coreos-stable-2079-3-0-v20190423
        labels: null
        sizeGb: 10
        type: pd-standard
      machineType: n1-standard-1
      metadata:
        creationTimestamp: null
      networkInterfaces:
      - subnetwork: gcp-actuator-test-subnet
      region: us-east1
      serviceAccounts: null
      zone: us-east1-b
status:
  addresses:
  - address: 10.0.0.66
    type: InternalIP
  - address: 35.196.144.13
    type: ExternalIP
  - address: agl060519-rnvnt-test-gcp-34.us-east1-b.c.openshift-gce-devel.internal
    type: InternalDNS
  - address: agl060519-rnvnt-test-gcp-34.c.openshift-gce-devel.internal
    type: AltInternalDNS
  providerStatus:
    conditions:
    - lastProbeTime: "2019-05-28T10:33:21Z"
      lastTransitionTime: "2019-05-28T10:33:21Z"
      message: machine successfully created
      reason: MachineCreationSucceeded
      status: "True"
      type: MachineCreated
    instanceId: agl060519-rnvnt-test-gcp-34
    instanceState: STAGING
    metadata:
      creationTimestamp: null

Running:

apiVersion: machine.openshift.io/v1beta1
kind: Machine
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"machine.openshift.io/v1beta1","kind":"Machine","metadata":{"annotations":{},"labels":{"machine.openshift.io/cluster-api-cluster":"agl060519-rnvnt","machine.openshift.io/cluster-api-machine-role":"test-gcp","machine.openshift.io/cluster-api-machine-type":"test-gcp"},"name":"agl060519-rnvnt-test-gcp-34","namespace":"test-gcp"},"spec":{"providerSpec":{"value":{"apiVersion":"gcpproviderconfig.openshift.io/v1beta1","canIPForward":true,"credentialsSecret":{"name":"test"},"deletionProtection":false,"disks":[{"autoDelete":true,"boot":true,"image":"projects/coreos-cloud/global/images/coreos-stable-2079-3-0-v20190423","sizeGb":10,"type":"pd-standard"}],"machineType":"n1-standard-1","networkInterfaces":[{"subnetwork":"gcp-actuator-test-subnet"}],"region":"us-east1","zone":"us-east1-b"}}}}
  creationTimestamp: "2019-05-28T10:33:15Z"
  finalizers:
  - machine.machine.openshift.io
  generation: 3
  labels:
    machine.openshift.io/cluster-api-cluster: agl060519-rnvnt
    machine.openshift.io/cluster-api-machine-role: test-gcp
    machine.openshift.io/cluster-api-machine-type: test-gcp
  name: agl060519-rnvnt-test-gcp-34
  namespace: test-gcp
  resourceVersion: "342093"
  selfLink: /apis/machine.openshift.io/v1beta1/namespaces/test-gcp/machines/agl060519-rnvnt-test-gcp-34
  uid: 006cf633-8134-11e9-a208-0a129cf3cc42
spec:
  metadata:
    creationTimestamp: null
  providerID: gce://openshift-gce-devel/us-east1-b/agl060519-rnvnt-test-gcp-34
  providerSpec:
    value:
      apiVersion: gcpproviderconfig.openshift.io/v1beta1
      canIPForward: true
      credentialsSecret:
        name: test
      deletionProtection: false
      disks:
      - autoDelete: true
        boot: true
        image: projects/coreos-cloud/global/images/coreos-stable-2079-3-0-v20190423
        labels: null
        sizeGb: 10
        type: pd-standard
      machineType: n1-standard-1
      metadata:
        creationTimestamp: null
      networkInterfaces:
      - subnetwork: gcp-actuator-test-subnet
      region: us-east1
      serviceAccounts: null
      zone: us-east1-b
status:
  addresses:
  - address: 10.0.0.66
    type: InternalIP
  - address: 35.196.144.13
    type: ExternalIP
  - address: agl060519-rnvnt-test-gcp-34.us-east1-b.c.openshift-gce-devel.internal
    type: InternalDNS
  - address: agl060519-rnvnt-test-gcp-34.c.openshift-gce-devel.internal
    type: AltInternalDNS
  providerStatus:
    conditions:
    - lastProbeTime: "2019-05-28T10:33:21Z"
      lastTransitionTime: "2019-05-28T10:33:21Z"
      message: machine successfully created
      reason: MachineCreationSucceeded
      status: "True"
      type: MachineCreated
    instanceId: agl060519-rnvnt-test-gcp-34
    instanceState: RUNNING
    metadata:
      creationTimestamp: null

Logs reflects the machine going from provisioning->staging->running:

I0528 12:33:15.798511   74067 controller.go:129] Reconciling Machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:15.798564   74067 controller.go:292] Machine "agl060519-rnvnt-test-gcp-34" in namespace "test-gcp" doesn't specify "cluster.k8s.io/cluster-name" label, assuming nil cluster
I0528 12:33:16.000987   74067 controller.go:129] Reconciling Machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:16.001044   74067 controller.go:292] Machine "agl060519-rnvnt-test-gcp-34" in namespace "test-gcp" doesn't specify "cluster.k8s.io/cluster-name" label, assuming nil cluster
I0528 12:33:16.001080   74067 actuator.go:57] Checking if machine "agl060519-rnvnt-test-gcp-34" exists
I0528 12:33:16.001954   74067 reflector.go:131] Starting reflector *v1.Secret (10h0m0s) from sigs.k8s.io/controller-runtime/pkg/cache/internal/informers_map.go:196
I0528 12:33:16.001979   74067 reflector.go:169] Listing and watching *v1.Secret from sigs.k8s.io/controller-runtime/pkg/cache/internal/informers_map.go:196
I0528 12:33:18.006935   74067 shared_informer.go:123] caches populated
I0528 12:33:19.492240   74067 reconciler.go:268] Machine "agl060519-rnvnt-test-gcp-34" does not exist
I0528 12:33:19.492278   74067 controller.go:246] Reconciling machine object agl060519-rnvnt-test-gcp-34 triggers idempotent create.
I0528 12:33:19.492308   74067 actuator.go:43] Creating machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:21.121422   74067 reconciler.go:145] Reconciling machine object "agl060519-rnvnt-test-gcp-34" with cloud state
I0528 12:33:21.530097   74067 conditions.go:40] Adding new provider condition {MachineCreated True 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC MachineCreationSucceeded machine successfully created}
I0528 12:33:21.530169   74067 reconciler.go:191] machine "agl060519-rnvnt-test-gcp-34" status is "PROVISIONING", requeuing...
I0528 12:33:21.530374   74067 machine_scope.go:118] Storing machine spec for "agl060519-rnvnt-test-gcp-34", resourceVersion: 341995, generation: 2
I0528 12:33:21.742787   74067 machine_scope.go:129] Storing machine status for "agl060519-rnvnt-test-gcp-34", resourceVersion: 341995, generation: 2
W0528 12:33:21.977681   74067 controller.go:248] Failed to create machine "agl060519-rnvnt-test-gcp-34": requeue in: 20s
I0528 12:33:21.977719   74067 controller.go:346] Actuator returned requeue-after error: requeue in: 20s
I0528 12:33:21.977777   74067 controller.go:129] Reconciling Machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:21.977788   74067 controller.go:292] Machine "agl060519-rnvnt-test-gcp-34" in namespace "test-gcp" doesn't specify "cluster.k8s.io/cluster-name" label, assuming nil cluster
I0528 12:33:21.977798   74067 actuator.go:57] Checking if machine "agl060519-rnvnt-test-gcp-34" exists
I0528 12:33:22.682087   74067 reconciler.go:260] Machine "agl060519-rnvnt-test-gcp-34" already exists
I0528 12:33:22.682124   74067 controller.go:237] Reconciling machine "agl060519-rnvnt-test-gcp-34" triggers idempotent update
I0528 12:33:22.682146   74067 actuator.go:75] Updating machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:22.682892   74067 reconciler.go:145] Reconciling machine object "agl060519-rnvnt-test-gcp-34" with cloud state
I0528 12:33:23.168907   74067 reconciler.go:191] machine "agl060519-rnvnt-test-gcp-34" status is "STAGING", requeuing...
I0528 12:33:23.168964   74067 machine_scope.go:118] Storing machine spec for "agl060519-rnvnt-test-gcp-34", resourceVersion: 342019, generation: 3
I0528 12:33:23.379412   74067 machine_scope.go:129] Storing machine status for "agl060519-rnvnt-test-gcp-34", resourceVersion: 342019, generation: 3
E0528 12:33:23.582505   74067 controller.go:239] Error updating machine "test-gcp/agl060519-rnvnt-test-gcp-34": requeue in: 20s
I0528 12:33:23.582539   74067 controller.go:346] Actuator returned requeue-after error: requeue in: 20s
I0528 12:33:23.585211   74067 controller.go:129] Reconciling Machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:23.585228   74067 controller.go:292] Machine "agl060519-rnvnt-test-gcp-34" in namespace "test-gcp" doesn't specify "cluster.k8s.io/cluster-name" label, assuming nil cluster
I0528 12:33:23.585239   74067 actuator.go:57] Checking if machine "agl060519-rnvnt-test-gcp-34" exists
I0528 12:33:24.381202   74067 reconciler.go:260] Machine "agl060519-rnvnt-test-gcp-34" already exists
I0528 12:33:24.381239   74067 controller.go:237] Reconciling machine "agl060519-rnvnt-test-gcp-34" triggers idempotent update
I0528 12:33:24.381256   74067 actuator.go:75] Updating machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:24.382005   74067 reconciler.go:145] Reconciling machine object "agl060519-rnvnt-test-gcp-34" with cloud state
I0528 12:33:24.909301   74067 reconciler.go:191] machine "agl060519-rnvnt-test-gcp-34" status is "STAGING", requeuing...
I0528 12:33:24.909366   74067 machine_scope.go:118] Storing machine spec for "agl060519-rnvnt-test-gcp-34", resourceVersion: 342025, generation: 3
I0528 12:33:25.203980   74067 machine_scope.go:129] Storing machine status for "agl060519-rnvnt-test-gcp-34", resourceVersion: 342025, generation: 3
E0528 12:33:25.455964   74067 controller.go:239] Error updating machine "test-gcp/agl060519-rnvnt-test-gcp-34": requeue in: 20s
I0528 12:33:25.456026   74067 controller.go:346] Actuator returned requeue-after error: requeue in: 20s
I0528 12:33:41.978262   74067 controller.go:129] Reconciling Machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:41.978311   74067 controller.go:292] Machine "agl060519-rnvnt-test-gcp-34" in namespace "test-gcp" doesn't specify "cluster.k8s.io/cluster-name" label, assuming nil cluster
I0528 12:33:41.978335   74067 actuator.go:57] Checking if machine "agl060519-rnvnt-test-gcp-34" exists
I0528 12:33:42.829907   74067 reconciler.go:260] Machine "agl060519-rnvnt-test-gcp-34" already exists
I0528 12:33:42.829943   74067 controller.go:237] Reconciling machine "agl060519-rnvnt-test-gcp-34" triggers idempotent update
I0528 12:33:42.829956   74067 actuator.go:75] Updating machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:42.830760   74067 reconciler.go:145] Reconciling machine object "agl060519-rnvnt-test-gcp-34" with cloud state
I0528 12:33:43.274389   74067 machine_scope.go:118] Storing machine spec for "agl060519-rnvnt-test-gcp-34", resourceVersion: 342025, generation: 3
I0528 12:33:43.479690   74067 machine_scope.go:129] Storing machine status for "agl060519-rnvnt-test-gcp-34", resourceVersion: 342025, generation: 3
I0528 12:33:43.750749   74067 controller.go:129] Reconciling Machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:43.750785   74067 controller.go:292] Machine "agl060519-rnvnt-test-gcp-34" in namespace "test-gcp" doesn't specify "cluster.k8s.io/cluster-name" label, assuming nil cluster
I0528 12:33:43.750801   74067 actuator.go:57] Checking if machine "agl060519-rnvnt-test-gcp-34" exists
I0528 12:33:44.672969   74067 reconciler.go:260] Machine "agl060519-rnvnt-test-gcp-34" already exists
I0528 12:33:44.673009   74067 controller.go:237] Reconciling machine "agl060519-rnvnt-test-gcp-34" triggers idempotent update
I0528 12:33:44.673024   74067 actuator.go:75] Updating machine "agl060519-rnvnt-test-gcp-34"
I0528 12:33:44.673672   74067 reconciler.go:145] Reconciling machine object "agl060519-rnvnt-test-gcp-34" with cloud state
I0528 12:33:45.184977   74067 machine_scope.go:118] Storing machine spec for "agl060519-rnvnt-test-gcp-34", resourceVersion: 342093, generation: 3
I0528 12:33:45.396167   74067 machine_scope.go:129] Storing machine status for "agl060519-rnvnt-test-gcp-34", resourceVersion: 342093, generation: 3

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 28, 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 May 28, 2019
@frobware
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: frobware

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 May 28, 2019
@openshift-merge-robot openshift-merge-robot merged commit 6925341 into openshift:master May 28, 2019
klog.Infof("Machine %q already exists", r.machine.Name)
return true, nil
switch instance.Status {
case "PROVISIONING", "REPAIRING", "RUNNING", "STAGING":
Copy link
Contributor

@frobware frobware May 29, 2019

Choose a reason for hiding this comment

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

I wonder whether this should be inverted:

	switch instance.Status {
	case "TERMINATED":
		klog.Infof("Machine %q is considered as non existent as its status is %q", instance.Status)
		return false, nil
	default:
		klog.Infof("Machine %q already exists", r.machine.Name)
		return true, nil
	}

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 should make all explicit and error otherwise

Copy link
Contributor

@frobware frobware May 29, 2019

Choose a reason for hiding this comment

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

we should make all explicit and error otherwise

This becomes brittle. We only really care for the TERMINATED state.

RadekManak pushed a commit to RadekManak/cluster-api-provider-gcp that referenced this pull request Apr 12, 2023
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

4 participants