-
Notifications
You must be signed in to change notification settings - Fork 607
Improve observability of API statuses #2368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 41 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
6485723
Limit istiod to 5 replicas and the default namespace
RobertLucian 9e5dfaf
Move prometheus exporters and fluent bit to their dedicated namespace
RobertLucian 060ebb9
Change the HPA's targets a bit
RobertLucian d65fafc
Redirect kubectl's output to /dev/null
RobertLucian 4b96c20
Add logging namespace
RobertLucian 0677208
Remove unnecessary namespace
RobertLucian bbcf4e3
Fixes
RobertLucian da66f7f
Refactoring a bit
RobertLucian 56554fb
Fixes
RobertLucian 77dc2e9
More refactoring
RobertLucian 50249d8
Event exporter must be in logging namespace
RobertLucian 23918df
Use consts where possible
RobertLucian a287457
Have all namespaces in a single yaml & revert temporary change
RobertLucian 34045d4
Patch instead of applying the default namespace
RobertLucian 7c13445
Merge branch 'master' into fix/istiod-oom
RobertLucian b24dff9
Fix waiting on the load balancer stage
RobertLucian 6c9421d
More namespace fixes
RobertLucian 7718df5
Merge branch 'master' into fix/istiod-oom
RobertLucian 4f4daef
Create additional-scrape-configs in prometheus ns
RobertLucian 2d572aa
Prometheus' service must be in prometheus ns
RobertLucian fde6ab0
Fix cortex cluster health cmd panicking
RobertLucian 4c6b670
Fix getPodMemorySaturation function instead
RobertLucian 042b2b3
Report live (x/y) and up-to-date replicas
RobertLucian dd50f2b
WIP on upgrading the statuses
RobertLucian 5618e96
Merge branch 'master' into feature/better-api-statuses
RobertLucian 4f9dc7c
WIP on API statuses
RobertLucian 4cde8f4
WIP on API statuses
RobertLucian d7ca13f
WIP on API statuses
RobertLucian 34dc5a3
Changes to the TrafficSplitter
RobertLucian 51606a7
WIP on API statuses
RobertLucian fb15122
Fixes
RobertLucian 943621a
Merge branch 'master' into feature/better-api-statuses
RobertLucian c5b0e73
Fix terminating status
RobertLucian 8edee7a
Fix the worker counts for the batch jobs
RobertLucian a0ec6df
Output type (yaml) fixes
RobertLucian e2b6404
Fix
RobertLucian f2bc8bb
Update docs
RobertLucian af364a6
Address PR comments
RobertLucian 12e3121
Merge branch 'master' into feature/better-api-statuses
RobertLucian f891aa3
Docs updates
RobertLucian 121a669
Update statuses.md
deliahu c337f29
Update statuses.md
deliahu 70a6132
Update statuses.md
deliahu 4e0dc14
Update statuses.md
deliahu ce6a89f
Address PR comments
RobertLucian 50f6304
Merge branch 'master' into feature/better-api-statuses
RobertLucian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,113 @@ | ||
/* | ||
Copyright 2021 Cortex Labs, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cortexlabs/cortex/cli/cluster" | ||
"github.com/cortexlabs/cortex/cli/types/cliconfig" | ||
"github.com/cortexlabs/cortex/pkg/lib/errors" | ||
"github.com/cortexlabs/cortex/pkg/lib/exit" | ||
"github.com/cortexlabs/cortex/pkg/lib/telemetry" | ||
"github.com/cortexlabs/cortex/pkg/types/userconfig" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const ( | ||
_titleReplicaStatus = "replica status" | ||
_titleReplicaCount = "replica count" | ||
) | ||
|
||
var ( | ||
_flagDescribeEnv string | ||
_flagDescribeWatch bool | ||
) | ||
|
||
func describeInit() { | ||
_describeCmd.Flags().SortFlags = false | ||
_describeCmd.Flags().StringVarP(&_flagDescribeEnv, "env", "e", "", "environment to use") | ||
_describeCmd.Flags().BoolVarP(&_flagDescribeWatch, "watch", "w", false, "re-run the command every 2 seconds") | ||
} | ||
|
||
var _describeCmd = &cobra.Command{ | ||
Use: "describe [API_NAME]", | ||
Short: "describe an api", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
apiName := args[0] | ||
|
||
var envName string | ||
if wasFlagProvided(cmd, "env") { | ||
envName = _flagDescribeEnv | ||
} else { | ||
var err error | ||
envName, err = getEnvFromFlag("") | ||
if err != nil { | ||
telemetry.Event("cli.describe") | ||
exit.Error(err) | ||
} | ||
} | ||
|
||
env, err := ReadOrConfigureEnv(envName) | ||
if err != nil { | ||
telemetry.Event("cli.describe") | ||
exit.Error(err) | ||
} | ||
telemetry.Event("cli.describe", map[string]interface{}{"env_name": env.Name}) | ||
|
||
rerun(_flagDescribeWatch, func() (string, error) { | ||
env, err := ReadOrConfigureEnv(envName) | ||
if err != nil { | ||
exit.Error(err) | ||
} | ||
|
||
out, err := envStringIfNotSpecified(envName, cmd) | ||
if err != nil { | ||
return "", err | ||
} | ||
apiTable, err := describeAPI(env, apiName) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return out + apiTable, nil | ||
}) | ||
}, | ||
} | ||
|
||
func describeAPI(env cliconfig.Environment, apiName string) (string, error) { | ||
apisRes, err := cluster.DescribeAPI(MustGetOperatorConfig(env.Name), apiName) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if len(apisRes) == 0 { | ||
exit.Error(errors.ErrorUnexpected(fmt.Sprintf("unable to find api %s", apiName))) | ||
} | ||
|
||
apiRes := apisRes[0] | ||
|
||
switch apiRes.Metadata.Kind { | ||
case userconfig.RealtimeAPIKind: | ||
return realtimeDescribeAPITable(apiRes, env) | ||
case userconfig.AsyncAPIKind: | ||
return asyncDescribeAPITable(apiRes, env) | ||
default: | ||
return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Spec.Kind, apiRes.Spec.Name)) | ||
deliahu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
This file contains hidden or 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 hidden or 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,59 @@ | ||
/* | ||
Copyright 2021 Cortex Labs, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"github.com/cortexlabs/cortex/pkg/lib/table" | ||
"github.com/cortexlabs/cortex/pkg/types/status" | ||
) | ||
|
||
func replicaCountTable(counts *status.ReplicaCounts) table.Table { | ||
var rows [][]interface{} | ||
for _, replicaCountType := range status.ReplicaCountTypes { | ||
count := counts.GetCountBy(replicaCountType) | ||
canBeHiddenIfZero := false | ||
switch replicaCountType { | ||
case status.ReplicaCountFailed: | ||
canBeHiddenIfZero = true | ||
case status.ReplicaCountKilled: | ||
canBeHiddenIfZero = true | ||
case status.ReplicaCountKilledOOM: | ||
canBeHiddenIfZero = true | ||
case status.ReplicaCountErrImagePull: | ||
canBeHiddenIfZero = true | ||
case status.ReplicaCountUnknown: | ||
canBeHiddenIfZero = true | ||
case status.ReplicaCountStalled: | ||
canBeHiddenIfZero = true | ||
} | ||
if count == 0 && canBeHiddenIfZero { | ||
continue | ||
} | ||
rows = append(rows, []interface{}{ | ||
replicaCountType, | ||
count, | ||
}) | ||
} | ||
|
||
return table.Table{ | ||
Headers: []table.Header{ | ||
{Title: _titleReplicaStatus, MinWidth: 32, MaxWidth: 32}, | ||
{Title: _titleReplicaCount}, | ||
}, | ||
Rows: rows, | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.