Open callum-stakater opened 10 months ago
OK I found a way around it using jsonpatch instead which is maybe arguably a bit nicer anyway
apiVersion: machine.openshift.io/v1beta1
kind: MachineSet
metadata:
name: test-1
namespace: openshift-machine-api
annotations:
"redhat-cop.redhat.io/patch-type": "application/json-patch+json"
"redhat-cop.redhat.io/patch": |
- op: replace
path: /spec/selector/matchLabels/machine.openshift.io~1cluster-api-cluster
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}
- op: replace
path: /spec/selector/matchLabels/machine.openshift.io~1cluster-api-machineset
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}-tester-0
- op: replace
path: /spec/template/metadata/labels/machine.openshift.io~1cluster-api-cluster
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}
- op: replace
path: /spec/template/metadata/labels/machine.openshift.io~1cluster-api-machineset
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}-tester-0
- op: replace
path: /spec/template/spec/providerSpec/value/networks/0/subnets/0/filter/name
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}-nodes
- op: replace
path: /spec/template/spec/providerSpec/value/networks/0/subnets/0/filter/tags
value: openshiftClusterID= {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}
- op: replace
path: /spec/template/spec/providerSpec/value/userDataSecret/name
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}-user-data
- op: replace
path: /spec/template/spec/providerSpec/value/serverGroupName
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}-tester
- op: replace
path: /spec/template/spec/providerSpec/value/metadata/serverMetadata/openshiftClusterID
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}
- op: replace
path: /spec/template/spec/providerSpec/value/securityGroups/0/filter/name
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}-tester
- op: replace
path: /spec/template/spec/providerSpec/value/tags/0
value: openshiftClusterID= {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}
- op: replace
path: /spec/template/spec/providerSpec/value/rootVolume/sourceUUID
value: {{ (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.infrastructureName }}-rhcos
spec:
replicas: 0
selector:
matchLabels:
machine.openshift.io/cluster-api-cluster: REPLACEME
machine.openshift.io/cluster-api-machineset: REPLACEME-tester-0
template:
metadata:
labels:
machine.openshift.io/cluster-api-cluster: REPLACEME
machine.openshift.io/cluster-api-machine-role: tester
machine.openshift.io/cluster-api-machine-type: tester
machine.openshift.io/cluster-api-machineset: REPLACEME-tester-0
spec:
lifecycleHooks: {}
metadata: {}
providerSpec:
value:
cloudName: openstack
networks:
- filter: {}
subnets:
- filter:
name: REPLACEME-nodes
tags: openshiftClusterID=REPLACEME
userDataSecret:
name: tester-user-data
serverGroupName: REPLACEME-tester
cloudsSecret:
name: openstack-cloud-credentials
namespace: openshift-machine-api
metadata:
creationTimestamp: null
serverMetadata:
Name: REPLACEME-tester
openshiftClusterID: REPLACEME
securityGroups:
- filter: {}
name: REPLACEME-tester
kind: OpenstackProviderSpec
tags:
- openshiftClusterID=REPLACEME
image: ''
rootVolume:
deviceType: ''
diskSize: 120
sourceType: image
sourceUUID: REPLACEME-rhcos
volumeType: __DEFAULT__
apiVersion: openstackproviderconfig.openshift.io/v1alpha1
flavor: hm.8x24
I can confirm the same issue & workaround on Azure
Attempting to deploy a
MachineSet
via openshift-gitops (issue is also visible when oc apply so isnt gitops related) and using patch-operator as a way to dynamically inject theinfrastructure_id
via the following patchresults in an error:
Error "failed calling webhook "patch-operator-inject.redhatcop.redhat.io": failed to call webhook: Post "https://patch-operator-controller-manager-service.patch-operator.svc:443/inject?timeout=10s": EOF" for field "undefined".
and the following stack trace in the pod logs:
In general patch-operator is functional and machinesets in general can be patched for example this works:
the example is attempting to create machineset on openstack provider but the same was experienced on vsphere also so isnt provider specific