diff --git a/config/context.go b/config/context.go index e7517094..36bd5d41 100644 --- a/config/context.go +++ b/config/context.go @@ -18,6 +18,7 @@ import ( ) type ManagementContext struct { + LocalConfig *rest.Config RESTConfig rest.Config UnversionedClient rest.Interface @@ -92,14 +93,14 @@ func (c *ManagementContext) StartAndWait() error { return ctx.Err() } -func NewClusterContext(clusterConfig, config rest.Config, clusterName string) (*ClusterContext, error) { +func NewClusterContext(managementConfig, config rest.Config, clusterName string) (*ClusterContext, error) { var err error context := &ClusterContext{ RESTConfig: config, ClusterName: clusterName, } - context.Management, err = NewManagementContext(clusterConfig) + context.Management, err = NewManagementContext(managementConfig) if err != nil { return nil, err } @@ -155,8 +156,8 @@ func (w *ClusterContext) Start(ctx context.Context) error { return controller.SyncThenSync(ctx, 5, controllers...) } -func (w *ClusterContext) StartAndWait() error { - ctx := signal.SigTermCancelContext(context.Background()) +func (w *ClusterContext) StartAndWait(ctx context.Context) error { + ctx = signal.SigTermCancelContext(ctx) w.Start(ctx) <-ctx.Done() return ctx.Err() diff --git a/status/status.go b/status/status.go index 5f1ba6b9..b7d0c0db 100644 --- a/status/status.go +++ b/status/status.go @@ -29,26 +29,27 @@ var conditionMappings = []conditionMapping{ Transition: true, State: "initializing", }, - { - Name: "Ready", - Transition: true, - State: "activating", - }, { Name: "Available", Transition: true, State: "activating", }, - { - Name: "Updating", - Transition: true, - FalseIsGood: true, - }, { Name: "Progressing", Transition: true, State: "updating", }, + { + Name: "Provisioned", + Transition: true, + State: "provisioning", + }, + { + Name: "Updating", + Transition: true, + FalseIsGood: true, + State: "updating", + }, { Name: "ConfigOK", Transition: true, @@ -84,8 +85,14 @@ var conditionMappings = []conditionMapping{ FalseIsGood: true, }, { - Name: "NetworkUnavailable", - Error: true, + Name: "NetworkUnavailable", + FalseIsGood: true, + Error: true, + }, + { + Name: "KernelHasNoDeadlock", + FalseIsGood: true, + Error: true, }, { Name: "Unschedulable", @@ -97,6 +104,11 @@ var conditionMappings = []conditionMapping{ Error: true, FalseIsGood: true, }, + { + Name: "Ready", + Transition: true, + State: "activating", + }, } func Set(data map[string]interface{}) { @@ -120,6 +132,15 @@ func Set(data map[string]interface{}) { val, ok = values.GetValue(data, "status", "conditions") if !ok || val == nil { + if val, ok := values.GetValue(data, "metadata", "created"); ok { + if i, err := convert.ToTimestamp(val); err == nil { + if time.Unix(i/1000, 0).Add(5 * time.Second).Before(time.Now()) { + data["state"] = "active" + return + } + } + } + data["state"] = "initializing" data["transitioning"] = "yes" return @@ -155,6 +176,8 @@ func Set(data map[string]interface{}) { good = false } else if !conditionMapping.FalseIsGood && condition.Status == "False" { good = false + } else if conditionMapping.Transition && !conditionMapping.FalseIsGood && condition.Status == "Unknown" { + good = false } if !good && conditionMapping.Transition {