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: add cloud provider resources and role #449

Merged
merged 1 commit into from
Jul 28, 2024

Conversation

utkuozdemir
Copy link
Member

Add the new resources for the cloud provider feature: CloudConfigs, MachineRequests and MachineRequestStatuses.

Add a new role, CloudProvider with access to the resources a cloud provider plugin requires.

Introduce the concept of "cloud provider service accounts" which are a special type of service accounts in the format cloud-provider:<id>. They must have the CloudProvider role and their id is matched against the label omni.sidero.dev/cloud-provider-id label on the MachineRequest* type resources.

@utkuozdemir utkuozdemir marked this pull request as ready for review July 8, 2024 21:33
@utkuozdemir utkuozdemir changed the title feat: add cloud provider resources and role WIP: feat: add cloud provider resources and role Jul 10, 2024
@utkuozdemir utkuozdemir marked this pull request as draft July 10, 2024 07:28
@utkuozdemir utkuozdemir force-pushed the cloud-provider-groundwork branch 3 times, most recently from 5c7aaee to 3fc6dbe Compare July 11, 2024 10:15
@utkuozdemir utkuozdemir force-pushed the cloud-provider-groundwork branch 2 times, most recently from 9753e33 to 85869eb Compare July 13, 2024 23:44
@utkuozdemir utkuozdemir changed the title WIP: feat: add cloud provider resources and role feat: add cloud provider resources and role Jul 15, 2024
@utkuozdemir utkuozdemir marked this pull request as ready for review July 15, 2024 08:47
Comment on lines +261 to +298
func (st *State) filterEvents(ctx context.Context, cloudProviderID string, eventCh chan<- state.Event) chan state.Event {
innerEventCh := make(chan state.Event)

panichandler.Go(func() {
defer close(eventCh)

for {
select {
case <-ctx.Done():
return

case event, ok := <-innerEventCh:
if !ok {
return
}

if event.Type == state.Bootstrapped || event.Type == state.Errored {
channel.SendWithContext(ctx, eventCh, event)

continue
}

if event.Resource != nil {
resCloudProviderID, cpOk := event.Resource.Metadata().Labels().Get(omni.LabelCloudProviderID)
if !cpOk || cloudProviderID != resCloudProviderID {
continue // discard
}
}

channel.SendWithContext(ctx, eventCh, event)
}
}
}, st.logger)

return innerEventCh
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@smira I am not sure if I got this filtering logic right, pls have a look :)

@utkuozdemir utkuozdemir force-pushed the cloud-provider-groundwork branch 3 times, most recently from 37b0505 to 5552da1 Compare July 17, 2024 08:12
@utkuozdemir
Copy link
Member Author

/m

@utkuozdemir
Copy link
Member Author

/m

Add the new resources for the cloud provider feature: `CloudConfigs`, `MachineRequests` and `MachineRequestStatuses`.

Add a new role, `CloudProvider` with access to the resources a cloud provider plugin requires.

Introduce the concept of "cloud provider service accounts" which are a special type of service accounts in the format `cloud-provider:<id>`. They must have the `CloudProvider` role and their id is matched against the label `omni.sidero.dev/cloud-provider-id` label on the `MachineRequest*` type resources.

Signed-off-by: Utku Ozdemir <[email protected]>
@utkuozdemir
Copy link
Member Author

/m

@talos-bot talos-bot merged commit 4ec7a43 into siderolabs:main Jul 28, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants