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

fix: fix panic in ConfigPatchRequestController #755

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions client/pkg/infra/provision/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"gopkg.in/yaml.v3"

"github.com/siderolabs/omni/client/api/omni/specs"
"github.com/siderolabs/omni/client/pkg/omni/resources"
"github.com/siderolabs/omni/client/pkg/omni/resources/infra"
"github.com/siderolabs/omni/client/pkg/omni/resources/omni"
)
Expand Down Expand Up @@ -143,7 +142,7 @@ func (context *Context[T]) UnmarshalProviderData(dest any) error {

// CreateConfigPatch for the provisioned machine.
func (context *Context[T]) CreateConfigPatch(ctx context.Context, name string, data []byte) error {
r := infra.NewConfigPatchRequest(resources.InfraProviderNamespace, name)
r := infra.NewConfigPatchRequest(name)

providerID, ok := context.machineRequest.Metadata().Labels().Get(omni.LabelInfraProviderID)
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions client/pkg/omni/resources/infra/config_patch_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
)

// NewConfigPatchRequest creates new ConfigPatchRequest resource.
func NewConfigPatchRequest(ns string, id resource.ID) *ConfigPatchRequest {
func NewConfigPatchRequest(id resource.ID) *ConfigPatchRequest {
return typed.NewResource[ConfigPatchRequestSpec, ConfigPatchRequestExtension](
resource.NewMetadata(ns, ConfigPatchRequestType, id, resource.VersionUndefined),
resource.NewMetadata(resources.InfraProviderNamespace, ConfigPatchRequestType, id, resource.VersionUndefined),
protobuf.NewResourceSpec(&specs.ConfigPatchSpec{}),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewInfraProviderConfigPatchController() *InfraProviderConfigPatchController
return omni.NewConfigPatch(resources.DefaultNamespace, request.Metadata().ID())
},
UnmapMetadataFunc: func(configPatch *omni.ConfigPatch) *infra.ConfigPatchRequest {
return infra.NewConfigPatchRequest(resources.DefaultNamespace, configPatch.Metadata().ID())
return infra.NewConfigPatchRequest(configPatch.Metadata().ID())
},
TransformFunc: func(ctx context.Context, r controller.Reader, _ *zap.Logger, request *infra.ConfigPatchRequest, patch *omni.ConfigPatch) error {
machineRequestID, ok := request.Metadata().Labels().Get(omni.LabelMachineRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"github.com/siderolabs/omni/client/pkg/omni/resources"
"github.com/siderolabs/omni/client/pkg/omni/resources/infra"
"github.com/siderolabs/omni/client/pkg/omni/resources/omni"
omnictrl "github.com/siderolabs/omni/internal/backend/runtime/omni/controllers/omni"
Expand All @@ -38,7 +37,7 @@ func (suite *InfraProviderConfigPatchControllerSuite) TestReconcile() {
id := "patch"
requestID := "request-1"

request := infra.NewConfigPatchRequest(resources.InfraProviderNamespace, id)
request := infra.NewConfigPatchRequest(id)
request.Metadata().Labels().Set(omni.LabelMachineRequest, requestID)
request.Metadata().Labels().Set(omni.LabelInfraProviderID, provider)

Expand Down
2 changes: 1 addition & 1 deletion internal/backend/runtime/omni/infraprovider/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestInfraProviderAccess(t *testing.T) {

// ConfigPatchRequest

cpr := infra.NewConfigPatchRequest(resources.InfraProviderNamespace, "test-cpr")
cpr := infra.NewConfigPatchRequest("test-cpr")

// create
assert.NoError(t, st.Create(ctx, cpr))
Expand Down