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

feat: core erda k8s labels #6323

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2bc8509
feat: new deployment labels
CeerDecy Mar 21, 2024
c648369
feat: set core/erda labels when apply or update deployment and service
CeerDecy Mar 21, 2024
b118db8
feat: merge daemon labels when update
CeerDecy Mar 25, 2024
eedb7ee
polish: remove useless code
CeerDecy Mar 26, 2024
699fc3a
Merge branch 'master' into feature/k8s-labels
CeerDecy Mar 27, 2024
78943b9
polish: maintaining labels constants
CeerDecy Mar 27, 2024
50e2f46
polish: warp merge labels
CeerDecy Mar 27, 2024
cbc1268
feat: pass monkey patch
CeerDecy Mar 27, 2024
0c8dc4c
feat: pass monkey patch
CeerDecy Mar 27, 2024
c44d8e6
Merge branch 'master' into feature/k8s-labels
CeerDecy May 31, 2024
64594b9
extract labels to labels.go
CeerDecy May 31, 2024
a09b3e7
feat: add service group id for service
CeerDecy May 31, 2024
201b63e
polish: improve unit testing
CeerDecy May 31, 2024
c4a0c68
polish: add license
CeerDecy May 31, 2024
f707585
polish: pass test action
CeerDecy Jun 4, 2024
93fcd91
polish: pass test action
CeerDecy Jun 4, 2024
e501e98
Merge branch 'master' into feature/k8s-labels
CeerDecy Jun 4, 2024
8b2cc71
polish: move the labels.go to the orchestrator directory
CeerDecy Jun 11, 2024
9181e05
polish: move the labels.go to the orchestrator directory
CeerDecy Jun 11, 2024
af8dd17
feat: adding new labels to the base addon
CeerDecy Jun 11, 2024
58cee3b
feat: adding new labels to the cluster addons
CeerDecy Jun 11, 2024
a9d27c6
Merge branch 'master' into feature/k8s-labels
CeerDecy Jun 11, 2024
42bca21
polish: solve circular references
CeerDecy Jun 11, 2024
c367c1e
feat: set tenant-id label for addons
CeerDecy Jun 11, 2024
440eeec
polish: remove useless code
CeerDecy Jun 11, 2024
793082d
feat: setting tenant-id for manually added Addons
CeerDecy Jun 12, 2024
a2c159a
feat: addon 'type' and 'version' labels
CeerDecy Jun 24, 2024
994efc4
fix: tenantResp.Data may be nil
CeerDecy Jul 1, 2024
76c506f
polish: remove useless code
CeerDecy Jul 1, 2024
f901870
polish: move 'GenerateTenantID' to the utils package
CeerDecy Jul 1, 2024
b565620
feat: patch QueryTenantByProjectIDAndWorkspace method to pass test
CeerDecy Jul 1, 2024
58ca797
fix: cluster addon sharescope label
CeerDecy Jul 5, 2024
1fc13c1
Merge branch 'master' into feature/k8s-labels
CeerDecy Aug 23, 2024
541063d
feat: merge tenantId
CeerDecy Aug 23, 2024
1dc74de
feat: erda label setter
CeerDecy Aug 27, 2024
470db8c
feat: sort imports
CeerDecy Aug 27, 2024
f6fb151
feat: pass test
CeerDecy Aug 27, 2024
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
2 changes: 2 additions & 0 deletions apistructs/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,8 @@ type AddonHandlerCreateItem struct {
InsideAddon string `json:"insideAddon"`
// ShareScope 是否为内部依赖addon,N:否,Y:是
ShareScope string `json:"shareScope"`
// TenantId 租户Id
TenantId string `json:"tenantId,omitempty"`
}

// AddonExtension addon extension对象信息
Expand Down
2 changes: 2 additions & 0 deletions internal/apps/msp/resource/deploy/handlers/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@
service.Labels = make(map[string]string)
}
utils.SetlabelsFromOptions(options, service.Labels)
utils.SetCoreErdaLabels(service.Labels, labels, req)
utils.SetAddonErdaLabels(service.Labels, req, resourceInfo.Spec)

Check warning on line 606 in internal/apps/msp/resource/deploy/handlers/handler.go

View check run for this annotation

Codecov / codecov/patch

internal/apps/msp/resource/deploy/handlers/handler.go#L605-L606

Added lines #L605 - L606 were not covered by tests
}

