Skip to content

Commit

Permalink
improved resources structures and coherence, fixed some bugs, added s…
Browse files Browse the repository at this point in the history
…upport for discovery without selector
  • Loading branch information
cannarelladev committed Oct 17, 2023
1 parent e2cac2a commit b2d1e8f
Show file tree
Hide file tree
Showing 43 changed files with 628 additions and 325 deletions.
192 changes: 141 additions & 51 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build Pipeline
on:
push:
tags:
- 'v*'
- "v*"
branches:
- main

Expand All @@ -23,52 +23,52 @@ jobs:
architectures: ${{ steps.configure.outputs.architectures }}
pr-number: ${{ steps.configure.outputs.pr-number }}
steps:
- name: Get the version
id: get_version
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
if: startsWith(github.ref, 'refs/tags/v')
- name: Configure
id: configure
run: |
# The ref of the commit to checkout (do not use the merge commit if repository dispatch)
if [ "${{ github.event_name }}" == "repository_dispatch" ]; then
echo "master=false" >> $GITHUB_OUTPUT
echo "architectures=linux/amd64" >> $GITHUB_OUTPUT
echo "commit-ref=${{ github.event.client_payload.pull_request.head.sha }}" >> $GITHUB_OUTPUT
echo "pr-number=${{ github.event.client_payload.github.payload.issue.number }}" >> $GITHUB_OUTPUT
elif [ "${{ steps.get_version.outputs.VERSION }}" != "" ]; then
echo "master=false" >> $GITHUB_OUTPUT
echo "architectures=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
echo "commit-ref=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_OUTPUT
else
echo "master=true" >> $GITHUB_OUTPUT
echo "architectures=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
echo "commit-ref=${{ github.sha }}" >> $GITHUB_OUTPUT
fi
# The suffix to append to the repository name if not triggered by a push for a release
([[ "${{ steps.get_version.outputs.VERSION }}" == "" ]] && \
echo "repo-suffix=-ci" ||
echo "repo-suffix=") >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" != "repository_dispatch" ]; then
echo "repo-name=${{ github.repository }}" >> $GITHUB_OUTPUT
else
echo "repo-name=${{ github.event.client_payload.github.payload.repository.full_name }}" >> $GITHUB_OUTPUT
fi
# Since we are using a repository-dispatch event, we have to explicitly set a run check. We initialize it to a "pending" state.
# - uses: octokit/[email protected]
# name: "Initialize run check to 'pending (For PR-only)"
# with:
# route: POST /repos/${{ github.repository }}/statuses/${{ steps.configure.outputs.commit-ref }}
# state: "pending"
# description: "Component build status"
# context: "Components building"
# target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if: ${{ github.event_name == 'repository_dispatch' }}
- name: Get the version
id: get_version
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
if: startsWith(github.ref, 'refs/tags/v')
- name: Configure
id: configure
run: |
# The ref of the commit to checkout (do not use the merge commit if repository dispatch)
if [ "${{ github.event_name }}" == "repository_dispatch" ]; then
echo "master=false" >> $GITHUB_OUTPUT
echo "architectures=linux/amd64" >> $GITHUB_OUTPUT
echo "commit-ref=${{ github.event.client_payload.pull_request.head.sha }}" >> $GITHUB_OUTPUT
echo "pr-number=${{ github.event.client_payload.github.payload.issue.number }}" >> $GITHUB_OUTPUT
elif [ "${{ steps.get_version.outputs.VERSION }}" != "" ]; then
echo "master=false" >> $GITHUB_OUTPUT
echo "architectures=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
echo "commit-ref=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_OUTPUT
else
echo "master=true" >> $GITHUB_OUTPUT
echo "architectures=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
echo "commit-ref=${{ github.sha }}" >> $GITHUB_OUTPUT
fi
# The suffix to append to the repository name if not triggered by a push for a release
([[ "${{ steps.get_version.outputs.VERSION }}" == "" ]] && \
echo "repo-suffix=-ci" ||
echo "repo-suffix=") >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" != "repository_dispatch" ]; then
echo "repo-name=${{ github.repository }}" >> $GITHUB_OUTPUT
else
echo "repo-name=${{ github.event.client_payload.github.payload.repository.full_name }}" >> $GITHUB_OUTPUT
fi
# Since we are using a repository-dispatch event, we have to explicitly set a run check. We initialize it to a "pending" state.
# - uses: octokit/[email protected]
# name: "Initialize run check to 'pending (For PR-only)"
# with:
# route: POST /repos/${{ github.repository }}/statuses/${{ steps.configure.outputs.commit-ref }}
# state: "pending"
# description: "Component build status"
# context: "Components building"
# target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if: ${{ github.event_name == 'repository_dispatch' }}

build:
permissions:
Expand All @@ -81,9 +81,9 @@ jobs:
fail-fast: false
matrix:
component:
- rear-manager
- rear-controller
- local-resource-manager
- rear-manager
- rear-controller
- local-resource-manager
steps:
- name: Set up QEMU
uses: docker/[email protected]
Expand Down Expand Up @@ -140,4 +140,94 @@ jobs:
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
post-build:
runs-on: ubuntu-latest
needs: [build, configure]
steps:
# Since we are using a repository-dispatch event, we have to explicitly set a run check. We update it to the actual status.
- uses: octokit/[email protected]
name: "Set the PR check status (For PR-only)"
with:
route: POST /repos/${{ github.repository }}/statuses/${{ needs.configure.outputs.commit-ref }}
state: "${{ needs.build.result }}"
description: "Component build status"
context: "Components building"
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }}
if: ${{ !cancelled() && github.event_name == 'repository_dispatch' }}

release:
runs-on: ubuntu-latest
needs: [build, configure]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# The changelog generation requires the entire history
fetch-depth: 0
ref: "${{ needs.configure.outputs.commit-ref }}"
repository: "${{ needs.configure.outputs.repo-name }}"
persist-credentials: false

- name: Get the latest Fluidos release
uses: pozetroninc/[email protected]
id: last-release
with:
repository: ${{ github.repository }}
excludes: prerelease, draft

- name: Configure Git
run: |
git config user.name "adamjensenbot"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.8.1

- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: "${{ needs.configure.outputs.commit-ref }}"
version_extractor_regex: "v(.*)$"

- name: Download chart releaser
run: |
curl -sSL "https://github.com/helm/chart-releaser/releases/download/v1.4.0/chart-releaser_1.4.0_linux_amd64.tar.gz" | tar -xz
- name: Package helm chart
run: |
# the output should be in the .cr-release-packages since cr index expects to find it there to create the helm index
helm package deployments/node --version "${{ needs.configure.outputs.commit-ref }}" --app-version "${{ needs.configure.outputs.commit-ref }}" --destination .cr-release-packages
# we need to upload only helm artifacts first, to make the index updater to work
- uses: ncipollo/release-action@v1
with:
artifacts: ".cr-release-packages/*"
generateReleaseNotes: true
token: ${{ secrets.CI_TOKEN }}
allowUpdates: true
tag: ${{ needs.configure.outputs.commit-ref }}
name: ${{ needs.configure.outputs.commit-ref }}
prerelease: ${{ steps.semver_parser.outputs.prerelease != '' }}

- name: Update Helm index
run: |
repo=$(cut -d '/' -f 2 <<< "$GITHUB_REPOSITORY")
owner=$(cut -d '/' -f 1 <<< "$GITHUB_REPOSITORY")
# Update index and push to github pages
./cr index \
--owner "$owner" \
--git-repo "$repo" \
--release-name-template "${{ needs.configure.outputs.commit-ref }}" \
--token "${{ secrets.GITHUB_TOKEN }}" \
--index-path index.yaml \
--pages-index-path index.yaml \
--push
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ config
*.swp
*.swo
*~
*.tgz
#*.tgz
.vscode
.devcontainer
.DS_Store
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ rbacs: controller-gen
# Install gci if not available
gci:
ifeq (, $(shell which gci))
@go install github.com/daixiang0/[email protected].0
@go install github.com/daixiang0/[email protected].2
GCI=$(GOBIN)/gci
else
GCI=$(shell which gci)
Expand All @@ -59,7 +59,7 @@ fmt: gci addlicense
# Install golangci-lint if not available
golangci-lint:
ifeq (, $(shell which golangci-lint))
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2
GOLANGCILINT=$(GOBIN)/golangci-lint
else
GOLANGCILINT=$(shell which golangci-lint)
Expand Down
2 changes: 1 addition & 1 deletion apis/advertisement/v1alpha1/discovery_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type DiscoverySpec struct {

// This is the FlavourSelector that describes the characteristics of the intent that the solver is looking to satisfy
// This pattern corresponds to what has been defined in the REAR Protocol to do a discovery with a selector
Selector nodecorev1alpha1.FlavourSelector `json:"selector"`
Selector *nodecorev1alpha1.FlavourSelector `json:"selector"`

// This flag indicates that needs to be enstablished a subscription to the provider in case a match is found.
// In order to have periodic updates of the status of the matching Flavour
Expand Down
7 changes: 6 additions & 1 deletion apis/advertisement/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions apis/nodecore/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ type NodeIdentity struct {
}

// toString() returns a string representation of the GenericRef.
func (r GenericRef) toString() string {
/* func (r GenericRef) toString() string {
if r.Namespace != "" {
return r.Namespace + "/" + r.Name
}
return r.Name
}
} */
2 changes: 1 addition & 1 deletion apis/nodecore/v1alpha1/solver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type RangeSelector struct {
type SolverSpec struct {

// Selector contains the flavour requirements for the solver.
Selector FlavourSelector `json:"selector"`
Selector *FlavourSelector `json:"selector,omitempty"`

// IntentID is the ID of the intent that the Node Orchestrator is trying to solve.
// It is used to link the solver with the intent.
Expand Down
6 changes: 5 additions & 1 deletion apis/nodecore/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/reservation/v1alpha1/contract_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type ContractSpec struct {

// The partition represents the dimension of the resources sold/bought.
// So it will reflect the dimension of the resources allocated on the remote cluster and reflected on the local virtual node.
Partition Partition `json:"partition,omitempty"`
Partition *Partition `json:"partition,omitempty"`

// This is the Node identity of the buyer FLUIDOS Node.
Buyer nodecorev1alpha1.NodeIdentity `json:"buyer"`
Expand Down
2 changes: 1 addition & 1 deletion apis/reservation/v1alpha1/reservation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type ReservationSpec struct {
Seller nodecorev1alpha1.NodeIdentity `json:"seller"`

// Parition is the partition of the flavour that is being reserved
Partition Partition `json:"partition,omitempty"`
Partition *Partition `json:"partition,omitempty"`

// Reserve indicates if the reservation is a reserve or not
Reserve bool `json:"reserve,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion apis/reservation/v1alpha1/transaction_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type TransactionSpec struct {
ClusterID string `json:"clusterID"`

// Partition is the partition of the flavour that is being reserved
Partition Partition `json:"partition,omitempty"`
Partition *Partition `json:"partition,omitempty"`

// StartTime is the time at which the reservation should start
StartTime string `json:"startTime,omitempty"`
Expand Down
18 changes: 15 additions & 3 deletions apis/reservation/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b2d1e8f

Please sign in to comment.