-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] [ML] Deployment Handler (#1500)
- Loading branch information
Showing
23 changed files
with
804 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// 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. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
|
||
package v1alpha1 | ||
|
||
import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" | ||
|
||
const ( | ||
ExtensionDeploymentFoundCondition api.ConditionType = "DeploymentFound" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// 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. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
|
||
package kubernetes | ||
|
||
import ( | ||
"github.com/rs/zerolog" | ||
|
||
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared" | ||
"github.com/arangodb/kube-arangodb/pkg/util/errors" | ||
"github.com/arangodb/kube-arangodb/pkg/util/kclient" | ||
) | ||
|
||
func ML() shared.Factory { | ||
return shared.NewFactory("ml", true, ml) | ||
} | ||
|
||
func ml(logger zerolog.Logger, files chan<- shared.File) error { | ||
k, ok := kclient.GetDefaultFactory().Client() | ||
if !ok { | ||
return errors.Newf("Client is not initialised") | ||
} | ||
|
||
if err := mlExtensions(logger, files, k); err != nil { | ||
logger.Err(err).Msgf("Error while collecting arango ml extension") | ||
return err | ||
} | ||
|
||
if err := mlStorages(logger, files, k); err != nil { | ||
logger.Err(err).Msgf("Error while collecting arango ml storage") | ||
return err | ||
} | ||
|
||
if err := mlBatchJobs(logger, files, k); err != nil { | ||
logger.Err(err).Msgf("Error while collecting arango ml batch jobs") | ||
return err | ||
} | ||
|
||
if err := mlCronJobs(logger, files, k); err != nil { | ||
logger.Err(err).Msgf("Error while collecting arango ml cron jobs") | ||
return err | ||
} | ||
|
||
return nil | ||
} |
73 changes: 73 additions & 0 deletions
73
pkg/debug_package/generators/kubernetes/arango_ml_batch_job.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// 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. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
|
||
package kubernetes | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/rs/zerolog" | ||
|
||
mlApi "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1" | ||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli" | ||
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared" | ||
"github.com/arangodb/kube-arangodb/pkg/util/errors" | ||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors" | ||
"github.com/arangodb/kube-arangodb/pkg/util/kclient" | ||
) | ||
|
||
func mlBatchJobs(logger zerolog.Logger, files chan<- shared.File, client kclient.Client) error { | ||
batchjobs, err := listMLBatchJobs(client) | ||
if err != nil { | ||
if kerrors.IsForbiddenOrNotFound(err) { | ||
return nil | ||
} | ||
|
||
return err | ||
} | ||
|
||
if err := errors.ExecuteWithErrorArrayP2(mlBatchJob, client, files, batchjobs...); err != nil { | ||
logger.Err(err).Msgf("Error while collecting arango ml batchjobs") | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func mlBatchJob(client kclient.Client, files chan<- shared.File, ext *mlApi.ArangoMLBatchJob) error { | ||
files <- shared.NewYAMLFile(fmt.Sprintf("kubernetes/arango/ml/batchjobs/%s.yaml", ext.GetName()), func() ([]interface{}, error) { | ||
return []interface{}{ext}, nil | ||
}) | ||
|
||
return nil | ||
} | ||
|
||
func listMLBatchJobs(client kclient.Client) ([]*mlApi.ArangoMLBatchJob, error) { | ||
return ListObjects[*mlApi.ArangoMLBatchJobList, *mlApi.ArangoMLBatchJob](context.Background(), client.Arango().MlV1alpha1().ArangoMLBatchJobs(cli.GetInput().Namespace), func(result *mlApi.ArangoMLBatchJobList) []*mlApi.ArangoMLBatchJob { | ||
q := make([]*mlApi.ArangoMLBatchJob, len(result.Items)) | ||
|
||
for id, e := range result.Items { | ||
q[id] = e.DeepCopy() | ||
} | ||
|
||
return q | ||
}) | ||
} |
73 changes: 73 additions & 0 deletions
73
pkg/debug_package/generators/kubernetes/arango_ml_cron_job.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2023 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// 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. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
|
||
package kubernetes | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/rs/zerolog" | ||
|
||
mlApi "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1" | ||
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli" | ||
"github.com/arangodb/kube-arangodb/pkg/debug_package/shared" | ||
"github.com/arangodb/kube-arangodb/pkg/util/errors" | ||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors" | ||
"github.com/arangodb/kube-arangodb/pkg/util/kclient" | ||
) | ||
|
||
func mlCronJobs(logger zerolog.Logger, files chan<- shared.File, client kclient.Client) error { | ||
cronjobs, err := listMLCronJobs(client) | ||
if err != nil { | ||
if kerrors.IsForbiddenOrNotFound(err) { | ||
return nil | ||
} | ||
|
||
return err | ||
} | ||
|
||
if err := errors.ExecuteWithErrorArrayP2(mlCronJob, client, files, cronjobs...); err != nil { | ||
logger.Err(err).Msgf("Error while collecting arango ml cronjobs") | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func mlCronJob(client kclient.Client, files chan<- shared.File, ext *mlApi.ArangoMLCronJob) error { | ||
files <- shared.NewYAMLFile(fmt.Sprintf("kubernetes/arango/ml/cronjobs/%s.yaml", ext.GetName()), func() ([]interface{}, error) { | ||
return []interface{}{ext}, nil | ||
}) | ||
|
||
return nil | ||
} | ||
|
||
func listMLCronJobs(client kclient.Client) ([]*mlApi.ArangoMLCronJob, error) { | ||
return ListObjects[*mlApi.ArangoMLCronJobList, *mlApi.ArangoMLCronJob](context.Background(), client.Arango().MlV1alpha1().ArangoMLCronJobs(cli.GetInput().Namespace), func(result *mlApi.ArangoMLCronJobList) []*mlApi.ArangoMLCronJob { | ||
q := make([]*mlApi.ArangoMLCronJob, len(result.Items)) | ||
|
||
for id, e := range result.Items { | ||
q[id] = e.DeepCopy() | ||
} | ||
|
||
return q | ||
}) | ||
} |
Oops, something went wrong.