Skip to content
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

Pricing changes #347

Merged
merged 3 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions ATTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,8 @@ SOFTWARE.
## github.com/charmbracelet/bubbletea

* Name: github.com/charmbracelet/bubbletea
* Version: v1.1.1
* License: [MIT](https://github.com/charmbracelet/bubbletea/blob/v1.1.1/LICENSE)
* Version: v1.2.4
* License: [MIT](https://github.com/charmbracelet/bubbletea/blob/v1.2.4/LICENSE)

```
MIT License
Expand Down Expand Up @@ -1210,8 +1210,8 @@ SOFTWARE.
## github.com/charmbracelet/lipgloss

* Name: github.com/charmbracelet/lipgloss
* Version: v0.13.0
* License: [MIT](https://github.com/charmbracelet/lipgloss/blob/v0.13.0/LICENSE)
* Version: v1.0.0
* License: [MIT](https://github.com/charmbracelet/lipgloss/blob/v1.0.0/LICENSE)

```
MIT License
Expand Down Expand Up @@ -1241,8 +1241,8 @@ SOFTWARE.
## github.com/charmbracelet/x/ansi

* Name: github.com/charmbracelet/x/ansi
* Version: v0.2.3
* License: [MIT](https://github.com/charmbracelet/x/blob/ansi/v0.2.3/ansi/LICENSE)
* Version: v0.4.5
* License: [MIT](https://github.com/charmbracelet/x/blob/ansi/v0.4.5/ansi/LICENSE)

```
MIT License
Expand Down Expand Up @@ -1272,8 +1272,8 @@ SOFTWARE.
## github.com/charmbracelet/x/term

* Name: github.com/charmbracelet/x/term
* Version: v0.2.0
* License: [MIT](https://github.com/charmbracelet/x/blob/term/v0.2.0/term/LICENSE)
* Version: v0.2.1
* License: [MIT](https://github.com/charmbracelet/x/blob/term/v0.2.1/term/LICENSE)

```
MIT License
Expand Down Expand Up @@ -5286,8 +5286,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## golang.org/x/sync/errgroup

* Name: golang.org/x/sync/errgroup
* Version: v0.8.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sync/+/v0.8.0:LICENSE)
* Version: v0.9.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sync/+/v0.9.0:LICENSE)

```
Copyright 2009 The Go Authors.
Expand Down Expand Up @@ -5323,8 +5323,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## golang.org/x/sys/unix

* Name: golang.org/x/sys/unix
* Version: v0.24.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.24.0:LICENSE)
* Version: v0.27.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.27.0:LICENSE)

```
Copyright 2009 The Go Authors.
Expand Down Expand Up @@ -6029,8 +6029,8 @@ limitations under the License.
## k8s.io/api

* Name: k8s.io/api
* Version: v0.31.1
* License: [Apache-2.0](https://github.com/kubernetes/api/blob/v0.31.1/LICENSE)
* Version: v0.31.3
* License: [Apache-2.0](https://github.com/kubernetes/api/blob/v0.31.3/LICENSE)

```

Expand Down Expand Up @@ -6702,8 +6702,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## k8s.io/client-go

* Name: k8s.io/client-go
* Version: v0.31.1
* License: [Apache-2.0](https://github.com/kubernetes/client-go/blob/v0.31.1/LICENSE)
* Version: v0.31.3
* License: [Apache-2.0](https://github.com/kubernetes/client-go/blob/v0.31.3/LICENSE)

```

Expand Down
32 changes: 16 additions & 16 deletions cmd/eks-node-viewer/ATTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,8 @@ SOFTWARE.
## github.com/charmbracelet/bubbletea

* Name: github.com/charmbracelet/bubbletea
* Version: v1.1.1
* License: [MIT](https://github.com/charmbracelet/bubbletea/blob/v1.1.1/LICENSE)
* Version: v1.2.4
* License: [MIT](https://github.com/charmbracelet/bubbletea/blob/v1.2.4/LICENSE)

```
MIT License
Expand Down Expand Up @@ -1210,8 +1210,8 @@ SOFTWARE.
## github.com/charmbracelet/lipgloss

* Name: github.com/charmbracelet/lipgloss
* Version: v0.13.0
* License: [MIT](https://github.com/charmbracelet/lipgloss/blob/v0.13.0/LICENSE)
* Version: v1.0.0
* License: [MIT](https://github.com/charmbracelet/lipgloss/blob/v1.0.0/LICENSE)

```
MIT License
Expand Down Expand Up @@ -1241,8 +1241,8 @@ SOFTWARE.
## github.com/charmbracelet/x/ansi

* Name: github.com/charmbracelet/x/ansi
* Version: v0.2.3
* License: [MIT](https://github.com/charmbracelet/x/blob/ansi/v0.2.3/ansi/LICENSE)
* Version: v0.4.5
* License: [MIT](https://github.com/charmbracelet/x/blob/ansi/v0.4.5/ansi/LICENSE)

```
MIT License
Expand Down Expand Up @@ -1272,8 +1272,8 @@ SOFTWARE.
## github.com/charmbracelet/x/term

* Name: github.com/charmbracelet/x/term
* Version: v0.2.0
* License: [MIT](https://github.com/charmbracelet/x/blob/term/v0.2.0/term/LICENSE)
* Version: v0.2.1
* License: [MIT](https://github.com/charmbracelet/x/blob/term/v0.2.1/term/LICENSE)

```
MIT License
Expand Down Expand Up @@ -5286,8 +5286,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## golang.org/x/sync/errgroup

* Name: golang.org/x/sync/errgroup
* Version: v0.8.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sync/+/v0.8.0:LICENSE)
* Version: v0.9.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sync/+/v0.9.0:LICENSE)

```
Copyright 2009 The Go Authors.
Expand Down Expand Up @@ -5323,8 +5323,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## golang.org/x/sys/unix

* Name: golang.org/x/sys/unix
* Version: v0.24.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.24.0:LICENSE)
* Version: v0.27.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.27.0:LICENSE)

```
Copyright 2009 The Go Authors.
Expand Down Expand Up @@ -6029,8 +6029,8 @@ limitations under the License.
## k8s.io/api

* Name: k8s.io/api
* Version: v0.31.1
* License: [Apache-2.0](https://github.com/kubernetes/api/blob/v0.31.1/LICENSE)
* Version: v0.31.3
* License: [Apache-2.0](https://github.com/kubernetes/api/blob/v0.31.3/LICENSE)

```

Expand Down Expand Up @@ -6702,8 +6702,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## k8s.io/client-go

* Name: k8s.io/client-go
* Version: v0.31.1
* License: [Apache-2.0](https://github.com/kubernetes/client-go/blob/v0.31.1/LICENSE)
* Version: v0.31.3
* License: [Apache-2.0](https://github.com/kubernetes/client-go/blob/v0.31.3/LICENSE)

```

Expand Down
1 change: 1 addition & 0 deletions cmd/eks-node-viewer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func main() {
log.Fatalf("creating style, %s", err)
}
m := model.NewUIModel(strings.Split(flags.ExtraLabels, ","), flags.NodeSort, style)
m.DisablePricing = flags.DisablePricing
m.SetResources(strings.FieldsFunc(flags.Resources, func(r rune) bool { return r == ',' }))

var nodeSelector labels.Selector
Expand Down
4 changes: 4 additions & 0 deletions pkg/model/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func (n *Node) IsFargate() bool {
return n.node.Labels["eks.amazonaws.com/compute-type"] == "fargate"
}

func (n *Node) IsAuto() bool {
return n.node.Labels["eks.amazonaws.com/compute-type"] == "auto"
}

func (n *Node) Labels() map[string]string {
return n.node.Labels
}
Expand Down
24 changes: 24 additions & 0 deletions pkg/model/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,30 @@ func TestNodeTypeFargate(t *testing.T) {
}
}

func TestNodeTypeAuto(t *testing.T) {
for label, value := range map[string]string{
"eks.amazonaws.com/compute-type": "auto",
} {
n := testNode("mynode")
n.Labels = map[string]string{
label: value,
}
node := model.NewNode(n)
if node.IsOnDemand() {
t.Errorf("exepcted to not be on-demand")
}
if node.IsSpot() {
t.Errorf("exepcted to not be spot")
}
if node.IsFargate() {
t.Errorf("exepcted to not be fargate")
}
if !node.IsAuto() {
t.Errorf("exepcted to be auto")
}
}
}

func TestNodeNotReadyFalse(t *testing.T) {
for _, status := range []v1.ConditionStatus{v1.ConditionFalse, v1.ConditionUnknown} {
t.Run(string(status), func(t *testing.T) {
Expand Down
26 changes: 17 additions & 9 deletions pkg/model/uimodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ var (
)

type UIModel struct {
progress progress.Model
cluster *Cluster
extraLabels []string
paginator paginator.Model
height int
nodeSorter func(lhs, rhs *Node) bool
style *Style
progress progress.Model
cluster *Cluster
extraLabels []string
paginator paginator.Model
height int
nodeSorter func(lhs, rhs *Node) bool
style *Style
DisablePricing bool
}

func NewUIModel(extraLabels []string, nodeSort string, style *Style) *UIModel {
Expand Down Expand Up @@ -144,7 +145,7 @@ func (u *UIModel) writeNodeInfo(n *Node, w io.Writer, resources []v1.ResourceNam

if firstLine {
priceLabel := fmt.Sprintf("/$%0.4f", n.Price)
if !n.HasPrice() {
if !n.HasPrice() || u.DisablePricing {
priceLabel = ""
}
fmt.Fprintf(w, "%s\t%s\t%s\t(%d pods)\t%s%s", n.Name(), res, u.progress.ViewAs(pct), n.NumPods(), n.InstanceType(), priceLabel)
Expand All @@ -160,6 +161,10 @@ func (u *UIModel) writeNodeInfo(n *Node, w io.Writer, resources []v1.ResourceNam
fmt.Fprintf(w, "\t-")
}

if n.IsAuto() {
fmt.Fprintf(w, "/Auto")
}

// node status
if n.Cordoned() && n.Deleting() {
fmt.Fprintf(w, "\tCordoned/Deleting")
Expand Down Expand Up @@ -222,8 +227,11 @@ func (u *UIModel) writeClusterSummary(resources []v1.ResourceName, stats Stats,
// message printer formats numbers nicely with commas
enPrinter := message.NewPrinter(language.English)
clusterPrice := enPrinter.Sprintf("$%0.3f/hour | $%0.3f/month", stats.TotalPrice, monthlyPrice)
if u.DisablePricing {
clusterPrice = ""
}
if firstLine {
enPrinter.Fprintf(w, "%d nodes\t(%s/%s)\t%s\t%s\t%s\t%s\n",
enPrinter.Fprintf(w, "%d nodes\t(%10s/%s)\t%s\t%s\t%s\t%s\n",
stats.NumNodes, used.String(), allocatable.String(), pctUsedStr, res, u.progress.ViewAs(pctUsed/100.0), clusterPrice)
} else {
enPrinter.Fprintf(w, " \t%s/%s\t%s\t%s\t%s\t\n",
Expand Down