Skip to content

Support nic lingjun node type#1585

Merged
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
mowangdk:feature/support_nic_lingjun
Dec 23, 2025
Merged

Support nic lingjun node type#1585
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
mowangdk:feature/support_nic_lingjun

Conversation

@mowangdk

Copy link
Copy Markdown
Contributor

What type of PR is this?

What this PR does / why we need it:

Support nic type lingjun node

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 15, 2025
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 15, 2025
@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch from 3998323 to 7939ef8 Compare December 15, 2025 08:34
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 15, 2025
@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch from 7939ef8 to d829b22 Compare December 15, 2025 08:37
@mowangdk

Copy link
Copy Markdown
Contributor Author

/test all

@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch from a7043fc to 1275539 Compare December 15, 2025 13:08
@mowangdk

Copy link
Copy Markdown
Contributor Author

/test all

@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch from 1275539 to cc011d4 Compare December 15, 2025 13:12
@mowangdk mowangdk marked this pull request as ready for review December 15, 2025 13:13
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 15, 2025
Comment thread pkg/cloud/metadata/lingjun.go Outdated
Comment thread pkg/cloud/metadata/lingjun_test.go Outdated
Comment thread pkg/cloud/metadata/lingjun_test.go Outdated
Comment thread pkg/cloud/metadata/metadata.go Outdated
}
data, err := os.ReadFile(LingjunConfigFile)
if err != nil {
klog.V(1).InfoS("can't read lingjun metadata file, use env metadata only", "file", LingjunConfigFile, "error", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should log "no such file" error at V(3), and other errors with klog.Error

@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch 3 times, most recently from 0d98d7c to 1680d9b Compare December 17, 2025 07:35
Comment thread pkg/cloud/metadata/lingjun_test.go Outdated
if data, exists := LingjunTestCases[caseName]; exists {
return []byte(data)
}
// Return default case if not found

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so complex.. Just don't make it not found.

Comment thread pkg/cloud/metadata/lingjun.go Outdated
NimitzInterface []string `json:"NimitzInterface"`
}

func NewLingJunMetadata(data []byte) (*LingjunMetaData, error) {

@huww98 huww98 Dec 17, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we hide all the error handling in this func? e.g. just pass in a path, log and return nil on error. Then we just need this in NewMetadata:

if lm := NewLingJunMetadata(path); lm != nil {
	defaultMetadata.providers = append(defaultMetadata.providers, newImmutableProvider(lm, "lingjun"))
}

So that lingjun.go is more self-contained.

@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch 5 times, most recently from 52d808a to 4f73aa0 Compare December 17, 2025 09:52
Comment thread pkg/cloud/metadata/lingjun_test.go Outdated

func TestNewLingJunMetadata(t *testing.T) {
// Create a temporary directory for test files
tempDir := t.TempDir()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to each test case, to avoid any possibility of interference between different cases.

Comment thread pkg/cloud/metadata/lingjun_test.go Outdated
Comment on lines +49 to +52
LingjunConfigFile = filepath.Join(tempDir, "lingjun_config_standard")
defer func() {
LingjunConfigFile = originalConfigFile
}()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just pass LingjunConfigFile into NewLingJunMetadata? Replacing global variable should only be used as last resort, as it prevents parallel test.

Comment on lines +145 to +152
if err != nil {
if errors.Is(err, os.ErrNotExist) {
klog.V(3).InfoS("lingjun metadata file does not exist, use env metadata only", "file", LingjunConfigFile)
} else {
klog.ErrorS(err, "Failed to read lingjun metadatafile", "file", LingjunConfigFile)
}
return defaultMetadata
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but I'd prefer these code to also go into NewLingJunMetadata, so that we can have test coverage over it.

Comment thread pkg/disk/utils.go Outdated
return getLingjunAvailableDiskCount(efloC, lingjunNodeId)
count, err := getLingjunAvailableDiskCount(efloC, lingjunNodeId)
if err != nil {
klog.ErrorS(err, "getAvailableDiskCount: failed to get lingjun available disk count", "lingjunID", lingjunNodeId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to ignore all errors? Can we be more specific here?

Comment thread pkg/disk/utils_test.go Outdated
name: "empty_node_type",
lingjunID: "node-123",
setupMock: func() {
// 模拟返回的 NodeType 为空字符串

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this case. Do you expect it to return success?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please avoid Chinese in this repo.

Comment thread pkg/cloud/metadata/lingjun.go Outdated
EniMac string `json:"EniMac"`
AckNicName string `json:"AckNicName"`
NimitzNetworkMode string `json:"NimitzNetworkMode"`
NimitzInterface []string `json:"NimitzInterface"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about remove fields that we don't use? This way, we:

  • reduce the possibility of being breaked by changes of this file.
  • slightly improve the performance as we don't need to deserialize these extra fields.

@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch 2 times, most recently from 93566a2 to 804a2be Compare December 18, 2025 14:51
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 18, 2025
@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch 4 times, most recently from 5d900f7 to 1bf2f25 Compare December 22, 2025 12:21
Comment thread pkg/disk/utils_test.go Outdated
nodeType := "ebmgvn"
lingjunNodeResp := &eflo.DescribeNodeResponse{
Body: &eflo.DescribeNodeResponseBody{
NodeType: &nodeType,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NodeType: &nodeType,
NodeType: ptr.To("ebmgvn"),

Also avoid Chinese.

Comment thread pkg/disk/utils_test.go Outdated
Comment on lines +1185 to +1188
ctrl := gomock.NewController(t)
defer ctrl.Finish()

mockEFLOClient := cloud.NewMockEFLOInterface(ctrl)

@huww98 huww98 Dec 22, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd better create a new ctrl/mockEFLOClient for each case, to avoid any interference.

Besides, Finish() is not nessesary:

New in go1.14+, if you are passing a *testing.T into NewController function you no longer need to call ctrl.Finish() in your test methods.

Comment thread pkg/bmcpfs/controllerserver_test.go Outdated
volumeHandle: "fs-12345+",
expectedFsId: "fs-12345",
expectedFsetId: "",
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but I'm not sure if you add this by mistake? This is unrelated to other changes.

@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch 2 times, most recently from 307b5a5 to d0a937c Compare December 22, 2025 13:15
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mowangdk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mowangdk mowangdk force-pushed the feature/support_nic_lingjun branch from d0a937c to e3aec60 Compare December 23, 2025 08:50
@huww98

huww98 commented Dec 23, 2025

Copy link
Copy Markdown
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 23, 2025
@k8s-ci-robot k8s-ci-robot merged commit becf3b9 into kubernetes-sigs:master Dec 23, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants