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

Solutions management #2279

Merged
merged 19 commits into from
Mar 11, 2020
Merged

Solutions management #2279

merged 19 commits into from
Mar 11, 2020

Conversation

alexandre-allard
Copy link
Contributor

@alexandre-allard alexandre-allard commented Mar 3, 2020

Component: salt, scripts, solutions

Context:

Summary:

Acceptance criteria: Ability to import, activate and deploy a Solution in an Environment using the CLI solutions.sh


Closes: #2277

@bert-e
Copy link
Contributor

bert-e commented Mar 3, 2020

Hello alexandre-allard-scality,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Mar 3, 2020

Conflict

A conflict has been raised during the creation of
integration branch w/2.5/feature/solutions-management with contents from feature/solutions-management
and development/2.5.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/2.5/feature/solutions-management origin/development/2.5
 $ git merge origin/feature/solutions-management
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/2.5/feature/solutions-management

return 1
fi

if ! jq -e ".[] | select(.version == \"$VERSION\")" \
Copy link
Contributor

@gdemonet gdemonet Mar 3, 2020

Choose a reason for hiding this comment

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

Installing a package just for this single line seems a bit heavy... But that's OK I guess, jq is a nice tool to have at hand, could even make sense to put it in metalk8s-utils container image (see #2156).

FWIW, here's how you could have done it without external deps:

if ! python -c "import json, sys; \
      available = any(v['version'] == '$VERSION' for v in json.loads('$solution_data')); \
      sys.exit(0 if available else 1)"; then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's a bit heavy, but I think jq can still be useful to parse json as I did here, if one want to read the content of a configmap for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed it and used the python solution.

@alexandre-allard alexandre-allard force-pushed the feature/solutions-management branch 2 times, most recently from 1732bca to 3c98eb4 Compare March 3, 2020 08:56
@alexandre-allard alexandre-allard marked this pull request as ready for review March 3, 2020 08:57
@alexandre-allard alexandre-allard requested a review from a team as a code owner March 3, 2020 08:57
@alexandre-allard alexandre-allard force-pushed the feature/solutions-management branch 6 times, most recently from 2fd3615 to 8fbee1c Compare March 3, 2020 17:22
Copy link
Collaborator

@TeddyAndrieux TeddyAndrieux left a comment

Choose a reason for hiding this comment

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

Some comment but you already know most of them I think

docs/developer/solutions/deploy.rst Outdated Show resolved Hide resolved
docs/developer/solutions/deploy.rst Outdated Show resolved Hide resolved
docs/developer/solutions/deploy.rst Show resolved Hide resolved
}