return &req
Expand Down
46 changes: 46 additions & 0 deletions internal/apps/msp/resource/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,49 @@
labels[apistructs.AlibabaECILabel] = options[apistructs.AlibabaECILabel]
}
}

// k8s labels for cluster addons
const (
LabelCoreErdaCloudClusterName = "core.erda.cloud/cluster-name"
LabelCoreErdaCloudServiceType = "core.erda.cloud/service-type"

LabelDiceClusterName = "DICE_CLUSTER_NAME"
LabelDiceServiceType = "SERVICE_TYPE"
)

const (
LabelAddonErdaCloudId = "addon.erda.cloud/id"
LabelAddonErdaCloudScope = "addon.erda.cloud/scope"
LabelAddonErdaCloudType = "addon.erda.cloud/type"
LabelAddonErdaCloudVersion = "addon.erda.cloud/version"
)

var labelMappings = map[string]string{
LabelCoreErdaCloudClusterName: LabelDiceClusterName,
LabelCoreErdaCloudServiceType: LabelDiceServiceType,
}

func SetCoreErdaLabels(target map[string]string, source map[string]string, req apistructs.ServiceGroupCreateV2Request) {
if target == nil || source == nil {
return

Check warning on line 136 in internal/apps/msp/resource/utils/common.go

View check run for this annotation

Codecov / codecov/patch

internal/apps/msp/resource/utils/common.go#L134-L136

Added lines #L134 - L136 were not covered by tests
}
for core, dice := range labelMappings {
if v, exist := source[dice]; exist {
target[core] = v

Check warning on line 140 in internal/apps/msp/resource/utils/common.go

View check run for this annotation

Codecov / codecov/patch

internal/apps/msp/resource/utils/common.go#L138-L140

Added lines #L138 - L140 were not covered by tests
}
}

target[LabelCoreErdaCloudClusterName] = req.ClusterName

Check warning on line 144 in internal/apps/msp/resource/utils/common.go

View check run for this annotation

Codecov / codecov/patch

internal/apps/msp/resource/utils/common.go#L144

Added line #L144 was not covered by tests
}

func SetAddonErdaLabels(labels map[string]string, req apistructs.ServiceGroupCreateV2Request, spec *apistructs.AddonExtension) {
if labels == nil && spec == nil {
return

Check warning on line 149 in internal/apps/msp/resource/utils/common.go

View check run for this annotation

Codecov / codecov/patch

internal/apps/msp/resource/utils/common.go#L147-L149

Added lines #L147 - L149 were not covered by tests
}
if spec.ShareScopes != nil && len(spec.ShareScopes) > 0 {
labels[LabelAddonErdaCloudScope] = spec.ShareScopes[0]

Check warning on line 152 in internal/apps/msp/resource/utils/common.go

View check run for this annotation

Codecov / codecov/patch

internal/apps/msp/resource/utils/common.go#L151-L152

Added lines #L151 - L152 were not covered by tests
}
labels[LabelAddonErdaCloudId] = req.ID
labels[LabelAddonErdaCloudType] = spec.Name
labels[LabelAddonErdaCloudVersion] = spec.Version

Check warning on line 156 in internal/apps/msp/resource/utils/common.go

View check run for this annotation

Codecov / codecov/patch

internal/apps/msp/resource/utils/common.go#L154-L156

Added lines #L154 - L156 were not covered by tests
}
43 changes: 43 additions & 0 deletions internal/tools/orchestrator/dbclient/msp_tenant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2021 Terminus, 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 dbclient

import "time"

const (
TableMSPTenant = "msp_tenant"
)

type MSPTenant struct {
Id string `gorm:"column:id" db:"id" json:"id" form:"id"` // Tenant id
Type string `gorm:"column:type" db:"type" json:"type" form:"type"` // Tenant type(dop 、msp)
RelatedProjectId string `gorm:"column:related_project_id" db:"related_project_id" json:"related_project_id" form:"related_project_id"` // Project id
RelatedWorkspace string `gorm:"column:related_workspace" db:"related_workspace" json:"related_workspace" form:"related_workspace"` // Workspace( DEV、TEST、STAGING、PROD、DEFAULT)
CreatedAt time.Time `gorm:"column:created_at" db:"created_at" json:"create_time" form:"create_time"` // Create time
UpdatedAt time.Time `gorm:"column:updated_at" db:"updated_at" json:"update_time" form:"update_time"` // Update time
IsDeleted bool `gorm:"column:is_deleted" db:"is_deleted" json:"is_deleted" form:"is_deleted"` // Delete or not
}

