Skip to content

Commit 7de8bc8

Browse files
committed
Alpine & status fixes
1 parent 408de54 commit 7de8bc8

File tree

13 files changed

+164
-70
lines changed

13 files changed

+164
-70
lines changed

dashboard/assets.go

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

dashboard/src/deployment/DeploymentList.js

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const HeaderView = () => (
1515
<Table.HeaderCell><Popup trigger={<span>Pods</span>}>Ready / Total</Popup></Table.HeaderCell>
1616
<Table.HeaderCell><Popup trigger={<span>Volumes</span>}>Bound / Total</Popup></Table.HeaderCell>
1717
<Table.HeaderCell>StorageClass</Table.HeaderCell>
18-
<Table.HeaderCell></Table.HeaderCell>
18+
<Table.HeaderCell>Actions</Table.HeaderCell>
1919
</Table.Row>
2020
</Table.Header>
2121
);
@@ -34,10 +34,12 @@ const NoDatabaseLinkView = () => (
3434
</Popup>
3535
);
3636

37-
const RowView = ({name, mode, environment, version, license, ready_pod_count, pod_count, ready_volume_count, volume_count, storage_classes, database_url, delete_command}) => (
37+
const RowView = ({name, mode, environment, stateColor, version, license, readyPodCount, podCount, readyVolumeCount, volumeCount, storageClasses, databaseURL, deleteCommand, describeCommand}) => (
3838
<Table.Row>
3939
<Table.Cell>
40-
<Icon name="bell" color="red"/>
40+
<Popup trigger={<Icon name={(stateColor==="green") ? "check" : "bell"} color={stateColor}/>}>
41+
{getStateColorDescription(stateColor)}
42+
</Popup>
4143
</Table.Cell>
4244
<Table.Cell>
4345
<Link to={`/deployment/${name}`}>
@@ -58,15 +60,21 @@ const RowView = ({name, mode, environment, version, license, ready_pod_count, po
5860
{(license==="enterprise") ? <Popup trigger={<Icon name="dollar"/>} content="Enterprise edition"/>: null}
5961
</span>
6062
</Table.Cell>
61-
<Table.Cell>{ready_pod_count} / {pod_count}</Table.Cell>
62-
<Table.Cell>{ready_volume_count} / {volume_count}</Table.Cell>
63-
<Table.Cell>{storage_classes.map((item) => (item === "") ? "<default>" : item)}</Table.Cell>
63+
<Table.Cell>{readyPodCount} / {podCount}</Table.Cell>
64+
<Table.Cell>{readyVolumeCount} / {volumeCount}</Table.Cell>
65+
<Table.Cell>{storageClasses.map((item) => (item === "") ? "<default>" : item)}</Table.Cell>
6466
<Table.Cell>
65-
{ database_url ? <DatabaseLinkView name={name} url={database_url}/> : <NoDatabaseLinkView/>}
67+
{ databaseURL ? <DatabaseLinkView name={name} url={databaseURL}/> : <NoDatabaseLinkView/>}
68+
<CommandInstruction
69+
trigger={<Icon link name="zoom"/>}
70+
command={describeCommand}
71+
title="Describe deployment"
72+
description="To get more information on the state of this deployment, run:"
73+
/>
6674
<span style={{"float":"right"}}>
6775
<CommandInstruction
6876
trigger={<Icon link name="trash"/>}
69-
command={delete_command}
77+
command={deleteCommand}
7078
title="Delete deployment"
7179
description="To delete this deployment, run:"
7280
/>
@@ -87,15 +95,17 @@ const ListView = ({items}) => (
8795
namespace={item.namespace}
8896
mode={item.mode}
8997
environment={item.environment}
98+
stateColor={item.state_color}
9099
version={item.database_version}
91100
license={item.database_license}
92-
ready_pod_count={item.ready_pod_count}
93-
pod_count={item.pod_count}
94-
ready_volume_count={item.ready_volume_count}
95-
volume_count={item.volume_count}
96-
storage_classes={item.storage_classes}
97-
database_url={item.database_url}
98-
delete_command={createDeleteCommand(item.name, item.namespace)}
101+
readyPodCount={item.ready_pod_count}
102+
podCount={item.pod_count}
103+
readyVolumeCount={item.ready_volume_count}
104+
volumeCount={item.volume_count}
105+
storageClasses={item.storage_classes}
106+
databaseURL={item.database_url}
107+
deleteCommand={createDeleteCommand(item.name, item.namespace)}
108+
describeCommand={createDescribeCommand(item.name, item.namespace)}
99109
/>) : <p>No items</p>
100110
}
101111
</Table.Body>
@@ -108,6 +118,25 @@ function createDeleteCommand(name, namespace) {
108118
return `kubectl delete ArangoDeployment -n ${namespace} ${name}`;
109119
}
110120

121+
function createDescribeCommand(name, namespace) {
122+
return `kubectl describe ArangoDeployment -n ${namespace} ${name}`;
123+
}
124+
125+
function getStateColorDescription(stateColor) {
126+
switch (stateColor) {
127+
case "green":
128+
return "Everything is running smooth.";
129+
case "yellow":
130+
return "There is some activity going on, but deployment is available.";
131+
case "orange":
132+
return "There is some activity going on, deployment may be/become unavailable. You should pay attention now!";
133+
case "red":
134+
return "The deployment is in a bad state and manual intervention is likely needed.";
135+
default:
136+
return "State is not known.";
137+
}
138+
}
139+
111140
class DeploymentList extends Component {
112141
state = {};
113142

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const (
5959
defaultServerPort = 8528
6060
defaultLogLevel = "debug"
6161
defaultAdminSecretName = "arangodb-operator-dashboard"
62+
defaultAlpineImage = "alpine:3.7"
6263
)
6364

6465
var (
@@ -86,6 +87,7 @@ var (
8687
enableDeployment bool // Run deployment operator
8788
enableDeploymentReplication bool // Run deployment-replication operator
8889
enableStorage bool // Run local-storage operator
90+
alpineImage string
8991
}
9092
chaosOptions struct {
9193
allowed bool
@@ -107,6 +109,7 @@ func init() {
107109
f.BoolVar(&operatorOptions.enableDeployment, "operator.deployment", false, "Enable to run the ArangoDeployment operator")
108110
f.BoolVar(&operatorOptions.enableDeploymentReplication, "operator.deployment-replication", false, "Enable to run the ArangoDeploymentReplication operator")
109111
f.BoolVar(&operatorOptions.enableStorage, "operator.storage", false, "Enable to run the ArangoLocalStorage operator")
112+
f.StringVar(&operatorOptions.alpineImage, "operator.alpine-image", defaultAlpineImage, "Docker image used for alpine containers")
110113
f.BoolVar(&chaosOptions.allowed, "chaos.allowed", false, "Set to allow chaos in deployments. Only activated when allowed and enabled in deployment")
111114
}
112115

@@ -249,6 +252,7 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
249252
EnableDeploymentReplication: operatorOptions.enableDeploymentReplication,
250253
EnableStorage: operatorOptions.enableStorage,
251254
AllowChaos: chaosOptions.allowed,
255+
AlpineImage: operatorOptions.alpineImage,
252256
}
253257
deps := operator.Dependencies{
254258
LogService: logService,

pkg/deployment/context_impl.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ func (d *Deployment) GetLifecycleImage() string {
6363
return d.config.LifecycleImage
6464
}
6565

66+
// GetAlpineImage returns the image name containing the alpine environment
67+
func (d *Deployment) GetAlpineImage() string {
68+
return d.config.AlpineImage
69+
}
70+
6671
// GetNamespace returns the kubernetes namespace that contains
6772
// this deployment.
6873
func (d *Deployment) GetNamespace() string {

pkg/deployment/deployment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type Config struct {
5252
ServiceAccount string
5353
AllowChaos bool
5454
LifecycleImage string
55+
AlpineImage string
5556
}
5657

5758
// Dependencies holds dependent services for a Deployment

pkg/deployment/images.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, ima
178178
tolerations = k8sutil.AddTolerationIfNotFound(tolerations, k8sutil.NewNoExecuteToleration(k8sutil.TolerationKeyNodeAlphaUnreachable, shortDur))
179179
serviceAccountName := ""
180180

181-
if err := k8sutil.CreateArangodPod(ib.KubeCli, true, ib.APIObject, role, id, podName, "", image, "", ib.Spec.GetImagePullPolicy(), "", false, terminationGracePeriod, args, nil, nil, nil, nil,
181+
if err := k8sutil.CreateArangodPod(ib.KubeCli, true, ib.APIObject, role, id, podName, "", image, "", "", ib.Spec.GetImagePullPolicy(), "", false, terminationGracePeriod, args, nil, nil, nil, nil,
182182
tolerations, serviceAccountName, "", ""); err != nil {
183183
log.Debug().Err(err).Msg("Failed to create image ID pod")
184184
return true, maskAny(err)

pkg/deployment/resources/context.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type Context interface {
6060
GetKubeCli() kubernetes.Interface
6161
// GetLifecycleImage returns the image name containing the lifecycle helper (== name of operator image)
6262
GetLifecycleImage() string
63+
// GetAlpineImage returns the image name containing the alpine environment
64+
GetAlpineImage() string
6365
// GetNamespace returns the namespace that contains the deployment
6466
GetNamespace() string
6567
// CreateEvent creates a given event.

pkg/deployment/resources/pod_creator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, memberID string,
448448
}
449449
groupSpec := spec.GetServerGroupSpec(group)
450450
lifecycleImage := r.context.GetLifecycleImage()
451+
alpineImage := r.context.GetAlpineImage()
451452
terminationGracePeriod := group.DefaultTerminationGracePeriod()
452453
tolerations := r.createPodTolerations(group, groupSpec)
453454
serviceAccountName := groupSpec.GetServiceAccountName()
@@ -514,7 +515,7 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, memberID string,
514515
engine := spec.GetStorageEngine().AsArangoArgument()
515516
requireUUID := group == api.ServerGroupDBServers && m.IsInitialized
516517
finalizers := r.createPodFinalizers(group)
517-
if err := k8sutil.CreateArangodPod(kubecli, spec.IsDevelopment(), apiObject, role, m.ID, m.PodName, m.PersistentVolumeClaimName, imageInfo.ImageID, lifecycleImage, spec.GetImagePullPolicy(),
518+
if err := k8sutil.CreateArangodPod(kubecli, spec.IsDevelopment(), apiObject, role, m.ID, m.PodName, m.PersistentVolumeClaimName, imageInfo.ImageID, lifecycleImage, alpineImage, spec.GetImagePullPolicy(),
518519
engine, requireUUID, terminationGracePeriod, args, env, finalizers, livenessProbe, readinessProbe, tolerations, serviceAccountName, tlsKeyfileSecretName, rocksdbEncryptionSecretName); err != nil {
519520
return maskAny(err)
520521
}

pkg/deployment/server_api.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,44 @@ func (d *Deployment) Environment() api.Environment {
5656
return d.GetSpec().GetEnvironment()
5757
}
5858

59+
// StateColor determinates the state of the deployment in color codes.
60+
func (d *Deployment) StateColor() server.StateColor {
61+
allGood := true
62+
deploymentAvailable := true
63+
failed := false
64+
if d.PodCount() != d.ReadyPodCount() {
65+
allGood = false
66+
}
67+
if d.VolumeCount() != d.ReadyVolumeCount() {
68+
allGood = false
69+
}
70+
status, _ := d.GetStatus()
71+
status.Members.ForeachServerGroup(func(group api.ServerGroup, list api.MemberStatusList) error {
72+
for _, m := range list {
73+
switch m.Phase {
74+
case api.MemberPhaseFailed:
75+
failed = true
76+
case api.MemberPhaseCreated:
77+
// Should be ok now
78+
default:
79+
// Something is going on
80+
allGood = true
81+
}
82+
}
83+
return nil
84+
})
85+
if failed {
86+
return server.StateRed
87+
}
88+
if !deploymentAvailable {
89+
return server.StateOrange
90+
}
91+
if !allGood {
92+
return server.StateYellow
93+
}
94+
return server.StateGreen
95+
}
96+
5997
// PodCount returns the number of pods for the deployment
6098
func (d *Deployment) PodCount() int {
6199
count := 0

pkg/operator/operator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ type Config struct {
7171
PodName string
7272
ServiceAccount string
7373
LifecycleImage string
74+
AlpineImage string
7475
EnableDeployment bool
7576
EnableDeploymentReplication bool
7677
EnableStorage bool

0 commit comments

Comments
 (0)