Skip to content

Commit

Permalink
NodeReload controller was refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan Siryk authored and Bohdan Siryk committed Oct 10, 2023
1 parent e2401e3 commit 2c6f78a
Show file tree
Hide file tree
Showing 11 changed files with 442 additions and 132 deletions.
24 changes: 4 additions & 20 deletions apis/clusterresources/v1beta1/nodereload_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/instaclustr/operator/pkg/models"
)

// NodeReloadSpec defines the desired state of NodeReload
Expand All @@ -30,8 +28,11 @@ type NodeReloadSpec struct {

// NodeReloadStatus defines the observed state of NodeReload
type NodeReloadStatus struct {
NodeInProgress Node `json:"nodeInProgress,omitempty"`
NodeInProgress *Node `json:"nodeInProgress,omitempty"`
CurrentOperationStatus *Operation `json:"currentOperationStatus,omitempty"`
PendingNodes []*Node `json:"pendingNodes,omitempty"`
CompletedNodes []*Node `json:"completedNodes,omitempty"`
FailedNodes []*Node `json:"failedNodes,omitempty"`
}

type Node struct {
Expand Down Expand Up @@ -75,20 +76,3 @@ func (nr *NodeReload) NewPatch() client.Patch {
func init() {
SchemeBuilder.Register(&NodeReload{}, &NodeReloadList{})
}

func (nr *NodeReloadStatus) FromInstAPI(status *models.NodeReloadStatus) *NodeReloadStatus {
var nrStatus = &NodeReloadStatus{
NodeInProgress: Node{
ID: status.NodeID,
},
CurrentOperationStatus: &Operation{
OperationID: status.OperationID,
TimeCreated: status.TimeCreated,
TimeModified: status.TimeModified,
Status: status.Status,
Message: status.Message,
},
}

return nrStatus
}
39 changes: 38 additions & 1 deletion apis/clusterresources/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions config/crd/bases/clusterresources.instaclustr.com_nodereloads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ spec:
status:
description: NodeReloadStatus defines the observed state of NodeReload
properties:
completedNodes:
items:
properties:
nodeID:
type: string
required:
- nodeID
type: object
type: array
currentOperationStatus:
properties:
message:
Expand All @@ -68,13 +77,31 @@ spec:
- timeCreated
- timeModified
type: object
failedNodes:
items:
properties:
nodeID:
type: string
required:
- nodeID
type: object
type: array
nodeInProgress:
properties:
nodeID:
type: string
required:
- nodeID
type: object
pendingNodes:
items:
properties:
nodeID:
type: string
required:
- nodeID
type: object
type: array
type: object
type: object
served: true
Expand Down
Loading

0 comments on commit 2c6f78a

Please sign in to comment.