func (MSPTenant) TableName() string { return TableMSPTenant }

Check warning on line 33 in internal/tools/orchestrator/dbclient/msp_tenant.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/dbclient/msp_tenant.go#L33

Added line #L33 was not covered by tests

func (db *DBClient) QueryTenantByProjectIDAndWorkspace(projectId, workSpace string) (*MSPTenant, error) {
tenant := MSPTenant{}
err := db.
Model(&tenant).
Where("`related_project_id` = ?", projectId).
Where("`related_workspace` = ?", workSpace).
Find(&tenant).Error
return &tenant, err

Check warning on line 42 in internal/tools/orchestrator/dbclient/msp_tenant.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/dbclient/msp_tenant.go#L35-L42

Added lines #L35 - L42 were not covered by tests
}
186 changes: 186 additions & 0 deletions internal/tools/orchestrator/labels/labels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
// Copyright (c) 2021 Terminus, 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 labels

import (
"encoding/json"

"github.com/sirupsen/logrus"

"github.com/erda-project/erda/apistructs"
"github.com/erda-project/erda/internal/tools/orchestrator/dbclient"
)

// k8s labels
const (
LabelCoreErdaCloudClusterName = "core.erda.cloud/cluster-name"
LabelCoreErdaCloudOrgId = "core.erda.cloud/org-id"
LabelCoreErdaCloudOrgName = "core.erda.cloud/org-name"
LabelCoreErdaCloudAppId = "core.erda.cloud/app-id"
LabelCoreErdaCloudAppName = "core.erda.cloud/app-name"
LabelCoreErdaCloudProjectId = "core.erda.cloud/project-id"
LabelCoreErdaCloudProjectName = "core.erda.cloud/project-name"
LabelCoreErdaCloudRuntimeId = "core.erda.cloud/runtime-id"
LabelCoreErdaCloudServiceName = "core.erda.cloud/service-name"
LabelCoreErdaCloudWorkSpace = "core.erda.cloud/workspace"
LabelCoreErdaCloudServiceType = "core.erda.cloud/service-type"
LabelCoreErdaCloudServiceGroupId = "core.erda.cloud/servicegroup-id"

LabelMonitorErdaCloudTenantId = "monitor.erda.cloud/tenant-id"
LabelMonitorErdaCloudEnabled = "monitor.erda.cloud/enabled"
LabelMonitorErdaCloudExporter = "monitor.erda.cloud/exporter"

LabelDiceClusterName = "DICE_CLUSTER_NAME"
LabelDiceOrgId = "DICE_ORG_ID"
LabelDiceOrgName = "DICE_ORG_NAME"
LabelDiceAppId = "DICE_APPLICATION_ID"
LabelDiceAppName = "DICE_APPLICATION_NAME"
LabelDiceProjectId = "DICE_PROJECT_ID"
LabelDiceProjectName = "DICE_PROJECT_NAME"
LabelDiceRuntimeId = "DICE_RUNTIME_ID"
LabelDiceServiceName = "DICE_SERVICE_NAME"
LabelDiceWorkSpace = "DICE_WORKSPACE"
LabelDiceServiceType = "SERVICE_TYPE"
LabelServiceGroupId = "servicegroup-id"

ServiceEnvPublicHost = "PUBLIC_HOST"

PublicHostTerminusKey = "terminusKey"
)

const (
LabelAddonErdaCloudId = "addon.erda.cloud/id"
LabelAddonErdaCloudScope = "addon.erda.cloud/scope"
LabelAddonErdaCloudType = "addon.erda.cloud/type"
LabelAddonErdaCloudVersion = "addon.erda.cloud/version"
)

var labelMappings = map[string]string{
LabelCoreErdaCloudClusterName: LabelDiceClusterName,
LabelCoreErdaCloudOrgId: LabelDiceOrgId,
LabelCoreErdaCloudOrgName: LabelDiceOrgName,
LabelCoreErdaCloudAppId: LabelDiceAppId,
LabelCoreErdaCloudAppName: LabelDiceAppName,
LabelCoreErdaCloudProjectId: LabelDiceProjectId,
LabelCoreErdaCloudProjectName: LabelDiceProjectName,
LabelCoreErdaCloudRuntimeId: LabelDiceRuntimeId,
LabelCoreErdaCloudServiceName: LabelDiceServiceName,
LabelCoreErdaCloudWorkSpace: LabelDiceWorkSpace,
LabelCoreErdaCloudServiceType: LabelDiceServiceType,
}

