...

Source file src/edge-infra.dev/pkg/edge/api/status/status.go

Documentation: edge-infra.dev/pkg/edge/api/status

     1  package status
     2  
     3  import "fmt"
     4  
     5  const (
     6  	// Registered is the status returned when the cluster is not bootstrapped
     7  	// and Edge Manifests have not been applied.
     8  	Registered = "Registered"
     9  	// Ready is the status returned when the cluster is bootstrapped,
    10  	// kustomization is ready, shipment is ready, and bucket is ready.
    11  	Ready = "Ready"
    12  	// Installing is the status returned when the cluster is bootstrapped,
    13  	// but no Ready status condition exists for either the kustomization, shipment, or/and bucket
    14  	// and no error exists for either too.
    15  	Installing = "Installing"
    16  	// Error is the status returned when the cluster is bootstrapped,
    17  	// but the Ready status condition is False for either the kustomization, shipment, or/and bucket
    18  	// or/and an error exists for any.
    19  	Error = "Error"
    20  	// AwaitingInstallation is the status returned when the terminal's activation code is not consumed.
    21  	AwaitingInstallation = "Awaiting Installation"
    22  	// Disconnected is the status returned when the terminal's node status is Unknown.
    23  	Disconnected = "Disconnected"
    24  	// NotAvailable  is the status returned when the resource's status is not available.
    25  	NotAvailable = "N/A"
    26  	// Running is the status returned when the helm pod is working without error
    27  	Running = "Running"
    28  
    29  	// RegisteredMessage is the status message returned when the status is Registered.
    30  	RegisteredMessage = "Registered but Edge is not installed"
    31  	// ReadyMessage is the status message returned when the status is Ready.
    32  	ReadyMessage = "Cluster is ready"
    33  	// InstallingMessage is the status message returned when the status is Installing.
    34  	InstallingMessage = "Waiting for installation to complete"
    35  	// NotReportedFormat is the status message format for missing or not reported statuses.
    36  	NotReportedFormat = "Waiting for"
    37  	// UnusedActivationCodeMessage is the status message returned when the status is Awaiting Installation.
    38  	UnusedActivationCodeMessage = "Activation code not consumed"
    39  	// DisconnectedMessage is the status message returned when the status is Disconnected.
    40  	DisconnectedMessage = "Node is disconnected or turned off"
    41  	// NodeReadyMessage is the status message returned when the status is Ready.
    42  	NodeReadyMessage = "Node Ready"
    43  	// NotAvailableMessage is the status message returned when the status is N/A.
    44  	NotAvailableMessage = "Status for node missing"
    45  	// Unknown to support Kubernetes Node Unknown status returned in some cases.
    46  	Unknown = "UNKNOWN"
    47  
    48  	// IsReady ready status string for a resource.
    49  	IsReady = "True"
    50  	// NotReady not ready status string for a resource.
    51  	NotReady = "False"
    52  	// KindReadyMessage ready status message for individual kind resource.
    53  	KindReadyMessage = "%s is ready"
    54  	// NotAvailableStatusMessage is the status message returned when the status is N/A.
    55  	NotAvailableStatusMessage = "Status not available"
    56  	// Deleting status string for when a workload is marked as deleted
    57  	Deleting = "Deleting"
    58  	// DeletingStatusMessage is the status message returned when a workload is pending deletion by the clusterctl.
    59  	DeletingStatusMessage = "Workload is being deleted"
    60  	// Updating
    61  	Updating = "Updating"
    62  	// UpdatingStatusMessage
    63  	UpdatingStatusMessage = "Workload is updating"
    64  	// InstallingStatusMessage
    65  	InstallingStatusMessage = "Workload is installing"
    66  	// WorkloadReadyStatusMessage
    67  	WorkloadReadyStatusMessage = "Workload is installed and healthy"
    68  	// Supported denotes that the cluster's version (infra or edge os) is supported
    69  	Supported = "VersionSupported"
    70  	// ErrGettingVersion returns an error if there is no active fleet version or terminal versions associated with the cluster
    71  	ErrGettingVersion = "ErrGettingVersion"
    72  	// ClusterInfraOutOfSupport indicates that a cluster's infra version is out of support
    73  	ClusterOutOfSupport = "OutOfSupport"
    74  	// ClusterInfraNearingEndOfSupport indicates that a cluster's infra version will be out of support in the next release
    75  	ClusterNearingEndOfSupport = "NearingEndOfSupport"
    76  	// NoActiveVersion indicates that a cluster does not have an associated active Edge Infra version
    77  	NoActiveVersion = "Cluster has no active version"
    78  	// NoTerminalVersion indicates that a cluster registered as dsds does not have any EdgeOS versions associated with it
    79  	NoTerminalVersion = "Cluster is registered as dsds but has no terminal versions associated with it"
    80  	// NotDeployedStatusMessage is the status message returned when a workload has
    81  	// not been deployed and is not in the process of being deployed.
    82  	NotDeployedStatusMessage = "Workload not deployed"
    83  )
    84  
    85  // IsNotReported checks to see if the kind exists and if the status is not reported.
    86  func IsNotReported(kind string, notReportedElem map[string]bool) bool {
    87  	notReportedValue, exists := notReportedElem[kind]
    88  	return exists && notReportedValue
    89  }
    90  
    91  // MergeErrorMessages merges a slice of status error messages into a comma separated list.
    92  func MergeErrorMessages(errors []string) string {
    93  	errMessage := ""
    94  	for idx, err := range errors {
    95  		switch {
    96  		case idx == 0:
    97  			errMessage = err
    98  		case idx < len(errors)-1:
    99  			errMessage = fmt.Sprintf("%s, %s", errMessage, err)
   100  		case idx == len(errors)-1:
   101  			conjunction := ", and"
   102  			if len(errors) == 2 {
   103  				conjunction = " and"
   104  			}
   105  			errMessage = fmt.Sprintf("%s%s %s", errMessage, conjunction, err)
   106  		}
   107  	}
   108  	return errMessage
   109  }
   110  

View as plain text