Skip to content
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
7 changes: 7 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ rules:
- list
- patch
- watch
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- apiGroups:
- admissionregistration.k8s.io
resources:
Expand Down
1 change: 1 addition & 0 deletions controllers/provisioning_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type ensureFunc func(*provisioning.ProvisioningInfo) (bool, error)
// +kubebuilder:rbac:groups=config.openshift.io,resources=clusteroperators;clusteroperators/status,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=config.openshift.io,resources=infrastructures;infrastructures/status,verbs=get
// +kubebuilder:rbac:groups="",resources=events,verbs=create;watch;list;patch
// +kubebuilder:rbac:groups="",resources=pods,verbs=list;get
// +kubebuilder:rbac:groups="",resources=configmaps;secrets;services,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apps,resources=deployments;daemonsets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=metal3.io,resources=provisionings;provisionings/finalizers,verbs=get;list;watch;create;update;patch;delete
Expand Down
7 changes: 7 additions & 0 deletions manifests/0000_31_cluster-baremetal-operator_05_rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ rules:
- list
- patch
- watch
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- apiGroups:
- admissionregistration.k8s.io
resources:
Expand Down
29 changes: 22 additions & 7 deletions provisioning/baremetal_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1063,16 +1063,31 @@ func DeleteMetal3Deployment(info *ProvisioningInfo) error {
}

func getPodHostIP(podClient coreclientv1.PodsGetter, targetNamespace string) (string, error) {
labelSelector := &metav1.LabelSelector{
MatchLabels: map[string]string{
"k8s-app": metal3AppName,
cboLabelName: stateService,
}}

selector, err := metav1.LabelSelectorAsSelector(labelSelector)
if err != nil {
return "", err
}

listOptions := metav1.ListOptions{
LabelSelector: metal3AppName,
FieldSelector: "status.hostIP",
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 removed this because it failed with;

 invalid selector: 'status.hostIP'; can't understand 'status.hostIP'" "name"="provisioning-configuration"

Maybe it is because of lack of get permission but I did this change for a quick fix

Copy link
Contributor

Choose a reason for hiding this comment

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

As an additional safety measure, can you please also verify that len(podList.Items) == 1 instead of > 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think for the latest version @andfasano ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, it seems ok, let's see the virtualmedia job

LabelSelector: selector.String(),
}

podList, err := podClient.Pods(targetNamespace).List(context.Background(), listOptions)
if err == nil && len(podList.Items) > 0 {
// We expect only one pod with the above LabelSelector
hostIP := podList.Items[0].Status.HostIP
return hostIP, err
if err != nil {
return "", err
}

// We expect only one pod with the above LabelSelector
if len(podList.Items) != 1 {
return "", fmt.Errorf("there should be only one pod listed for the given label")
}
return "", err

hostIP := podList.Items[0].Status.HostIP
return hostIP, err
}