// AddonLabelSetter Set labels for addon
type AddonLabelSetter struct {
target map[string]string
source map[string]string
instance *dbclient.AddonInstance
params *apistructs.AddonHandlerCreateItem
}

func NewAddonLabelSetter(target map[string]string, source map[string]string, ins *dbclient.AddonInstance, params *apistructs.AddonHandlerCreateItem) *AddonLabelSetter {
return &AddonLabelSetter{target: target, source: source, instance: ins, params: params}

Check warning on line 93 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L92-L93

Added lines #L92 - L93 were not covered by tests
}

func (a *AddonLabelSetter) SetCoreErdaLabels() *AddonLabelSetter {
if a.source == nil || a.target == nil {
return a

Check warning on line 98 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L96-L98

Added lines #L96 - L98 were not covered by tests
}
for core, dice := range labelMappings {
if v, exist := a.source[dice]; exist {
a.target[core] = v

Check warning on line 102 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L100-L102

Added lines #L100 - L102 were not covered by tests
}
}
return a

Check warning on line 105 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L105

Added line #L105 was not covered by tests
}

func (a *AddonLabelSetter) SetAddonErdaLabels() *AddonLabelSetter {
if a.instance == nil || a.target == nil {
return a

Check warning on line 110 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L108-L110

Added lines #L108 - L110 were not covered by tests
}
a.target[LabelAddonErdaCloudId] = a.instance.ID
a.target[LabelAddonErdaCloudScope] = a.instance.ShareScope
a.target[LabelAddonErdaCloudType] = a.instance.AddonName
a.target[LabelAddonErdaCloudVersion] = a.instance.Version
return a

Check warning on line 116 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L112-L116

Added lines #L112 - L116 were not covered by tests
}

func (a *AddonLabelSetter) SetMonitorErdaCloudLabels() *AddonLabelSetter {
if a.target == nil {
return a

Check warning on line 121 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L119-L121

Added lines #L119 - L121 were not covered by tests
}
if a.params != nil && a.params.TenantId != "" {
a.target[LabelMonitorErdaCloudTenantId] = a.params.TenantId

Check warning on line 124 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L123-L124

Added lines #L123 - L124 were not covered by tests
}
a.target[LabelMonitorErdaCloudEnabled] = "true"
a.target[LabelMonitorErdaCloudExporter] = "true"
return nil

Check warning on line 128 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L126-L128

Added lines #L126 - L128 were not covered by tests
}

// RuntimeLabelSetter Set labels for runtime
type RuntimeLabelSetter struct {
service *apistructs.Service
sg *apistructs.ServiceGroup
labels map[string]string
}

func NewRuntimeLabelSetter(service *apistructs.Service, sg *apistructs.ServiceGroup, labels map[string]string) *RuntimeLabelSetter {
return &RuntimeLabelSetter{service: service, sg: sg, labels: labels}
}

func (r *RuntimeLabelSetter) SetMonitorErdaCloudLabels() *RuntimeLabelSetter {
if r.labels == nil {
r.labels = make(map[string]string)

Check warning on line 144 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L144

Added line #L144 was not covered by tests
}
r.labels[LabelMonitorErdaCloudEnabled] = "true"
r.labels[LabelMonitorErdaCloudExporter] = "true"

if r.service == nil {
return r

Check warning on line 150 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L150

Added line #L150 was not covered by tests
}

if publicHost, exists := r.service.Env[ServiceEnvPublicHost]; exists {
var publicHostMap map[string]string
if err := json.Unmarshal([]byte(publicHost), &publicHostMap); err != nil {
logrus.Errorf("failed to unmarshal public host map for service: %v, err: %v", r.service.Name, err)

Check warning on line 156 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L154-L156

Added lines #L154 - L156 were not covered by tests
}
if terminusKey, exists := publicHostMap[PublicHostTerminusKey]; exists {
r.labels[LabelMonitorErdaCloudTenantId] = terminusKey

Check warning on line 159 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L158-L159

Added lines #L158 - L159 were not covered by tests
}
}
return r
}

