Skip to content

Commit

Permalink
Fix job.bmc creation and deletion:
Browse files Browse the repository at this point in the history
Use status' to make sure creation and
deletion work properly.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Sep 19, 2024
1 parent 4ebc9e5 commit b3b089f
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 128 deletions.
16 changes: 15 additions & 1 deletion api/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
WorkflowStateTimeout = WorkflowState("STATE_TIMEOUT")
WorkflowStateSuccess = WorkflowState("STATE_SUCCESS")
WorkflowStatePreparing = WorkflowState("STATE_PREPARING")
StatusSuccess = "success"
StatusFailure = "failure"
)

// WorkflowSpec defines the desired state of Workflow.
Expand Down Expand Up @@ -64,7 +66,12 @@ type WorkflowStatus struct {
ToggleHardware *Status `json:"toggleHardware,omitempty"`

// OneTimeNetboot indicates whether the controller has successfully netbooted the associated hardware.
OneTimeNetboot *Status `json:"oneTimeNetboot,omitempty"`
OneTimeNetboot OneTimeNetbootStatus `json:"oneTimeNetboot,omitempty"`
}

type OneTimeNetbootStatus struct {
CreationStatus *Status `json:"creationStatus,omitempty"`
DeletionStatus *Status `json:"deletionStatus,omitempty"`
}

// Wanted to use metav1.Status but kubebuilder errors with, "must apply listType to an array, found".
Expand Down Expand Up @@ -92,6 +99,13 @@ type Status struct {
// Details *metav1.StatusDetails `json:"details,omitempty" protobuf:"bytes,5,opt,name=details"`
}

func (s *Status) IsSuccess() bool {
if s == nil {
return false

Check warning on line 104 in api/v1alpha1/workflow_types.go

View check run for this annotation

Codecov / codecov/patch

api/v1alpha1/workflow_types.go#L102-L104

Added lines #L102 - L104 were not covered by tests
}
return s.Status == StatusSuccess

Check warning on line 106 in api/v1alpha1/workflow_types.go

View check run for this annotation

Codecov / codecov/patch

api/v1alpha1/workflow_types.go#L106

Added line #L106 was not covered by tests
}

// Task represents a series of actions to be completed by a worker.
type Task struct {
Name string `json:"name"`
Expand Down
31 changes: 26 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

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

56 changes: 40 additions & 16 deletions config/crd/bases/tinkerbell.org_workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,46 @@ spec:
oneTimeNetboot:
description: OneTimeNetboot indicates whether the controller has successfully netbooted the associated hardware.
properties:
message:
description: A human-readable description of the status of this operation.
type: string
reason:
description: |-
A machine-readable description of why this operation is in the
"Failure" status. If this value is empty there
is no information available. A Reason clarifies an HTTP status
code but does not override it.
type: string
status:
description: |-
Status of the operation.
One of: "Success" or "Failure".
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
type: string
creationStatus:
description: Wanted to use metav1.Status but kubebuilder errors with, "must apply listType to an array, found".
properties:
message:
description: A human-readable description of the status of this operation.
type: string
reason:
description: |-
A machine-readable description of why this operation is in the
"Failure" status. If this value is empty there
is no information available. A Reason clarifies an HTTP status
code but does not override it.
type: string
status:
description: |-
Status of the operation.
One of: "Success" or "Failure".
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
type: string
type: object
deletionStatus:
description: Wanted to use metav1.Status but kubebuilder errors with, "must apply listType to an array, found".
properties:
message:
description: A human-readable description of the status of this operation.
type: string
reason:
description: |-
A machine-readable description of why this operation is in the
"Failure" status. If this value is empty there
is no information available. A Reason clarifies an HTTP status
code but does not override it.
type: string
status:
description: |-
Status of the operation.
One of: "Success" or "Failure".
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
type: string
type: object
type: object
state:
description: State is the state of the workflow in Tinkerbell.
Expand Down
Loading

0 comments on commit b3b089f

Please sign in to comment.