forked from metal3-io/ironic-standalone-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request metal3-io#70 from dtantsur/status
✨ Rework reporting status to the controller
- Loading branch information
Showing
9 changed files
with
147 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ironic | ||
|
||
type Status struct { | ||
// Object is reconciled but some resources may be in progress. | ||
Reconciled bool | ||
// Object is reconciled and all resources are ready. | ||
Ready bool | ||
// Fatal error, further reconciliation is not possible. | ||
Fatal error | ||
} | ||
|
||
func (status Status) IsError() bool { | ||
return status.Fatal != nil | ||
} | ||
|
||
func (status Status) IsReady() bool { | ||
return status.Ready && !status.IsError() | ||
} | ||
|
||
func (status Status) String() string { | ||
if status.Fatal != nil { | ||
return status.Fatal.Error() | ||
} | ||
|
||
if !status.Reconciled { | ||
return "resources are being updated" | ||
} | ||
|
||
if !status.Ready { | ||
return "resources are not ready yet" | ||
} | ||
|
||
return "resources are available" | ||
} | ||
|
||
// Everything is done, no more reconciliation required. | ||
func ready() (Status, error) { | ||
return Status{Reconciled: true, Ready: true}, nil | ||
} | ||
|
||
// We have updated dependent resources. | ||
func updated() (Status, error) { | ||
return Status{}, nil | ||
} | ||
|
||
// We are passively waiting for something external to happen. | ||
func inProgress() (Status, error) { | ||
return Status{Reconciled: true}, nil | ||
} | ||
|
||
// Checking or updating status failed, we hope it's going to resolve itself | ||
// (e.g. a glitch in access to Kube API). | ||
func transientError(err error) (Status, error) { | ||
return Status{}, err | ||
} |
Oops, something went wrong.