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 #743 from fao89/nsconditions
Browse files Browse the repository at this point in the history
Update NodeSetConditions on error
  • Loading branch information
openshift-merge-bot[bot] authored Mar 11, 2024
2 parents ca8000b + 89b22e6 commit 684e436
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 21 deletions.
8 changes: 2 additions & 6 deletions api/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (

// ServiceReadyCondition Status=True condition indicates if the
// service is finished and successful.
ServiceReadyCondition string = "%s service ready"
ServiceReadyCondition condition.Type = "ServiceReady"

// ServiceReadyMessage ready
ServiceReadyMessage = "%s service ready"
Expand Down Expand Up @@ -87,7 +87,7 @@ const (

// NodeSetDeploymentReadyCondition Status=True condition indicates if the
// NodeSet Deployment is finished and successful.
NodeSetDeploymentReadyCondition string = "Deployment ready for NodeSet"
NodeSetDeploymentReadyCondition condition.Type = "NodeSetDeploymentReady"

// NodeSetDeploymentReadyMessage ready
NodeSetDeploymentReadyMessage = "Deployment ready for NodeSet"
Expand All @@ -98,10 +98,6 @@ const (
// NodeSetDeploymentErrorMessage error
NodeSetDeploymentErrorMessage = "Deployment error occurred %s for NodeSet"

// NodeSetServiceDeploymentReadyCondition Status=True condition indicates if the
// NodeSet Deployment is finished and successful.
NodeSetServiceDeploymentReadyCondition string = "%s Deployment ready"

// NodeSetServiceDeploymentReadyMessage ready
NodeSetServiceDeploymentReadyMessage = "%s Deployment ready"

Expand Down
5 changes: 3 additions & 2 deletions api/v1beta1/openstackdataplanedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ limitations under the License.
package v1beta1

import (
"encoding/json"
"encoding/json"

"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -126,7 +127,7 @@ func (instance *OpenStackDataPlaneDeployment) InitConditions() {
for _, nodeSet := range instance.Spec.NodeSets {
nsConds := condition.Conditions{}
nsConds.Set(condition.UnknownCondition(
condition.Type(NodeSetDeploymentReadyCondition), condition.InitReason, condition.InitReason))
NodeSetDeploymentReadyCondition, condition.InitReason, condition.InitReason))
instance.Status.NodeSetConditions[nodeSet] = nsConds

}
Expand Down
29 changes: 25 additions & 4 deletions controllers/openstackdataplanedeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.ReadyMessage)
shouldRequeue := false
haveError := false
deploymentErrMsg := ""

globalInventorySecrets := map[string]string{}
globalSSHKeySecrets := map[string]string{}
Expand Down Expand Up @@ -287,11 +288,26 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
deployResult, err = deployer.Deploy(nodeSet.Spec.Services)
}

nsConditions := instance.Status.NodeSetConditions[nodeSet.Name]

if err != nil {
util.LogErrorForObject(helper, err, fmt.Sprintf("OpenStackDeployment error for NodeSet %s", nodeSet.Name), instance)
Log.Info("Set NodeSetDeploymentReadyCondition false", "nodeSet", nodeSet.Name)
haveError = true
errMsg := fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, err.Error())
if len(deploymentErrMsg) == 0 {
deploymentErrMsg = errMsg
} else {
deploymentErrMsg = fmt.Sprintf("%s & %s", deploymentErrMsg, errMsg)
}
instance.Status.Conditions.MarkFalse(
condition.DeploymentReadyCondition,
dataplanev1.NodeSetDeploymentReadyCondition,
condition.ErrorReason,
condition.SeverityError,
dataplanev1.DataPlaneNodeSetErrorMessage,
errMsg)
nsConditions.MarkFalse(
dataplanev1.NodeSetDeploymentReadyCondition,
condition.ErrorReason,
condition.SeverityError,
condition.DeploymentReadyErrorMessage,
Expand All @@ -303,15 +319,20 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
} else {
Log.Info("OpenStackDeployment succeeded for NodeSet", "NodeSet", nodeSet.Name)
Log.Info("Set NodeSetDeploymentReadyCondition true", "nodeSet", nodeSet.Name)
nsConditions := instance.Status.NodeSetConditions[nodeSet.Name]
nsConditions.MarkTrue(
condition.Type(dataplanev1.NodeSetDeploymentReadyCondition),
dataplanev1.NodeSetDeploymentReadyCondition,
condition.DeploymentReadyMessage)
}
}

