Skip to content

Commit 95643d3

Browse files
committed
Various improvements
1 parent 44cec70 commit 95643d3

File tree

8 files changed

+115
-57
lines changed

8 files changed

+115
-57
lines changed

dashboard/assets.go

Lines changed: 52 additions & 52 deletions
Large diffs are not rendered by default.

dashboard/src/deployment/DeploymentOperator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const StyledContentBox = styled('div')`
2323
const ListView = () => (
2424
<div>
2525
<Header dividing>
26-
ArangoDeployments
26+
ArangoDeployment resources
2727
</Header>
2828
<DeploymentList/>
2929
</div>

dashboard/src/storage/StorageOperator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const StyledContentBox = styled('div')`
2121
const ListView = () => (
2222
<div>
2323
<Header dividing>
24-
ArangoLocalStorages
24+
ArangoLocalStorage resources
2525
</Header>
2626
<StorageList/>
2727
</div>

dashboard/src/storage/VolumeList.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const HeaderView = ({loading}) => (
1919
<Table.Row>
2020
<Table.HeaderCell>State</Table.HeaderCell>
2121
<Table.HeaderCell>Name</Table.HeaderCell>
22+
<Table.HeaderCell>Capacity</Table.HeaderCell>
23+
<Table.HeaderCell>Node</Table.HeaderCell>
2224
<Table.HeaderCell>
2325
Actions
2426
<LoaderBox><Loader size="mini" active={loading} inline/></LoaderBox>
@@ -27,7 +29,7 @@ const HeaderView = ({loading}) => (
2729
</Table.Header>
2830
);
2931

30-
const RowView = ({name, stateColor, describeCommand, deleteCommand}) => (
32+
const RowView = ({name, stateColor, nodeName, capacity, describeCommand, deleteCommand}) => (
3133
<Table.Row>
3234
<Table.Cell>
3335
<Popup trigger={<Icon name={(stateColor==="green") ? "check" : "bell"} color={stateColor}/>}>
@@ -37,6 +39,12 @@ const RowView = ({name, stateColor, describeCommand, deleteCommand}) => (
3739
<Table.Cell>
3840
{name}
3941
</Table.Cell>
42+
<Table.Cell>
43+
{capacity}
44+
</Table.Cell>
45+
<Table.Cell>
46+
{nodeName}
47+
</Table.Cell>
4048
<Table.Cell>
4149
<CommandInstruction
4250
trigger={<Icon link name="zoom"/>}
@@ -66,6 +74,8 @@ const ListView = ({items, loading}) => (
6674
key={item.name}
6775
name={item.name}
6876
stateColor={item.state_color}
77+
nodeName={item.node_name}
78+
capacity={item.capacity}
6979
deleteCommand={createDeleteCommand(item.name)}
7080
describeCommand={createDescribeCommand(item.name)}
7181
/>

pkg/server/handlers_storage.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,25 @@ func newLocalStorageInfoDetails(ls LocalStorage) LocalStorageInfoDetails {
8989
type Volume interface {
9090
Name() string
9191
StateColor() StateColor
92+
NodeName() string
93+
Capacity() string
9294
}
9395

9496
// VolumeInfo contained the information returned per volume that is created on behalf of a local storage.
9597
type VolumeInfo struct {
9698
Name string `json:"name"`
9799
StateColor StateColor `json:"state_color"`
100+
NodeName string `json:"node_name"`
101+
Capacity string `json:"capacity"`
98102
}
99103

100104
// newVolumeInfo creates a VolumeInfo for the given volume
101105
func newVolumeInfo(v Volume) VolumeInfo {
102106
return VolumeInfo{
103107
Name: v.Name(),
104108
StateColor: v.StateColor(),
109+
NodeName: v.NodeName(),
110+
Capacity: v.Capacity(),
105111
}
106112
}
107113

pkg/storage/local_storage.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ func (ls *LocalStorage) run() {
174174
ls.image = image
175175
ls.imagePullPolicy = pullPolicy
176176

177+
// Set state
178+
if ls.status.State == api.LocalStorageStateNone {
179+
ls.status.State = api.LocalStorageStateCreating
180+
if err := ls.updateCRStatus(); err != nil {
181+
ls.createEvent(k8sutil.NewErrorEvent("Failed to update LocalStorage state", err, ls.apiObject))
182+
}
183+
}
184+
177185
// Create StorageClass
178186
if err := ls.ensureStorageClass(ls.apiObject); err != nil {
179187
ls.failOnError(err, "Failed to create storage class")
@@ -260,6 +268,13 @@ func (ls *LocalStorage) run() {
260268
recentInspectionErrors++
261269
}
262270
} else {
271+
if ls.status.State == api.LocalStorageStateCreating || ls.status.State == api.LocalStorageStateNone {
272+
ls.status.State = api.LocalStorageStateRunning
273+
if err := ls.updateCRStatus(); err != nil {
274+
hasError = true
275+
ls.createEvent(k8sutil.NewErrorEvent("Failed to update LocalStorage state", err, ls.apiObject))
276+
}
277+
}
263278
recentInspectionErrors = 0
264279
}
265280

pkg/storage/server_api.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
package storage
2424

2525
import (
26+
"sort"
27+
28+
api "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha"
2629
"github.com/arangodb/kube-arangodb/pkg/server"
2730
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2831
)
@@ -39,8 +42,14 @@ func (ls *LocalStorage) LocalPaths() []string {
3942

4043
// StateColor returns a color describing the state of the local storage resource
4144
func (ls *LocalStorage) StateColor() server.StateColor {
42-
// TODO
43-
return server.StateYellow
45+
switch ls.status.State {
46+
case api.LocalStorageStateRunning:
47+
return server.StateGreen
48+
case api.LocalStorageStateFailed:
49+
return server.StateRed
50+
default:
51+
return server.StateYellow
52+
}
4453
}
4554

4655
// StorageClass returns the name of the StorageClass specified in the local storage resource
@@ -66,5 +75,8 @@ func (ls *LocalStorage) Volumes() []server.Volume {
6675
result = append(result, serverVolume(pv))
6776
}
6877
}
78+
sort.Slice(result, func(i, j int) bool {
79+
return result[i].Name() < result[j].Name()
80+
})
6981
return result
7082
}

pkg/storage/server_volume_api.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func (v serverVolume) Name() string {
3434
return v.ObjectMeta.GetName()
3535
}
3636

37+
// StateColor returns a color representing the state of the volume
3738
func (v serverVolume) StateColor() server.StateColor {
3839
switch v.Status.Phase {
3940
default:
@@ -44,3 +45,17 @@ func (v serverVolume) StateColor() server.StateColor {
4445
return server.StateRed
4546
}
4647
}
48+
49+
// NodeName returns the name of the node the volume is created on volume
50+
func (v serverVolume) NodeName() string {
51+
return v.GetAnnotations()[nodeNameAnnotation]
52+
}
53+
54+
// Capacity returns the capacity of the volume in human readable form
55+
func (v serverVolume) Capacity() string {
56+
c, found := v.Spec.Capacity[v1.ResourceStorage]
57+
if found {
58+
return c.String()
59+
}
60+
return "?"
61+
}

0 commit comments

Comments
 (0)