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

[release-4.17] OCPBUGS-46071: Ensure BMH deletion before InfrEnv and NS #2131

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ztp/siteconfig-generator/siteConfig/clusterCRsV1.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ metadata:
name: "{{ .Node.HostName }}"
namespace: "{{ .Cluster.ClusterName }}"
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
inspect.metal3.io: "{{ .Node.IronicInspect }}"
bmac.agent-install.openshift.io.node-label: "{{ .Node.NodeLabels }}"
bmac.agent-install.openshift.io/hostname: "{{ .Node.HostName }}"
Expand Down
2 changes: 1 addition & 1 deletion ztp/siteconfig-generator/siteConfig/clusterCRsV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ metadata:
name: "{{ .Node.HostName }}"
namespace: "{{ .Cluster.ClusterName }}"
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
inspect.metal3.io: "{{ .Node.IronicInspect }}"
bmac.agent-install.openshift.io.node-label: "{{ .Node.NodeLabels }}"
bmac.agent-install.openshift.io/hostname: "{{ .Node.HostName }}"
Expand Down
51 changes: 51 additions & 0 deletions ztp/siteconfig-generator/siteConfig/siteConfigBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2554,3 +2554,54 @@ func Test_siteConfigMap(t *testing.T) {
})
}
}

func Test_bmhWaveOrder(t *testing.T) {
// Test that BMH is deleted before dependencies.
ManagedCluster := `
apiVersion: ran.openshift.io/v1
kind: SiteConfig
metadata:
name: "test-site"
spec:
clusterImageSetNameRef: "openshift-v4.18.0"
clusters:
- clusterName: "cluster1"
clusterLabels:
group-du-sno: ""
common: true
sites : "test-site"
nodes:
- hostName: "node1"
nodeNetwork:
interfaces:
- name: "eno1"
macAddress: E4:43:4B:F6:12:E0
config:
interfaces:
- name: eno1
type: ethernet
state: up
`
sc := SiteConfig{}
err := yaml.Unmarshal([]byte(ManagedCluster), &sc)
assert.Equal(t, err, nil)

scBuilder, _ := NewSiteConfigBuilder()
scBuilder.SetLocalExtraManifestPath("testdata/extra-manifest")
result, err := scBuilder.Build(sc)

bmh, err := getKind(result["test-site/cluster1"], "BareMetalHost")
metadata := bmh["metadata"].(map[string]interface{})
annotations := metadata["annotations"].(map[string]interface{})
bmhWave := annotations["argocd.argoproj.io/sync-wave"]

infraenv, err := getKind(result["test-site/cluster1"], "InfraEnv")
metadata = infraenv["metadata"].(map[string]interface{})
annotations = metadata["annotations"].(map[string]interface{})
infraWave := annotations["argocd.argoproj.io/sync-wave"]

// The BMH must complete deletion prior to the infraenv,
// nmstateconfig, or namespace being deleted in order to complete
// cleanup. Ref OCPBUGS-42945
assert.Greater(t, bmhWave, infraWave)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: VERYVERYWRONG
namespace: "{{ .Cluster.ClusterName }}"
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
inspect.metal3.io: enabled
bmac.agent-install.openshift.io/hostname: "{{ .Node.HostName }}"
bmac.agent-install.openshift.io/installer-args: "{{ .Node.InstallerArgs }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: "{{ .Node.HostName }}"
namespace: ALSOVERYWRONG
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
inspect.metal3.io: enabled
bmac.agent-install.openshift.io/hostname: "{{ .Node.HostName }}"
bmac.agent-install.openshift.io/installer-args: "{{ .Node.InstallerArgs }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: "{{ .Node.HostName }}"
namespace: "{{ .Cluster.ClusterName }}"
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
inspect.metal3.io: enabled
bmac.agent-install.openshift.io/hostname: "{{ .Node.HostName }}"
bmac.agent-install.openshift.io/installer-args: "{{ .Node.InstallerArgs }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand All @@ -160,7 +160,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node2
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand All @@ -179,7 +179,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node3
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand All @@ -181,7 +181,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node2
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand All @@ -200,7 +200,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node3
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand All @@ -219,7 +219,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node4
bmac.agent-install.openshift.io/role: worker
ran.openshift.io/ztp-gitops-generated: '{}'
Expand All @@ -238,7 +238,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node5
bmac.agent-install.openshift.io/role: worker
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node1
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand All @@ -151,7 +151,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node2
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand All @@ -170,7 +170,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io/hostname: node3
bmac.agent-install.openshift.io/role: master
ran.openshift.io/ztp-gitops-generated: '{}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io.node-label.node-role.kubernetes.io/infra: ""
bmac.agent-install.openshift.io.node-label.node-role.kubernetes.io/master: ""
bmac.agent-install.openshift.io/hostname: node1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
annotations:
argocd.argoproj.io/sync-wave: "1"
argocd.argoproj.io/sync-wave: "3"
bmac.agent-install.openshift.io.node-label.node-role.kubernetes.io/infra: ""
bmac.agent-install.openshift.io.node-label.node-role.kubernetes.io/master: ""
bmac.agent-install.openshift.io/hostname: node1
Expand Down