Skip to content
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
6 changes: 6 additions & 0 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3834,6 +3834,12 @@ func (c *Client) UpdateClusterMaintenanceConfig(ctx context.Context, cmc types.C
return trail.FromGRPC(err)
}

// DeleteClusterMaintenanceConfig deletes the current maintenance window config singleton.
func (c *Client) DeleteClusterMaintenanceConfig(ctx context.Context) error {
_, err := c.grpc.DeleteClusterMaintenanceConfig(ctx, &emptypb.Empty{})
return trail.FromGRPC(err)
}

// integrationsClient returns an unadorned Integration client, using the underlying
// Auth gRPC connection.
func (c *Client) integrationsClient() integrationpb.IntegrationServiceClient {
Expand Down
1,636 changes: 837 additions & 799 deletions api/client/proto/authservice.pb.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions api/proto/teleport/legacy/client/proto/authservice.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2965,4 +2965,7 @@ service AuthService {

// UpdateClusterMaintenanceConfig updates the current maintenance window config singleton.
rpc UpdateClusterMaintenanceConfig(types.ClusterMaintenanceConfigV1) returns (google.protobuf.Empty);

// DeleteClusterMaintenanceConfig deletes the current maintenance window config singleton.
rpc DeleteClusterMaintenanceConfig(google.protobuf.Empty) returns (google.protobuf.Empty);
}
13 changes: 13 additions & 0 deletions lib/auth/auth_with_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -6819,6 +6819,19 @@ func (a *ServerWithRoles) UpdateClusterMaintenanceConfig(ctx context.Context, cm
return a.authServer.UpdateClusterMaintenanceConfig(ctx, cmc)
}

func (a *ServerWithRoles) DeleteClusterMaintenanceConfig(ctx context.Context) error {
if err := a.action(apidefaults.Namespace, types.KindClusterMaintenanceConfig, types.VerbDelete); err != nil {
return trace.Wrap(err)
}
if modules.GetModules().Features().Cloud {
// maintenance configuration in cloud is derived from values stored in
// an external cloud-specific database.
return trace.NotImplemented("cloud clusters do not support custom cluster maintenance resources")
}

return a.authServer.DeleteClusterMaintenanceConfig(ctx)
}

// NewAdminAuthServer returns auth server authorized as admin,
// used for auth server cached access
func NewAdminAuthServer(authServer *Server, alog events.AuditLogSessionStreamer) (ClientI, error) {
Expand Down
14 changes: 14 additions & 0 deletions lib/auth/grpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5183,6 +5183,20 @@ func (g *GRPCServer) UpdateClusterMaintenanceConfig(ctx context.Context, cmc *ty
return &emptypb.Empty{}, nil
}

// DeleteClusterMaintenanceConfig deletes the current maintenance config singleton.
func (g *GRPCServer) DeleteClusterMaintenanceConfig(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) {
auth, err := g.authenticate(ctx)
if err != nil {
return nil, trace.Wrap(err)
}

if err := auth.DeleteClusterMaintenanceConfig(ctx); err != nil {
return nil, trace.Wrap(err)
}

return &emptypb.Empty{}, nil
}

// GetBackend returns the backend from the underlying auth server.
func (g *GRPCServer) GetBackend() backend.Backend {
return g.AuthServer.bk
Expand Down
2 changes: 2 additions & 0 deletions lib/services/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@ type ClusterConfiguration interface {
GetClusterMaintenanceConfig(ctx context.Context) (types.ClusterMaintenanceConfig, error)
// UpdateClusterMaintenanceConfig updates the maintenance config singleton.
UpdateClusterMaintenanceConfig(ctx context.Context, cfg types.ClusterMaintenanceConfig) error
// DeleteClusterMaintenanceConfig deletes the maintenance config singleton.
DeleteClusterMaintenanceConfig(ctx context.Context) error
}
9 changes: 9 additions & 0 deletions lib/services/local/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,15 @@ func (s *ClusterConfigurationService) UpdateClusterMaintenanceConfig(ctx context
return trace.Wrap(err)
}

// DeleteClusterMaintenanceConfig deletes the maintenance config singleton resource.
func (s *ClusterConfigurationService) DeleteClusterMaintenanceConfig(ctx context.Context) error {
err := s.Delete(ctx, backend.Key(clusterConfigPrefix, maintenancePrefix))
if err != nil {
return trace.Wrap(err)
}
return nil
}

const (
clusterConfigPrefix = "cluster_configuration"
namePrefix = "name"
Expand Down
6 changes: 6 additions & 0 deletions tool/tctl/common/resource_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ func (rc *ResourceCommand) createAccessList(ctx context.Context, client auth.Cli
func (rc *ResourceCommand) Delete(ctx context.Context, client auth.ClientI) (err error) {
singletonResources := []string{
types.KindClusterAuthPreference,
types.KindClusterMaintenanceConfig,
types.KindClusterNetworkingConfig,
types.KindSessionRecordingConfig,
types.KindInstaller,
Expand Down Expand Up @@ -1068,6 +1069,11 @@ func (rc *ResourceCommand) Delete(ctx context.Context, client auth.ClientI) (err
return trace.Wrap(err)
}
fmt.Printf("cluster auth preference has been reset to defaults\n")
case types.KindClusterMaintenanceConfig:
if err := client.DeleteClusterMaintenanceConfig(ctx); err != nil {
Comment thread
greedy52 marked this conversation as resolved.
return trace.Wrap(err)
}
fmt.Printf("cluster maintenance configuration has been deleted\n")
case types.KindClusterNetworkingConfig:
if err = resetClusterNetworkingConfig(ctx, client); err != nil {
return trace.Wrap(err)
Expand Down