Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #350 from koor-tech/feature/ksd-379
Browse files Browse the repository at this point in the history
  • Loading branch information
galexrt authored Apr 11, 2024
2 parents 7dfe0b4 + 9ec48a1 commit 82413df
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 11 deletions.
48 changes: 48 additions & 0 deletions pkg/recommender/modules/rook_encryption.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package recommendermodules

import (
"context"

cephv1 "github.com/koor-tech/data-control-center/gen/go/api/resources/ceph/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func init() {
moduleFactories["k8s_resources"] = NewRookEncryption
}

func NewRookEncryption() (Module, error) {
return &RookEncryption{}, nil
}

type RookEncryption struct {
Module
}

func (m *RookEncryption) GetName() string {
return "rook_encryption"
}

func (m *RookEncryption) Run(ctx context.Context, p *Params) ([]*cephv1.ClusterRecommendation, error) {
recs := []*cephv1.ClusterRecommendation{}

clusters, err := p.K8S.GetRookClient().CephV1().CephClusters(p.Namespace).List(ctx, v1.ListOptions{})
if err != nil {
return nil, err
}
for _, item := range clusters.Items {
if item.Spec.Network.Connections.Encryption != nil && item.Spec.Network.Connections.Encryption.Enabled {
continue
}

recs = append(recs, &cephv1.ClusterRecommendation{
Title: "Ceph network encryption not active",
Description: `It is recommended to enable Ceph network encryption for clusters that might be running in \"untrusted\" networks.
To enable it carefully read the \"encryption.enabled\" settings comments <a class=\"underline\" href=\"https://rook.io/docs/rook/latest-release/CRDs/Cluster/ceph-cluster-crd/#network-configuration-settings\">here</a>.`,
Level: cephv1.RecommendationLevel_RECOMMENDATION_LEVEL_INFORMAL,

Check failure on line 42 in pkg/recommender/modules/rook_encryption.go

View workflow job for this annotation

GitHub Actions / golang-tests

undefined: cephv1.RecommendationLevel_RECOMMENDATION_LEVEL_INFORMAL
Type: cephv1.RecommendationType_RECOMMENDATION_TYPE_CLUSTER,
})
}

return recs, nil
}
4 changes: 4 additions & 0 deletions pkg/recommender/recommender.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package recommender

import (
"context"
"slices"
"sync"
"time"

Expand Down Expand Up @@ -118,6 +119,9 @@ func (r *Recommender) Gather() error {
r.mutex.Lock()
defer r.mutex.Unlock()

slices.SortFunc(recommendations, func(a *cephv1.ClusterRecommendation, b *cephv1.ClusterRecommendation) int {
return int(b.Level - a.Level)
})
r.recommendations = recommendations

return errs
Expand Down
4 changes: 2 additions & 2 deletions src/components/cluster/services/MgrService.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ClipboardIcon } from 'mdi-vue3';
import type { MgrService } from '~~/gen/ts/api/resources/ceph/v1/stats_pb';
import ServiceLiItem from '~/components/cluster/services/ServiceLiItem.vue';
import ServiceBox from '~/components/cluster/services/ServiceBox.vue';
import Time from '~/components/partials/elements/Time.vue';
import GenericTime from '~/components/partials/elements/GenericTime.vue';
import GenericBadge from '~/components/partials/GenericBadge.vue';
defineProps<{
Expand All @@ -27,7 +27,7 @@ defineProps<{
<ServiceLiItem>
<template #default> Updated Since </template>
<template #content>
<Time :value="stats.updatedSince" />
<GenericTime :value="stats.updatedSince" />
</template>
</ServiceLiItem>
</template>
Expand Down
6 changes: 3 additions & 3 deletions src/components/cluster/services/MonService.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { MonService } from '~~/gen/ts/api/resources/ceph/v1/stats_pb';
import GenericBadge from '~/components/partials/GenericBadge.vue';
import ServiceLiItem from '~/components/cluster/services/ServiceLiItem.vue';
import ServiceBox from '~/components/cluster/services/ServiceBox.vue';
import Time from '~/components/partials/elements/Time.vue';
import GenericTime from '~/components/partials/elements/GenericTime.vue';
defineProps<{
stats: MonService;
Expand Down Expand Up @@ -36,14 +36,14 @@ defineProps<{
<ServiceLiItem>
<template #default> Created Since </template>
<template #content>
<Time :value="stats.createdSince" />
<GenericTime :value="stats.createdSince" />
</template>
</ServiceLiItem>

<ServiceLiItem>
<template #default> Updated Since </template>
<template #content>
<Time :value="stats.updatedSince" />
<GenericTime :value="stats.updatedSince" />
</template>
</ServiceLiItem>
</template>
Expand Down
6 changes: 3 additions & 3 deletions src/components/cluster/services/OsdService.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TableIcon } from 'mdi-vue3';
import type { OsdService } from '~~/gen/ts/api/resources/ceph/v1/stats_pb';
import ServiceLiItem from '~/components/cluster/services/ServiceLiItem.vue';
import ServiceBox from '~/components/cluster/services/ServiceBox.vue';
import Time from '~/components/partials/elements/Time.vue';
import GenericTime from '~/components/partials/elements/GenericTime.vue';
defineProps<{
stats: OsdService;
Expand Down Expand Up @@ -38,14 +38,14 @@ defineProps<{
<ServiceLiItem>
<template #default> In Updated </template>
<template #content>
<Time :value="stats.osdInUpdatedSince" />
<GenericTime :value="stats.osdInUpdatedSince" />
</template>
</ServiceLiItem>

<ServiceLiItem>
<template #default> Up Updated </template>
<template #content>
<Time :value="stats.osdUpUpdatedSince" />
<GenericTime :value="stats.osdUpUpdatedSince" />
</template>
</ServiceLiItem>
</template>
Expand Down
4 changes: 2 additions & 2 deletions src/components/recommender/RecommenderList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ async function listClusterRecommendations(): Promise<ListClusterRecommendationsR
<DataNoDataBlock v-else-if="data === null || data === undefined" />

<template v-else>
<div class="mt-2 gap-2 grid grid-col-2">
<div class="max-w-3xl mt-2 gap-2 grid grid-col-2">
<RecommenderListEntry
v-for="recommendation in data.recommendations.sort((a, b) => a.type - b.type)"
v-for="recommendation in data.recommendations"
:key="recommendation.title"
:recommendation="recommendation"
/>
Expand Down
4 changes: 3 additions & 1 deletion src/components/recommender/RecommenderListEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ defineProps<{
<InformationIcon class="h-5 w-auto" :class="getRecommendationLevelTextColor(recommendation.level)" />
{{ RecommendationLevel[recommendation.level] }}
</GenericBadge>

{{ recommendation.title }}
</h3>
<p class="text-base">{{ recommendation.description }}</p>
<!-- eslint-disable-next-line vue/no-v-html -->
<p class="text-base" v-html="recommendation.description"></p>
<template v-if="recommendation.extraData && recommendation.extraData.case !== undefined">
<hr class="my-1" />
<p v-if="recommendation.extraData.case === 'recommendedValue'" class="text-sm">
Expand Down
1 change: 1 addition & 0 deletions src/error.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- eslint-disable vue/multi-word-component-names -->
<script setup lang="ts">
import { useClipboard } from '@vueuse/core';
import HeroFull from '~/components/partials/HeroFull.vue';
Expand Down

0 comments on commit 82413df

Please sign in to comment.