Skip to content

Commit

Permalink
Cluster status
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Mar 31, 2018
1 parent da232d3 commit 0d8a522
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
20 changes: 12 additions & 8 deletions apis/management.cattle.io/v3/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ import (
"github.com/rancher/norman/types"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/version"
)

type ClusterConditionType string

const (
// ClusterConditionReady Cluster ready to serve API (healthy when true, unhealthy when false)
ClusterConditionReady condition.Cond = "Ready"
ClusterConditionPending condition.Cond = "Pending"
// ClusterConditionProvisioned Cluster is provisioned
ClusterConditionProvisioned condition.Cond = "Provisioned"
ClusterConditionUpdated condition.Cond = "Updated"
ClusterConditionWaiting condition.Cond = "Waiting"
ClusterConditionRemoved condition.Cond = "Removed"
ClusterConditionReady condition.Cond = "Ready"
ClusterConditionPending condition.Cond = "Pending"
ClusterConditionCertsGenerated condition.Cond = "CertsGenerated"
ClusterConditionEtcd condition.Cond = "etcd"
ClusterConditionProvisioned condition.Cond = "Provisioned"
ClusterConditionUpdated condition.Cond = "Updated"
ClusterConditionWaiting condition.Cond = "Waiting"
ClusterConditionRemoved condition.Cond = "Removed"
// ClusterConditionNoDiskPressure true when all cluster nodes have sufficient disk
ClusterConditionNoDiskPressure condition.Cond = "NoDiskPressure"
// ClusterConditionNoMemoryPressure true when all cluster nodes have sufficient memory
Expand Down Expand Up @@ -80,11 +82,13 @@ type ClusterStatus struct {
CACert string `json:"caCert,omitempty"`
Capacity v1.ResourceList `json:"capacity,omitempty"`
Allocatable v1.ResourceList `json:"allocatable,omitempty"`
AppliedSpec ClusterSpec `json:"appliedSpec,omitempty"`
AppliedSpec *ClusterSpec `json:"appliedSpec,omitempty"`
AppliedEtcdSpec *ClusterSpec `json:"appliedEtcdSpec,omitempty"`
FailedSpec *ClusterSpec `json:"failedSpec,omitempty"`
Requested v1.ResourceList `json:"requested,omitempty"`
Limits v1.ResourceList `json:"limits,omitempty"`
ClusterName string `json:"clusterName,omitempty"`
Version *version.Info `json:"version,omitempty"`
AppliedPodSecurityPolicyTemplateName string `json:"appliedPodSecurityPolicyTemplateId"`
}

Expand Down
1 change: 0 additions & 1 deletion apis/management.cattle.io/v3/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas {
).
AddMapperForType(&Version, v3.ClusterStatus{},
m.Drop{Field: "serviceAccountToken"},
m.Drop{Field: "appliedSpec"},
m.Drop{Field: "clusterName"},
).
AddMapperForType(&Version, v3.ClusterEvent{}, &m.Move{
Expand Down
2 changes: 1 addition & 1 deletion mapper/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (c *Creator) ToInternal(data map[string]interface{}) {
}

func (c *Creator) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
if schema.CanList(nil) && schema.CanCreate(nil) {
if schema.CanList(nil) == nil && schema.CanCreate(nil) == nil {
schema.ResourceFields["creatorId"] = types.Field{
Type: "reference[/v3/schemas/user]",
CodeName: "CreatorID",
Expand Down
8 changes: 5 additions & 3 deletions status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ type condition struct {
// Unknown == transitioning
var transitioningMap = map[string]string{
"Active": "activating",
"AddonDeploy": "deploying",
"AgentDeployed": "installing",
"AddonDeploy": "provisioning",
"AgentDeployed": "provisioning",
"BackingNamespaceCreated": "configuring",
"CertsGenerated": "provisioning",
"ConfigOK": "configuring",
"Created": "creating",
"CreatorMadeOwner": "configuring",
Expand All @@ -38,6 +39,7 @@ var transitioningMap = map[string]string{
"DefaultProjectCreated": "configuring",
"DockerProvisioned": "provisioning",
"Downloaded": "downloading",
"etcd": "provisioning",
"Inactive": "deactivating",
"Initialized": "initializing",
"Installed": "installing",
Expand Down Expand Up @@ -96,7 +98,7 @@ func concat(str, next string) string {
if next == "" {
return str
}
return str + ", " + next
return str + "; " + next
}

func Set(data map[string]interface{}) {
Expand Down

0 comments on commit 0d8a522

Please sign in to comment.