Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #839 from fao89/nsupdhook
Browse files Browse the repository at this point in the history
Validate if deployment is running while updating a nodeset
  • Loading branch information
openshift-merge-bot[bot] authored Apr 23, 2024
2 parents e73530c + dbdfa4b commit 451f7f6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions api/v1beta1/openstackdataplanenodeset_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strings"

"github.com/go-playground/validator/v10"
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
baremetalv1 "github.com/openstack-k8s-operators/openstack-baremetal-operator/api/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -174,6 +175,19 @@ func (r *OpenStackDataPlaneNodeSet) ValidateUpdate(old runtime.Object) (admissio
r.Name,
errors,
)

}
if oldNodeSet.Status.DeploymentStatuses != nil {
for _, deployConditions := range oldNodeSet.Status.DeploymentStatuses {
deployCondition := deployConditions.Get(condition.ReadyCondition)
if !deployConditions.IsTrue(condition.ReadyCondition) && !condition.IsError(deployCondition) {
return nil, apierrors.NewConflict(
schema.GroupResource{Group: "dataplane.openstack.org", Resource: "OpenStackDataPlaneNodeSet"},
r.Name,
fmt.Errorf("could not patch openstackdataplanenodeset while openstackdataplanedeployment is running"),
)
}
}
}

return nil, nil
Expand Down

0 comments on commit 451f7f6

Please sign in to comment.