delete_solution() {
[[ ${NAMESPACE:-} ]] || NAMESPACE=$NAME
Copy link
Collaborator

Choose a reason for hiding this comment

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

All namespaces used for a solution could be retrieved using label selector like in the salt module,
But IMO we don't need to do it in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, but the user can have 2 namespaces in the same environment, with the same Solution and only want to delete a specific Solution, not both.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes indeed but IMO by default we should remove all namespaces even if namespace is not equal to the environement name, but anyway lets not take care of this in the bash script

scripts/solutions.sh Outdated Show resolved Hide resolved
scripts/solutions.sh Show resolved Hide resolved
salt/metalk8s/solutions/available.sls Outdated Show resolved Hide resolved
gdemonet and others added 15 commits March 5, 2020 17:38
Some objects are required for MetalK8s to manage Solutions, notably a
Namespace and ConfigMap for Admin UIs, and the `Environment` CRD.

Issue: #1852
A new field, currently named `active` (may be a poor choice, we'll see
with first user interactions, `activeVersions` could be more explicit),
is introduced to set which version of a Solution should be used for the
cluster-wide components of this Solution (i.e. the Admin UI and CRDs for
now).
Validation of the file format is added, using the usual `kind` and
`apiVersion` fields. Later improvements could use some OpenAPI schema.

Fixes: #1582
Previous approached relied on a ConfigMap, which poses numerous issues:
- it allows one to lie to the formula, potentially causing further
problems down the line
- the CM cannot always be up-to-date with the actual system state (due
to errors when updating it, or manual operations outside of Salt)

We change this approach by including basic heuristics in the
`metalk8s_solutions` module, which can be refined in the future.

Listing of mounted Solutions is made based on `mount.available` and a
naive filtering on the mountpoints (necessarily under /srv/scality).

Listing of active Solution versions is made by looking for UI Service
objects in the `metalk8s-solutions` namespace. This approach relies on
labels that we don't set ourselves, which is brittle, and does not
account for Solutions that may want to ship without an Admin UI.

Future iterations could improve those methods, but we are convinced it
is still safer than the ConfigMap method used before.

Issue: #1852
Making a Solution archive "available" to the cluster was split into two
formulas: `metalk8s.solutions.mounted` and `.configured`.
We group them into a single one, called `.available`.

We also remove the `.unmounted` and `.unconfigured` formulas, since the
source of truth is entirely held by the configuration file
(/etc/metalk8s/solutions.yaml). A single formula is responsible for
applying the desired state described in this configuration, adding and
removing Solution archives from the cluster.
Once a Solution is "available" (i.e. mounted and its images exposed by
the cluster registry), its cluster-wide components can be deployed.

We rely on the `active` mapping of active versions in the config file to
know which components to deploy or remove.

Note that one can set a desired version to 'latest' in this mapping,
which the orchestration will handle for using the highest version
available for a Solution (in SemVer terms).

Issue: #1852
We used `display_name` and `machine_id` to differenciate the expected
consumers (user or machine). For simplicity (thanks to slaperche-scality),
we rename them in `name` and `id` respectively. KISS!
Use Salt to read/write the Solutions config file
Environment CRD is not longer needed as we use directly a ConfigMap in
each namespace
Add salt module to read solution environment ConfigMap and retrieve it
in the solution ext_pillar
We re-instate the ConfigMap as both a way to track which version was
made available (through the `deploy-components` orchestrate) and a way
to share the information with MetalK8s UI users.
The setup of "environment" Namespaces and all the resources required to
run a Solution instance in it is becoming too complex for it to be
properly managed by the Solution Admin UIs, without mentioning the authz
requirements on users of said Admin UIs to make it work.
Instead, Admin UIs will now be deployed once per environment, making it
easier to keep in sync with the same Operator version.
Solution ISOs can now contain a `config.yaml` file to describe the few
specifics of its Operator and UI. We expose this information in the
`metalk8s:solutions:available` pillar, for later consumption in
orchestrations.
Salt is now able to "prepare" environments, based on two sources of
information:

- the environment *Namespace*s (denoted by some well-known labels) and
  their 'metalk8s-environment' *ConfigMap*s (which lists the Solution
  versions to deploy in this environment)
- the *SolutionConfig*s stored in each Solution ISO which allows Salt to
  know what should be deployed

Both sources of information are stored in the pillar.
Let's be consistent with the script's names,
(we don't have bootstrap-manager, downgrade-manager, ...)
the "-manager" suffix is not really useful anyway.

Refs: #2277
We add two helpers:
 - first one to retrieve the saltenv
 - second one to retrieve the local minion ID
These functions will be used in the script
managing the Solutions

Refs: #2277
We no longer try to reconfigure registry by including
metalk8s.repo.installed in metalk8s.solutions.available
which is wrong:
We alter the pillar by mounting Solutions and the changes
are not taken into account inside the repo sls, because
Jjinja rendering has already been done at this point, so
it reconfigures registry with outdated configuration.
We now do this in 2 steps, first mount/unmount Solutions,
then reconfigure registry.

Refs: #2277
Adding of salt no-op to avoid having an empty sls file
after rendering, otherwise it returns an exit code of 2
when using --retcode-passthrough, thus breaking the
calling script.

Refs: #2277
@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Integration data created

I have created the integration data for the additional destination branches.

The following branches will NOT be impacted:

  • development/1.0
  • development/1.1
  • development/1.2
  • development/1.3
  • development/2.0
  • development/2.1
  • development/2.2
  • development/2.3

You can set option create_pull_requests if you need me to create
integration pull requests in addition to integration branches, with:

@bert-e create_pull_requests

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

The following reviewers are expecting changes from the author, or must review again:

@@ -0,0 +1,116 @@
#
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this state should be renamed because he not really make the solutions available now :/ maybe like for archives of metalk8s mounted.sls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we'll change that later, we must first merge this asap.

Copy link
Collaborator

@TeddyAndrieux TeddyAndrieux left a comment

Choose a reason for hiding this comment

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

LGTM

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

@alexandre-allard
Copy link
Contributor Author

/approve

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Build failed

The build for commit did not succeed in branch w/2.6/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Build failed

The build for commit did not succeed in branch w/2.5/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Build failed

The build for commit did not succeed in branch feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Build failed

The build for commit did not succeed in branch w/2.6/feature/solutions-management.

The following options are set: approve

./solutions.sh import --archive </path/to/solution1.iso> \
--archive </path/to/solution2.iso>

Unimport a Solution
Copy link
Contributor

Choose a reason for hiding this comment

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

Unimport is probably not the right term, I would simply say remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's not the right term, it's not even a term. :)
Anyway this stuff will not stay as is and will be changed soon when we'll integrate this script in a centralized CLI.

Copy link
Contributor

Choose a reason for hiding this comment

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

will be changed soon

soon can mean far future or never in IT 😛 (except if you mean it'll be tackled in your next PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost my next PR, it's not "maybe, someday... if we have time" :)

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Build failed

The build for commit did not succeed in branch w/2.5/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Build failed

The build for commit did not succeed in branch feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Build failed

The build for commit did not succeed in branch w/2.6/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Build failed

The build for commit did not succeed in branch w/2.5/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 6, 2020

Build failed

The build for commit did not succeed in branch feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 7, 2020

Build failed

The build for commit did not succeed in branch w/2.5/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 7, 2020

Build failed

The build for commit did not succeed in branch feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 9, 2020

Build failed

The build for commit did not succeed in branch w/2.5/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 9, 2020

Build failed

The build for commit did not succeed in branch w/2.6/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 9, 2020

Build failed

The build for commit did not succeed in branch w/2.5/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 9, 2020

Build failed

The build for commit did not succeed in branch w/2.6/feature/solutions-management.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 9, 2020

In the queue

The changeset has received all authorizations and has been added to the
relevant queue(s). The queue(s) will be merged in the target development
branch(es) as soon as builds have passed.

The changeset will be merged in:

  • ✔️ development/2.4

  • ✔️ development/2.5

  • ✔️ development/2.6

The following branches will NOT be impacted:

  • development/1.0
  • development/1.1
  • development/1.2
  • development/1.3
  • development/2.0
  • development/2.1
  • development/2.2
  • development/2.3

There is no action required on your side. You will be notified here once
the changeset has been merged. In the unlikely event that the changeset
fails permanently on the queue, a member of the admin team will
contact you to help resolve the matter.

IMPORTANT

Please do not attempt to modify this pull request.

  • Any commit you add on the source branch will trigger a new cycle after the
    current queue is merged.
  • Any commit you add on one of the integration branches will be lost.

If you need this pull request to be removed from the queue, please contact a
member of the admin team now.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Mar 11, 2020

I have successfully merged the changeset of this pull request
into targetted development branches:

  • ✔️ development/2.4

  • ✔️ development/2.5

  • ✔️ development/2.6

The following branches have NOT changed:

  • development/1.0
  • development/1.1
  • development/1.2
  • development/1.3
  • development/2.0
  • development/2.1
  • development/2.2
  • development/2.3

Please check the status of the associated issue None.

Goodbye alexandre-allard-scality.

@bert-e bert-e merged commit ac115f9 into development/2.4 Mar 11, 2020
@bert-e bert-e deleted the feature/solutions-management branch March 11, 2020 15:32
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.

None yet

6 participants