if haveError {
return ctrl.Result{}, err
instance.Status.Conditions.MarkFalse(
condition.DeploymentReadyCondition,
condition.ErrorReason,
condition.SeverityError,
condition.DeploymentReadyErrorMessage,
deploymentErrMsg)
return ctrl.Result{}, fmt.Errorf(deploymentErrMsg)
}

if shouldRequeue {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/cert-manager/cert-manager v1.13.4
github.com/go-logr/logr v1.4.1
github.com/google/uuid v1.6.0
github.com/iancoleman/strcase v0.3.0
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0
github.com/onsi/ginkgo/v2 v2.16.0
github.com/onsi/gomega v1.31.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 h1:2XF1Vzq06X+inNqgJ9
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down
3 changes: 2 additions & 1 deletion pkg/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"

"github.com/iancoleman/strcase"
dataplanev1 "github.com/openstack-k8s-operators/dataplane-operator/api/v1beta1"
dataplaneutil "github.com/openstack-k8s-operators/dataplane-operator/pkg/util"
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
Expand Down Expand Up @@ -71,7 +72,7 @@ func (d *Deployer) Deploy(services []string) (*ctrl.Result, error) {
return &ctrl.Result{}, err
}
deployName = foundService.Name
readyCondition = condition.Type(fmt.Sprintf(dataplanev1.NodeSetServiceDeploymentReadyCondition, service))
readyCondition = condition.Type(fmt.Sprintf("Service%sDeploymentReady", strcase.ToCamel(service)))
readyWaitingMessage = fmt.Sprintf(dataplanev1.NodeSetServiceDeploymentReadyWaitingMessage, deployName)
readyMessage = fmt.Sprintf(dataplanev1.NodeSetServiceDeploymentReadyMessage, deployName)
readyErrorMessage = fmt.Sprintf(dataplanev1.NodeSetServiceDeploymentErrorMessage, deployName)
Expand Down
116 changes: 108 additions & 8 deletions tests/kuttl/tests/dataplane-deploy-no-nodes-test/05-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,97 @@ status:
type: SetupReady
configMapHashes:
ovncontroller-config: n56h54bh9bhcbh65ch9fhdh66dh95h5dch569h678h7fh599h7ch84h597h59h54dh58dhf6h66bh565h4hc4h587h645hd7hcch5d8h5f4h55cq
deploymentStatuses:
edpm-compute-no-nodes:
- message: Deployment completed
reason: Ready
status: "True"
type: NodeSetDeploymentReady
- message: bootstrap Deployment ready
reason: Ready
status: "True"
type: ServiceBootstrapDeploymentReady
- message: configure-network Deployment ready
reason: Ready
status: "True"
type: ServiceConfigureNetworkDeploymentReady
- message: configure-os Deployment ready
reason: Ready
status: "True"
type: ServiceConfigureOsDeploymentReady
- message: download-cache Deployment ready
reason: Ready
status: "True"
type: ServiceDownloadCacheDeploymentReady
- message: install-certs Deployment ready
reason: Ready
status: "True"
type: ServiceInstallCertsDeploymentReady
- message: install-os Deployment ready
reason: Ready
status: "True"
type: ServiceInstallOsDeploymentReady
- message: libvirt Deployment ready
reason: Ready
status: "True"
type: ServiceLibvirtDeploymentReady
- message: neutron-dhcp Deployment ready
reason: Ready
status: "True"
type: ServiceNeutronDhcpDeploymentReady
- message: neutron-metadata Deployment ready
reason: Ready
status: "True"
type: ServiceNeutronMetadataDeploymentReady
- message: neutron-ovn Deployment ready
reason: Ready
status: "True"
type: ServiceNeutronOvnDeploymentReady
- message: neutron-sriov Deployment ready
reason: Ready
status: "True"
type: ServiceNeutronSriovDeploymentReady
- message: nova Deployment ready
reason: Ready
status: "True"
type: ServiceNovaDeploymentReady
- message: ovn Deployment ready
reason: Ready
status: "True"
type: ServiceOvnDeploymentReady
- message: run-os Deployment ready
reason: Ready
status: "True"
type: ServiceRunOsDeploymentReady
- message: validate-network Deployment ready
reason: Ready
status: "True"
type: ServiceValidateNetworkDeploymentReady
edpm-compute-no-nodes-non-existent-service:
- message: Deployment error occurred OpenStackDataPlaneService.dataplane.openstack.org
"this-service-does-not-exist" not found
reason: Error
severity: Error
status: "False"
type: NodeSetDeploymentReady
edpm-compute-no-nodes-services-override:
- message: Deployment completed
reason: Ready
status: "True"
type: NodeSetDeploymentReady
- message: custom-service-override Deployment ready
reason: Ready
status: "True"
type: ServiceCustomServiceOverrideDeploymentReady
edpm-compute-no-nodes-updated-ovn-cm:
- message: Deployment completed
reason: Ready
status: "True"
type: NodeSetDeploymentReady
- message: ovn Deployment ready
reason: Ready
status: "True"
type: ServiceOvnDeploymentReady
secretHashes:
neutron-dhcp-agent-neutron-config: n68h676h98h689hd4h575h5dbh694h6fh688h57h665h5c5h56dh5ddh65bh5d7h5cdh644hb8h8fh5d9h5b9h555h9ch56dh5fh6chd4h5c5h5c5h68q
neutron-ovn-agent-neutron-config: n5f4h89hb8h645h55bh657h9fh5d9h5c6h595h9dh667h5f4hfhffh7fh685h56ch57fh679h5ddh5ddh95h696hbch5c7h669h84h54dh685hfh85q
Expand All @@ -67,14 +158,14 @@ spec:
- this-service-does-not-exist
status:
conditions:
- message: Deployment error occurred OpenStackDataPlaneService.dataplane.openstack.org
"this-service-does-not-exist" not found
- message: 'Deployment error occurred nodeSet: edpm-compute-no-nodes error: OpenStackDataPlaneService.dataplane.openstack.org
"this-service-does-not-exist" not found'
reason: Error
severity: Error
status: "False"
type: Ready
- message: Deployment error occurred OpenStackDataPlaneService.dataplane.openstack.org
"this-service-does-not-exist" not found
- message: 'Deployment error occurred nodeSet: edpm-compute-no-nodes error: OpenStackDataPlaneService.dataplane.openstack.org
"this-service-does-not-exist" not found'
reason: Error
severity: Error
status: "False"
Expand All @@ -83,9 +174,18 @@ status:
reason: Ready
status: "True"
type: InputReady
- message: 'DataPlaneNodeSet error occurred nodeSet: edpm-compute-no-nodes error:
OpenStackDataPlaneService.dataplane.openstack.org "this-service-does-not-exist"
not found'
reason: Error
severity: Error
status: "False"
type: NodeSetDeploymentReady
nodeSetConditions:
edpm-compute-no-nodes:
- message: Init
reason: Init
status: Unknown
type: Deployment ready for NodeSet
- message: Deployment error occurred OpenStackDataPlaneService.dataplane.openstack.org
"this-service-does-not-exist" not found
reason: Error
severity: Error
status: "False"
type: NodeSetDeploymentReady

0 comments on commit 684e436

Please sign in to comment.