func (r *RuntimeLabelSetter) SetCoreErdaLabels() *RuntimeLabelSetter {
if r.labels == nil {
r.labels = make(map[string]string)

Check warning on line 167 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L167

Added line #L167 was not covered by tests
}
if r.service != nil {
for coreLabel, diceLabel := range labelMappings {
if value, exists := r.service.Labels[diceLabel]; exists {
r.labels[coreLabel] = value

Check warning on line 172 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L172

Added line #L172 was not covered by tests
}
}
}

if sgId, exists := r.labels[LabelServiceGroupId]; exists {
r.labels[LabelCoreErdaCloudServiceGroupId] = sgId

Check warning on line 178 in internal/tools/orchestrator/labels/labels.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/labels/labels.go#L178

Added line #L178 was not covered by tests
}

if r.sg != nil && r.sg.ID != "" {
r.labels[LabelCoreErdaCloudServiceGroupId] = r.sg.ID
}

return r
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/erda-project/erda/apistructs"
"github.com/erda-project/erda/internal/tools/orchestrator/labels"
"github.com/erda-project/erda/internal/tools/orchestrator/scheduler/executor/plugins/k8s/k8sapi"
"github.com/erda-project/erda/internal/tools/orchestrator/scheduler/executor/plugins/k8s/toleration"
"github.com/erda-project/erda/internal/tools/orchestrator/scheduler/executor/plugins/k8s/types"
Expand Down Expand Up @@ -93,9 +94,27 @@
return errors.New(reason)
}
}
oldDaemon, err := k.getDaemonSet(ds.Namespace, ds.Name)
if err != nil {
return errors.Errorf("failed to merge daemonset labels, name: %s, (%v)", service.Name, err)

Check warning on line 99 in internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go#L97-L99

Added lines #L97 - L99 were not covered by tests
}
// merge DaemonSet labels
k.mergeLabels(ds.Labels, oldDaemon.Labels)

Check warning on line 102 in internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go#L102

Added line #L102 was not covered by tests
// merge Pod labels
k.mergeLabels(ds.Spec.Template.Labels, oldDaemon.Spec.Template.Labels)

Check warning on line 104 in internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go#L104

Added line #L104 was not covered by tests

return k.ds.Update(ds)
}

func (k *Kubernetes) mergeLabels(newLabels map[string]string, oldLabels map[string]string) {
for key, value := range oldLabels {
if _, ok := newLabels[key]; ok {
continue

Check warning on line 112 in internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go#L109-L112

Added lines #L109 - L112 were not covered by tests
}
newLabels[key] = value

Check warning on line 114 in internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go#L114

Added line #L114 was not covered by tests
}
}

func (k *Kubernetes) getDaemonSetDeltaResource(ctx context.Context, ds *appsv1.DaemonSet) (deltaCPU, deltaMemory int64, err error) {
oldDs, err := k.k8sClient.ClientSet.AppsV1().DaemonSets(ds.Namespace).Get(ctx, ds.Name, metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -244,13 +263,6 @@
}
podAnnotations(service, daemonset.Spec.Template.Annotations)

// inherit Labels from service.Labels and service.DeploymentLabels
err = inheritDaemonsetLabels(service, daemonset)
if err != nil {
logrus.Errorf("failed to set labels for service %s for Pod with error: %v\n", service.Name, err)
return nil, err
}

// set pod Annotations from service.Labels and service.DeploymentLabels
setPodAnnotationsFromLabels(service, daemonset.Spec.Template.Annotations)

Expand Down Expand Up @@ -289,6 +301,14 @@

SetPodAnnotationsBaseContainerEnvs(daemonset.Spec.Template.Spec.Containers[0], daemonset.Spec.Template.Annotations)

labels.NewRuntimeLabelSetter(service, sg, daemonset.Labels).
SetCoreErdaLabels().
SetMonitorErdaCloudLabels()

Check warning on line 306 in internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go#L304-L306

Added lines #L304 - L306 were not covered by tests

labels.NewRuntimeLabelSetter(service, sg, daemonset.Spec.Template.Labels).
SetCoreErdaLabels().
SetMonitorErdaCloudLabels()

Check warning on line 310 in internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go

View check run for this annotation

Codecov / codecov/patch

internal/tools/orchestrator/scheduler/executor/plugins/k8s/daemonset.go#L308-L310

Added lines #L308 - L310 were not covered by tests

secrets, err := k.CopyErdaSecrets("secret", service.Namespace)
if err != nil {
logrus.Errorf("failed to copy secret: %v", err)
Expand Down
Loading
Loading