diff --git a/status/status.go b/status/status.go index e4a5a076..acf6c7c9 100644 --- a/status/status.go +++ b/status/status.go @@ -5,10 +5,17 @@ import ( "time" + "encoding/json" + "github.com/rancher/norman/types/convert" "github.com/rancher/norman/types/values" + "github.com/sirupsen/logrus" ) +type status struct { + Conditions []condition `json:"conditions"` +} + type condition struct { Type string Status string @@ -44,6 +51,7 @@ var transitioningMap = map[string]string{ "Saved": "saving", "Updated": "updating", "Updating": "updating", + "InitialRolesPopulated": "activating", } // True == error @@ -93,6 +101,21 @@ func Set(data map[string]interface{}) { var conditions []condition convert.ToObj(val, &conditions) + statusAnn, annOK := values.GetValue(data, "metadata", "annotations", "cattle.io/status") + if annOK { + status := &status{} + s, ok := statusAnn.(string) + if ok { + err := json.Unmarshal([]byte(s), status) + if err != nil { + logrus.Warnf("Unable to unmarshal cattle status %v. Error: %v", s, err) + } + } + if len(status.Conditions) > 0 { + conditions = append(conditions, status.Conditions...) + } + } + val, ok := values.GetValue(data, "metadata", "removed") if ok && val != "" && val != nil { data["state"] = "removing"